o
    i                     @   sx  d dl Z d dlZd dlmZmZmZ d dlZd dlmZm	Z	m
Z
mZ d dlmZmZ d dlmZmZ d dlmZ ddlmZ erFdd	lmZ d
eeB dB defddZdedee fddZdZe
dddfdedededB dedB dedB ded defddZdedededefddZ dd defd!d"Z!d#e"eef d$e"eef ddfd%d&Z#d'eeB d(eeB deeB fd)d*Z$dS )+    N)TYPE_CHECKINGAnyLiteral)
ModelFieldPydanticSchemaGenerationError	Undefinedannotation_is_pydantic_v1)DefaultPlaceholderDefaultType)FastAPIDeprecationWarningPydanticV1NotSupportedError)	FieldInfo   )v2)APIRoutestatus_codereturnc                 C   s2   | d u rdS | dv rdS t | }|dk p|dv  S )NT>   Z5XXZ1XXdefaultZ4XXZ3XXZ2XX   >   i0        )int)r   Zcurrent_status_code r   D/home/app/Keep/.python/lib/python3.10/site-packages/fastapi/utils.pyis_body_allowed_for_status_code   s   r   pathc                 C   s   t td| S )Nz{(.*?)})setrefindall)r   r   r   r   get_path_param_names+   s   r   a  Invalid args for response field! Hint: check that {type_} is a valid Pydantic field type. If you are using a return type annotation that is not a valid Pydantic field (e.g. Union[Response, dict, None]) you can disable generating the response model from the type annotation with the path operation decorator parameter response_model=None. Read more: https://fastapi.tiangolo.com/tutorial/response-model/
validationnametype_r   
field_infoaliasmode)r    Zserializationc                 C   sb   t |rtd|d|pt|||d}z	tj|| |dW S  ty0   tjt	j
|dd w )NzXpydantic.v1 models are no longer supported by FastAPI. Please update the response model .)
annotationr   r$   )r%   r!   r#   )r"   )r   r   r   r   r   r   fastapi
exceptionsZFastAPIError_invalid_args_messageformat)r!   r"   r   r#   r$   r%   r   r   r   create_model_field:   s    
r,   methodc                 C   s@   t jdtdd |  | }tdd|}| d|  }|S )Nzrfastapi.utils.generate_operation_id_for_path() was deprecated, it is not used internally, and will be removed soon   )messagecategory
stacklevel\W_)warningswarnr   r   sublower)r!   r   r-   operation_idr   r   r   generate_operation_id_for_pathP   s   r9   router   c                 C   sH   | j  | j }tdd|}| jsJ | dt| jd   }|S )Nr2   r3   r   )r!   Zpath_formatr   r6   methodslistr7   )r:   r8   r   r   r   generate_unique_id_   s
   
r=   	main_dictupdate_dictc                 C   s   |  D ]=\}}|| v r t| | tr t|tr t| | | q|| v r=t| | tr=t|| tr=| | ||  | |< q|| |< qd S )N)items
isinstancedictdeep_dict_updater<   )r>   r?   keyvaluer   r   r   rC   g   s   
rC   
first_itemextra_itemsc                 G   s*   | f| }|D ]}t |ts|  S q| S )z
    Pass items or `DefaultPlaceholder`s by descending priority.

    The first one to _not_ be a `DefaultPlaceholder` will be returned.

    Otherwise, the first item (a `DefaultPlaceholder`) will be returned.
    )rA   r	   )rF   rG   r@   itemr   r   r   get_value_or_defaulty   s   

rI   )%r   r4   typingr   r   r   r(   Zfastapi._compatr   r   r   r   Zfastapi.datastructuresr	   r
   Zfastapi.exceptionsr   r   Zpydantic.fieldsr   _compatr   Zroutingr   r   strboolr   r   r   r*   r,   r9   r=   rB   rC   rI   r   r   r   r   <module>   sh    

&