o
    ûT·j£r  ã                !   @   sÐ  U d dl Z d dlZd dlZd dlZd dlmZ d dlmZm	Z	 d dl
mZmZmZ d dlmZ d dlmZmZmZmZmZmZ d dlmZmZ d dlmZmZmZmZmZm Z  d d	l!m"Z"m#Z#m$Z$ d d
l%m&Z& d dl'm(Z( d dl)m*Z*m+Z+ d dl,m-Z- d dl.m/Z/m0Z0 d dl1m2Z2 d dl3m4Z4 d dl5m6Z6m7Z7 d dl8m9Z9m:Z:m;Z; d dl<m=Z= d dl>m?Z? d dl@mAZA dddddddiddigidœddd œd!dd œd"d#id$dd œd%œg d&¢d'œZBd(dd)d*dd+e+d idœid,œZCd-d.d/d0d1d2d3œZDeEeFeFf eGd4< eG d5d6„ d6ƒƒZHd7ed8eHfd9d:„ZId;eJeKeeJeF f  d8eKeEeFef eJeEeFef  f fd<d=„ZLd>d?œd@eHdAe7dBeEeKeedC f eEeFef f dDeMd8eJeEeFef  f
dEdF„ZNd>d?œdGedB dAe7dBeEeKeedC f eEeFef f dDeMd8eEeFef dB f
dHdI„ZOdJejPdKeFd8eFfdLdM„ZQdJejPdKeFd8eFfdNdO„ZRdJejPdKeFdPeSeF d8eEeFef fdQdR„ZTd>d?œdJejPdPeSeF dAe7dBeEeKeedC f eEeFef f dDeMd8eKeEeFef eEeFef eEeFef f fdSdT„ZUdUejVd8ejPdB fdVdW„ZWdXeeAejVB  d8eJe fdYdZ„ZXd[ddddddddd>dd\œd"eFd]eFd^eFd_eFdB d`eFdB dXeeAejVB  daeeAejVB  dB dbeJeEeFef  dB dceJeEeFeFeB f  dB ddeFdB deeEeFeFeB f dB dfeEeFeFeB f dB dDeMdgeEeFef dB d8eEeFef fdhdi„ZYdS )jé    N)ÚSequence)Ú	dataclassÚfield)ÚAnyÚLiteralÚcast)Úrouting)Ú
ModelFieldÚget_definitionsÚget_flat_models_from_fieldsÚget_model_name_mapÚget_schema_from_model_fieldÚlenient_issubclass)ÚDefaultPlaceholderÚ_Unset)Ú	DependantÚ_get_cache_keyÚ_get_oauth_scopesÚ_get_security_schemeÚ_is_security_schemeÚ_UsesScopesCache)Ú_get_flat_fields_from_paramsÚget_flat_paramsÚget_validation_alias)Újsonable_encoder)ÚFastAPIDeprecationWarning)ÚMETHODS_WITH_BODYÚ
REF_PREFIX)ÚOpenAPI)ÚBodyÚ
ParamTypes)ÚResponse)Ú_SSE_EVENT_SCHEMA)ÚDependencyCacheKeyÚModelNameMap)Údeep_dict_updateÚgenerate_operation_id_for_pathÚis_body_allowed_for_status_code)Ú	BaseModel)ÚJSONResponse)Ú	BaseRouteÚValidationErrorÚobjectÚLocationÚarrayÚanyOfÚtypeÚstringÚinteger)Útitler0   ÚitemsÚMessage)r3   r0   z
Error Typer3   ÚInputÚContext)ÚlocÚmsgr0   ÚinputÚctx)r8   r9   r0   )r3   r0   Ú
propertiesÚrequiredÚHTTPValidationErrorÚdetailÚDetailú$ref)r3   r0   r<   ÚInformationÚSuccessÚRedirectionzClient ErrorzServer ErrorzDefault Response)Ú1XXÚ2XXÚ3XXÚ4XXÚ5XXÚDEFAULTÚstatus_code_rangesc                   @   sˆ   e Zd ZU eed�Zee ed< eed�Zee ed< eed�Z	ee ed< eed�Z
ee ed< eed�Zeeeee f  ed< dS )Ú_OpenAPIDependencyData)Údefault_factoryÚpath_paramsÚquery_paramsÚheader_paramsÚcookie_paramsÚsecurity_dependenciesN)Ú__name__Ú
__module__Ú__qualname__r   ÚlistrN   r	   Ú__annotations__rO   rP   rQ   rR   Útupler   Ústr© rZ   rZ   úX/home/dinkstrade/pdmp-scanner/venv/lib/python3.10/site-packages/fastapi/openapi/utils.pyrL   X   s   
 "ÿrL   Ú	dependantÚreturnc           
         sò   t ƒ }g }i }| g dfg}|rw| ¡ \}}}t||d�}||v r!q| |¡ |j |j¡ |j |j¡ |j |j¡ |j |j¡ | 	¡ ‰ t
|d�D ]}	|	ˆ vrVˆ  |	¡ qK|sft|d�rf|j |ˆ f¡ | ‡ fdd„t|jƒD ƒ¡ |s|S )NT)r\   Úuses_scopes_cache©r\   c                 3   s   � | ]}|ˆ d fV  qdS )FNrZ   )Ú.0Úsub_dependant©Úoauth_scopesrZ   r[   Ú	<genexpr>}   s
   € ÿ
ÿz/_get_openapi_dependency_data.<locals>.<genexpr>)rL   Úpopr   ÚappendrN   ÚextendrO   rP   rQ   Úcopyr   r   rR   ÚreversedÚdependencies)
r\   Údependency_dataÚvisitedr^   Ú
dependantsÚcurrent_dependantÚparent_oauth_scopesÚis_rootÚ	cache_keyÚscoperZ   rb   r[   Ú_get_openapi_dependency_datac   s>   þ

€ÿþërs   rR   c           
      C   sŒ   i }i }| D ]2\}}t |d�}t|jddd�}|j}|||< ||vr&g ||< |D ]}||| vr7||  |¡ q(qdd„ | ¡ D ƒ}	||	fS )Nr_   T©Úby_aliasÚexclude_nonec                 S   s   g | ]\}}||i‘qS rZ   rZ   )r`   ÚnameÚscopesrZ   rZ   r[   Ú
<listcomp>™   s    ÿz5_get_openapi_security_definitions.<locals>.<listcomp>)r   r   ÚmodelÚscheme_namerf   r4   )
rR   Úsecurity_definitionsÚoperation_security_dictÚsecurity_dependencyrc   Úsecurity_schemeÚsecurity_definitionÚsecurity_namerr   Úoperation_securityrZ   rZ   r[   Ú!_get_openapi_security_definitions„   s,   
ý€þÿrƒ   T)Úseparate_input_output_schemasrk   Úmodel_name_mapÚfield_mapping)Ú
validationÚserializationr„   c                 C   s†  g }t | jƒ}t | jƒ}t | jƒ}t | jƒ}tj|ftj|ftj|ftj	|fg}	d}
t
| jƒdkrD| jd }t|jjtƒrDt|jddƒ}
|	D ]z\}}|D ]s}|j}t|ddƒsXqLt||||d�}t|ƒ}t|jd|
ƒ}|tjkr~||jkr~|r~|j dd¡}||j|j ¡ |d	œ}|jr‘|j|d
< t|dd ƒ}t|dd ƒ}|r¦t|ƒ|d< n
|tur°t|ƒ|d< t|dd ƒrºd|d< | |¡ qLqF|S )NTé   r   Úconvert_underscoresÚinclude_in_schema©r   r…   r†   r„   Ú_ú-)rw   Úinr=   ÚschemaÚdescriptionÚopenapi_examplesÚexampleÚexamplesÚ
deprecated)r   rN   rO   rP   rQ   r    ÚpathÚqueryÚheaderÚcookieÚlenr   Ú
field_infoÚ
annotationr(   Úgetattrr   r   rw   ÚreplaceÚvalueÚis_requiredr‘   r   r   rf   )rk   r…   r†   r„   Ú
parametersrN   rO   rP   rQ   Úparameter_groupsÚdefault_convert_underscoresÚfirst_fieldÚ
param_typeÚparam_groupÚparamr›   Úparam_schemarw   rŠ   Ú	parameterr’   r“   rZ   rZ   r[   Ú!_get_openapi_operation_parametersŸ   sr   	



ü
ÿüý

ÿü
Ø)rª   Ú
body_fieldc           
      C   s˜   | sd S t | tƒsJ ‚t| |||d�}tt| jƒ}|j}| j ¡ }i }|r)||d< d|i}	|jr8t	|jƒ|	d< n|j
turDt	|j
ƒ|	d< ||	i|d< |S )NrŒ   r=   r�   r”   r“   Úcontent)Ú
isinstancer	   r   r   r   r›   Ú
media_typer    r’   r   r“   r   )
r«   r…   r†   r„   Úbody_schemar›   Úrequest_media_typer=   Úrequest_body_oaiÚrequest_media_contentrZ   rZ   r[   Ú"get_openapi_operation_request_bodyç   s0   	ü

ÿ
r³   ÚrouteÚmethodc                 C   s2   t jdtdd� | jr| jS | j}t| j||d�S )Nzqfastapi.openapi.utils.generate_operation_id() was deprecated, it is not used internally, and will be removed sooné   )ÚmessageÚcategoryÚ
stacklevel)rw   r–   rµ   )ÚwarningsÚwarnr   Úoperation_idÚpath_formatr&   rw   )r´   rµ   r–   rZ   rZ   r[   Úgenerate_operation_id
  s   ür¾   c                 C   s   | j r| j S | j dd¡ ¡ S )Nr�   ú )Úsummaryrw   rž   r3   ©r´   rµ   rZ   rZ   r[   Úgenerate_operation_summary  s   rÂ   Úoperation_idsc                 C   sÀ   i }| j r
| j |d< t| |d�|d< | jr| j|d< | jp| j}||v rMt| jddƒ}d|› d|› �}t| jd	i ƒ d
¡}|rF|d|› �7 }tj	|dd� | 
|¡ ||d< | jr^| j|d< |S )NÚtagsrÁ   rÀ   r‘   rS   z<unnamed_endpoint>zDuplicate Operation ID z for function Ú__globals__Ú__file__z at r‰   )r¹   ÚoperationIdr•   )rÄ   rÂ   r‘   r¼   Ú	unique_idr�   ÚendpointÚgetrº   r»   Úaddr•   )r´   rµ   rÃ   Ú	operationr¼   Úendpoint_namer·   Ú	file_namerZ   rZ   r[   Úget_openapi_operation_metadata  s&   



rÏ   c           .   	      s
  i }i }i }| j d usJ dƒ‚t| jtƒr| jj}n| j}|s#J dƒ‚|j}	| j�r€t| jƒ}
dd„ |
j	|
j
|
j|
jfD ƒ}| j D �]=}t| ||d�‰ g }t|
jd�\}}|r`ˆ  dg ¡ |¡ |rg| |¡ t|
|||d�}| |¡ |r‘d	d
„ |D ƒ}dd
„ |D ƒ}| |¡ t| ¡ ƒˆ d< |tv r¤t| j|||d�}|r¤|ˆ d< | jrÑi }| jD ] }t|tjƒrÌtttj|ƒ||||d�\}}}|j|i||j < q¬|ˆ d< | j!d urÜt"| j!ƒ}nt# $|j%¡}|j& 'd¡}|d ur÷t|j(t)ƒr÷t"|j(ƒ}| j*ˆ  di ¡ |i ¡d< t+| j!ƒ�r¤| j,�r7i }| j-�r"t.| j-|||d�}||d< ni |d< |ˆ  di ¡ |i ¡ di ¡d< nm| j/�rsi }t0 1t2¡}| j-�r^t.| j-|||d�}dg|d< dd|dœ|d d< ||d< |ˆ  di ¡ |i ¡ di ¡d< n1|	�r¤ddi} t3|t4ƒ�r�| j5�rŽt.| j5|||d�} ni } | ˆ  di ¡ |i ¡ di ¡ |	i ¡d < | j6�r9ˆ  di ¡}!| j6 7¡ D ]…\}"}#t0 1|#¡}$|$ 8d!d ¡ t"|"ƒ 9¡ }%|%d"k�rÏd#}%|! |%i ¡}&t|$t:ƒ�sßJ d$ƒ‚| j; '|"¡}'d }(|'�r
t.|'|||d�}(|	�pöd})|$ di ¡ |)i ¡ d i ¡}*t<|*|(ƒ t= 't"|"ƒ 9¡ ¡�pt>j?j6 't)|"ƒ¡}+|$ 'd¡�p-|& 'd¡�p-|+�p-d%},t<|&|$ƒ |,|&d< �q³d&}-|�sB| j�rot@‡ fd'd(„|-d)d#fD ƒƒ�sod*dd d+tAd, iiid-œˆ d |-< d.|v�ro| tBtCd/œ¡ | jD�ryt<ˆ | jDƒ ˆ || E¡ < qA|||fS )0NzMethods must be a listz.A response class is needed to generate OpenAPIc                 S   s   g | ]}t |ƒD ]}|‘qqS rZ   )r   )r`   Úfieldsr   rZ   rZ   r[   ry   M  s    øùÿz$get_openapi_path.<locals>.<listcomp>)r´   rµ   rÃ   )rR   Úsecurity)rk   r…   r†   r„   c                 S   s   i | ]}|d  |d f|“qS )r�   rw   rZ   ©r`   r§   rZ   rZ   r[   Ú
<dictcomp>m  s    ÿz$get_openapi_path.<locals>.<dictcomp>c                 S   s(   i | ]}|  d ¡r|d |d f|“qS )r=   r�   rw   )rÊ   rÒ   rZ   rZ   r[   rÓ   p  s    ýÿr¡   )r«   r…   r†   r„   ÚrequestBody©r´   rÃ   r…   r†   r„   Ú	callbacksÚstatus_codeÚ	responsesr‘   rŒ   Ú
itemSchemar¬   zapplication/jsonlÚdatar=   r1   zapplication/json)r0   ÚcontentMediaTypeÚcontentSchemar<   ztext/event-streamr0   r�   rz   rJ   Údefaultz%An additional response must be a dictzAdditional ResponseÚ422c                 3   s   � | ]	}|ˆ d  v V  qdS )rØ   NrZ   )r`   Ústatus©rÌ   rZ   r[   rd     s
   € 
ÿ
ÿz#get_openapi_path.<locals>.<genexpr>rH   zValidation ErrorrA   r>   )r‘   r¬   r+   )r+   r>   )FÚmethodsr­   Úresponse_classr   rŸ   r®   r‹   rs   r\   rN   rO   rP   rQ   rÏ   rƒ   rR   Ú
setdefaultrg   Úupdaterª   rV   Úvaluesr   r³   r«   rÖ   r   ÚAPIRouteÚget_openapi_pathr   Ú_APIRouteLiker–   rw   r×   rY   ÚinspectÚ	signatureÚ__init__r¡   rÊ   rÝ   ÚintÚresponse_descriptionr'   Úis_json_streamÚstream_item_fieldr   Úis_sse_streamrh   Údeepcopyr"   r   r)   Úresponse_fieldrØ   r4   re   ÚupperÚdictÚresponse_fieldsr%   rK   ÚhttpÚclientÚanyr   Úvalidation_error_definitionÚ$validation_error_response_definitionÚopenapi_extraÚlower).r´   rÃ   r…   r†   r„   r–   Úsecurity_schemesÚdefinitionsÚcurrent_response_classÚroute_response_media_typerk   Úall_route_paramsrµ   r¡   r|   r‚   Úoperation_parametersÚall_parametersÚrequired_parametersr±   rÖ   ÚcallbackÚcb_pathÚcb_security_schemesÚcb_definitionsr×   Úresponse_signatureÚstatus_code_paramÚjsonl_contentÚitem_schemaÚsse_contentÚcontent_schemaÚresponse_schemaÚoperation_responsesÚadditional_status_codeÚadditional_responseÚprocess_responseÚstatus_code_keyÚopenapi_responser   Úadditional_field_schemar®   Úadditional_schemaÚstatus_textr‘   Úhttp422rZ   rà   r[   rç   7  s¦  


üþ
ÿÿÿ
ü
ÿþ
ü

ûü€

þÿü
þÿ
þ
ü
ýþÿ
þüüÿ
ÿüý

ÿÿü

ý

ÿþÿþü

þÿÿþ
þÿ
rç   Úroute_contextc                 C   s   t | jtjƒrttj| ƒS d S )N)r­   Úoriginal_router   ræ   r   rè   )r  rZ   rZ   r[   Ú_get_api_route_for_openapi  s   r  Úroutesc           	      C   sÚ   g }g }g }g }t  | ¡D ]S}t|ƒ}|d u rq|jr`|jr.t|jtƒs(J dƒ‚| |j¡ |jr7| |j¡ |j	rB| 
|j	 ¡ ¡ |jrK| |j¡ |jrV| 
t|jƒ¡ t|jƒ}| 
|¡ q|t|| | ƒ }|S )Nz'A request body must be a Pydantic Field)r   Úiter_route_contextsr  r‹   r«   r­   r	   rf   rò   rõ   rg   rå   rï   rÖ   Úget_fields_from_routesr   r\   rV   )	r  Úbody_fields_from_routesÚresponses_from_routesÚrequest_fields_from_routesÚcallback_flat_modelsr  Ú	api_routeÚparamsÚflat_modelsrZ   rZ   r[   r  '  s:   ÿ

€
ÿr  z3.1.0)Úopenapi_versionrÀ   r‘   ÚwebhooksrÄ   ÚserversÚterms_of_serviceÚcontactÚlicense_infor„   Úexternal_docsÚversionr'  rÀ   r‘   r(  rÄ   r)  r*  r+  r,  r-  c                     s  | |dœ}|r||d< |r||d< |	r|	|d< |
r|
|d< |r#||d< ||dœ}|r.||d< i }i }i }t ƒ }tt|ƒt|p?g ƒ ƒ}t|t ƒ d	�}t|ƒ}t|||d
�\}‰ t |¡D ]8}t|ƒ}|d ur”t	|||||d�}|r”|\}}}|r‚| 
|ji ¡ |¡ |r�| 
di ¡ |¡ |r”ˆ  |¡ q\t |pšg ¡D ]8}t|ƒ}|d urÔt	|||||d�}|rÔ|\}}}|rÂ| 
|ji ¡ |¡ |rÍ| 
di ¡ |¡ |rÔˆ  |¡ qœˆ rä‡ fdd„tˆ ƒD ƒ|d< |rê||d< ||d< |rô||d< |rú||d< |�r||d< ttdi |¤Žddd�S )N)r3   r.  rÀ   r‘   ÚtermsOfServicer+  Úlicense)ÚopenapiÚinfor)  )Úknown_models)rÐ   r…   r„   rÕ   ÚsecuritySchemesc                    s   i | ]}|ˆ | “qS rZ   rZ   )r`   Úk©rþ   rZ   r[   rÓ   �  s    zget_openapi.<locals>.<dictcomp>ÚschemasÚ
componentsÚpathsr(  rÄ   ÚexternalDocsTrt   rZ   )Úsetr  rV   r   r   r
   r   r  r  rç   rã   r½   rä   Úsortedr   r   ) r3   r.  r'  rÀ   r‘   r  r(  rÄ   r)  r*  r+  r,  r„   r-  r2  Úoutputr8  r9  Úwebhook_pathsrÃ   Ú
all_fieldsr&  r…   r†   r  r$  Úresultr–   rý   Úpath_definitionsÚwebhook_contextÚapi_webhookrZ   r6  r[   Úget_openapiI  s    


ýû
ÿ
€û
ÿ
€rD  )Zrh   Úhttp.clientrö   ré   rº   Úcollections.abcr   Údataclassesr   r   Útypingr   r   r   Úfastapir   Úfastapi._compatr	   r
   r   r   r   r   Úfastapi.datastructuresr   r   Úfastapi.dependencies.modelsr   r   r   r   r   r   Úfastapi.dependencies.utilsr   r   r   Úfastapi.encodersr   Úfastapi.exceptionsr   Úfastapi.openapi.constantsr   r   Úfastapi.openapi.modelsr   Úfastapi.paramsr   r    Úfastapi.responsesr!   Úfastapi.sser"   Úfastapi.typesr#   r$   Úfastapi.utilsr%   r&   r'   Úpydanticr(   Ústarlette.responsesr)   Ústarlette.routingr*   rù   rú   rK   rô   rY   rW   rL   rs   rV   rX   rƒ   Úboolrª   r³   rè   r¾   rÂ   r;  rÏ   rç   ÚRouteContextr  r  rD  rZ   rZ   rZ   r[   Ú<module>   s^  
   ý÷ò
ýÿýú

!ÿ
þ"ùþýÿüù
øOùþýÿüù
ø#ÿÿ
þÿÿÿ

þ øþýüÿûø$	
÷ iÿ
þÿ
þ&ñþýüûúùø	÷
öõôóòñ
ð