
    "dxI                        U d dl Zd dlZd dlZd dlmZ d dlmZmZm	Z	m
Z
mZmZmZmZmZmZ d dl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mZ d d
lm Z  d dl!m"Z"m#Z# d dl$m%Z% d dl&m'Z'm(Z(m)Z)m*Z* d dl+m,Z, d dl-m.Z.m/Z/ d dl0m1Z1m2Z2m3Z3 d dl4m5Z5 d dl6m7Z7 d dl8m9Z9 d dl:m;Z; dddddddiddigiddddd ddd!g d!d"Z<d#dd$d%dd&edz   idid'Z=d(d)d*d+d,d-d.Z>ee?e?f         e@d/<   d0ed1eee?ef         e	ee?ef                  f         fd2ZAd3ee.         d4eeee,         ee         f         e?f         d1e	ee?ef                  fd5ZBd6e
e.         d4eeee,         ee         f         e?f         d1e
ee?ef                  fd7ZCd8ejD        d9e?d1e?fd:ZEd8ejD        d9e?d1e?fd;ZFd8ejD        d9e?d<ee?         d1ee?ef         fd=ZGd8ejD        d4eeHe?f         d<ee?         d1eee?ef         ee?ef         ee?ef         f         fd>ZId?ee9         d1eeee,         ee         f                  fd@ZJdAdddddddBdCe?dDe?dEe?dFe
e?         d?ee9         dGe
e	ee?ef                           dHe
e	ee?ee?ef         f                           dIe
e?         dJe
ee?ee?ef         f                  dKe
ee?ee?ef         f                  d1ee?ef         fdLZKdS )M    N)Enum)
AnyDictListOptionalSequenceSetTupleTypeUnioncast)routing)DefaultPlaceholder)	Dependant)get_flat_dependantget_flat_params)jsonable_encoder)METHODS_WITH_BODY
REF_PREFIX)OpenAPI)BodyParam)Response)deep_dict_updategenerate_operation_id_for_pathget_model_definitionsis_body_allowed_for_status_code)	BaseModel)
ModelField	Undefined)field_schemaget_flat_models_from_fieldsget_model_name_map)lenient_issubclass)JSONResponse)	BaseRoute)HTTP_422_UNPROCESSABLE_ENTITYValidationErrorobjectLocationarrayanyOftypestringinteger)titler-   itemsMessage)r0   r-   z
Error Type)locmsgr-   )r0   r-   
propertiesrequiredHTTPValidationErrordetailDetail$ref)r0   r-   r5   InformationSuccessRedirectionzClient ErrorzServer ErrorzDefault Response)1XX2XX3XX4XX5XXDEFAULTstatus_code_rangesflat_dependantreturnc                     i }g }| j         D ]K}t          |j        j        dd          }|j        j        }|||<   |                    ||j        i           L||fS )NTby_aliasexclude_none)security_requirementsr   security_schememodelscheme_nameappendscopes)rE   security_definitionsoperation_securitysecurity_requirementsecurity_definitionsecurity_names         9D:\api_v1\venv\Lib\site-packages\fastapi/openapi/utils.py get_openapi_security_definitionsrW   G   s      . D P P. 06
 
 

 -<H.A]+!!=2F2M"NOOOO!333    all_route_paramsmodel_name_mapc           	         g }| D ]}|j         }t          t          |          }|j        s&|j        |j        j        |j        t          ||t                    d         d}|j
        r
|j
        |d<   |j        rt          |j                  |d<   n'|j        t          k    rt          |j                  |d<   |j        r
|j        |d<   |                    |           |S )NrZ   
ref_prefixr   )nameinr6   schemadescriptionexamplesexample
deprecated)
field_infor   r   include_in_schemaaliasin_valuer6   r!   r   ra   rb   r   rc   r    rd   rO   )rY   rZ   
parametersparamre   	parameters         rV    get_openapi_operation_parametersrm   X   s   
 J! % %%
%,,
+ 	K.&"n  	
 
	 ! 	>'1'=Im$ 	H$4Z5H$I$IIj!!9,,#3J4F#G#GIi   	<&0&;Il#)$$$$rX   
body_fieldc                 v   | sd S t          | t                    sJ t          | |t                    \  }}}t	          t
          | j                  }|j        }| j        }i }|r||d<   d|i}|j	        rt          |j	                  |d<   n'|j        t          k    rt          |j                  |d<   ||i|d<   |S )Nr\   r6   r`   rb   rc   content)
isinstancer   r!   r   r   r   re   
media_typer6   rb   r   rc   r    )	rn   rZ   body_schema_re   request_media_typer6   request_body_oairequest_media_contents	            rV   "get_openapi_operation_request_bodyrx   w   s    
  tj*-----$>j  KA dJ122J#."H') 0'/$-5{,C P,<Z=P,Q,Qj))		y	(	(+;J<N+O+Oi(#57L"MYrX   routemethodc                     t          j        dt          d           | j        r| j        S | j        }t          | j        ||          S )Nzqfastapi.openapi.utils.generate_operation_id() was deprecated, it is not used internally, and will be removed soon   )
stacklevel)r^   pathrz   )warningswarnDeprecationWarningoperation_idpath_formatr   r^   )ry   rz   r~   s      rV   generate_operation_idr      s]     M	>	     "!!!D)uzVTTTTrX   c                 x    | j         r| j         S | j                            dd                                          S )Nrt    )summaryr^   replacer0   ry   rz   s     rV   generate_operation_summaryr      s8    } }:c3''--///rX   operation_idsc                    i }| j         r
| j         |d<   t          | |          |d<   | j        r
| j        |d<   | j        p| j        }||v r[d| d| j        j         z   }t          | j        di                               d          }|r|d	| z  }t          j
        |           |                    |           ||d
<   | j        r
| j        |d<   |S )Ntagsr   r   ra   zDuplicate Operation ID z for function __globals____file__z at operationIdrd   )r   r   ra   r   	unique_idendpoint__name__getattrgetr   r   addrd   )ry   rz   r   	operationr   message	file_names          rV   get_openapi_operation_metadatar      s    !#Iz '!J	&5E&QQQIi 5#(#4	- %8L}$$BlBBB(*+ 	 ENM2>>BB:NN	 	*)i)))Ggl###+Im 3"'"2	,rX   c                   ) i }i }i }| j         
J d            t          | j        t                    r| j        j        }n| j        }|s
J d            |j        }| j        r| j         D ]}t          | ||          )g }	t          | j	        d          }
t          |
          \  }}|r))                    dg                               |           |r|                    |           t          | j	                  }t          ||          }|	                    |           |	rQd	 |	D             }d
 |	D             }|                    |           t!          |                                          )d<   |t$          v rt'          | j        |          }|r|)d<   | j        rRi }| j        D ]C}t          |t,          j                  r't1          |||          \  }}}|j        |i||j        <   D|)d<   | j        t9          | j                  }nct;          j        |j                  }|j         !                    d          }|.t          |j"        tF                    rt9          |j"                  }| j$        )                    di                               |i           d<   |rtK          | j                  rddi}tM          |tN                    r*| j(        r!tS          | j(        |tT                    \  }}}ni }|)                    di                               |i                               di                               |i           d<   | j+        r)                    di           }| j+        ,                                D ]\  }}|-                                }|.                    dd            t9          |          /                                } | dk    rd} |                    | i           }!t          |t`                    s
J d            | j1        !                    |          }"d }#|"rmtS          |"|tT                    \  }#}}|pd}$|                    di                               |$i                               di           }%te          |%|#           tf          !                    t9          |          /                                          p0th          j5        j+        !                    tG          |                    }&|!                    d          p|!!                    d          p|&pd}'te          |!|           |'|!d<   t9          tl                    }(|s| j        r`to          )fd|(ddfD                       sBd ddd!tT          d"z   iiid#)d         |(<   d$|vr"|                    tp          tr          d%           | j:        rte          )| j:                   )||;                                <   |||fS )&NzMethods must be a listz.A response class is needed to generate OpenAPI)ry   rz   r   T)skip_repeats)rE   security)rY   rZ   c                 0    i | ]}|d          |d         f|S )r_   r^    .0rk   s     rV   
<dictcomp>z$get_openapi_path.<locals>.<dictcomp>   s4     " " "<AU4[%-0%" " "rX   c                 Z    i | ](}|                     d           |d         |d         f|)S )r6   r_   r^   )r   r   s     rV   r   z$get_openapi_path.<locals>.<dictcomp>   sI     ' ' 'yy,,'4[%-0%' ' 'rX   rj   )rn   rZ   requestBodyry   rZ   r   	callbacksstatus_code	responsesra   r-   r.   r\   rp   r`   rM   rC   defaultz%An additional response must be a dictzapplication/jsonzAdditional Responsec                 $    g | ]}|d          v S )r   r   )r   statusr   s     rV   
<listcomp>z$get_openapi_path.<locals>.<listcomp>O  s3        i44  rX   rA   zValidation Errorr:   r7   )ra   rp   r(   )r(   r7   )<methodsrq   response_classr   ri   rr   rf   r   r   	dependantrW   
setdefaultextendupdater   rm   listvaluesr   rx   rn   r   r   APIRouteget_openapi_pathr~   r^   r   strinspect	signature__init__rj   r   r   intresponse_descriptionr   r$   r%   response_fieldr!   r   r   r1   copypopupperdictresponse_fieldsr   rD   httpclientr'   anyvalidation_error_definition$validation_error_response_definitionopenapi_extralower)*ry   rZ   r   r~   security_schemesdefinitionscurrent_response_classroute_response_media_typerz   rj   rE   rQ   rR   rY   operation_parametersall_parametersrequired_parametersrv   r   callbackcb_pathcb_security_schemescb_definitionsr   response_signaturestatus_code_paramresponse_schemart   operation_responsesadditional_status_codeadditional_responseprocess_responsestatus_code_keyopenapi_responsefieldadditional_field_schemarr   additional_schemastatus_textra   http422r   s*                                            @rV   r   r      s    D')"$K=$$&>$$$%&(:;; 6161E1K!&!5!SS#SSSS/E/P X-m W	- W	-F6F-  I 02J/dSSSN7W-8 8 84 "4 " P$$Z44;;<NOOO# > ''(<===.u??#C!1.$ $ $  2333 H" "EO" " "' '!+' ' '# %%&9:::*.~/D/D/F/F*G*G	,'***#E$/$ $ $  $ @/?Im, 3	 % L LH!(G,<== 
L
 -"*+9*7  	#/* 5=M73K	(-0)2	+& ,!%"344 &-%67M7V%W%W"$6$A$E$Em$T$T!$0!"3";SAA E&)*;*C&D&D *   b11<<["MM ) $-L!. . $ $*8"4%&<lKK -+ -0<!0+9'11 1 1-AA +-
 $	 $$["55@@ *Y++JJ7PRT,U,U
  (B&/&:&:;&K&K# _**,,&B &B *'':'?'?'A'A$$(($777&)*@&A&A&G&G&I&IO&)33*3':'E'E'( ($ &($  ? ?>? ? ? "1556LMMEHL+ 
U8D!.Z9 9 95/A &?%TBT
,77	2FF'Z
B77'Z"55 *
 )):<STTT1C1G1G23399;;2 2 2P.2237M3N3NOO   ),,];; 1+//>>1&1 1	   %%57GHHH6A$]33788G  E$4 c   #*E9"=  ? ?  $6*$vz<Q/Q&R- 3 3	+&w/ %K77&&/J3W    " A E,?@@@#,D  !;..rX   routesc                    g }g }g }t                      }| D ]}t          |dd           rt          |t          j                  r|j        r>t          |j        t                    s
J d            |                    |j                   |j        r|                    |j                   |j	        r,|
                    |j	                                                   |j        r|t          |j                  z  }t          |j                  }|
                    |           |t!          ||z   |z   t                                z  }|S )Nrf   z'A request body must be a Pydantic Field)known_models)setr   rq   r   r   rn   r   rO   r   r   r   r   r   get_flat_models_from_routesr   r   r"   )r   body_fields_from_routesresponses_from_routesrequest_fields_from_routescallback_flat_modelsry   paramsflat_modelss           rV   r   r   i  s    13.035DGEE 6 65-t44 	67#:
 :
 	6  A!$j  = =<= = = (..u/?@@@# C%,,U-ABBB$ M%,,U-B-I-I-K-KLLL U$(CEO(T(TT$$U_55F&--f555&)D"77:TTUU* * * K rX   z3.0.2)openapi_versionra   r   serversterms_of_servicecontactlicense_infor0   versionr   ra   r   r   r   r   r   c        
            | |d}
|r||
d<   |r||
d<   |r||
d<   |	r|	|
d<   ||
d}|r||d<   i }i }t                      }t          |          }t          |          }t          ||          |D ]}t	          |t
          j                  rt          |||	          }|rx|\  }}}|r.|                    |j	        i           
                    |           |r)|                    d
i           
                    |           |r
                    |           rfdt                    D             |d<   |r||d<   ||d<   |r||d<   t          t          di |dd          S )N)r0   r   ra   termsOfServicer   license)openapiinfor   )r   rZ   r   securitySchemesc                 "    i | ]}||         S r   r   )r   kr   s     rV   r   zget_openapi.<locals>.<dictcomp>  s     P P PqKN P P PrX   schemas
componentspathsr   TrH   r   )r   r   r#   r   rq   r   r   r   r   r   r   sortedr   r   )r0   r   r   ra   r   r   r   r   r   r   r   outputr   r   r   r   rZ   ry   resultr~   r   path_definitionsr   s                         @rV   get_openapir    s    &+w??D *)] 2!1 "!Y '&Y)8$GGF $#y,.J')E!eeM-f55K'44N'  K  9 9eW-.. 	9%N-  F  	9;A8&(8 I$$U%6;;BB4HHH# ))*;R@@GG(   $ 9&&'7888 Q P P P PF;<O<O P P P
9 *)|F7O vG--f--4PPPPrX   )Lhttp.clientr   r   r   enumr   typingr   r   r   r   r   r	   r
   r   r   r   fastapir   fastapi.datastructuresr   fastapi.dependencies.modelsr   fastapi.dependencies.utilsr   r   fastapi.encodersr   fastapi.openapi.constantsr   r   fastapi.openapi.modelsr   fastapi.paramsr   r   fastapi.responsesr   fastapi.utilsr   r   r   r   pydanticr   pydantic.fieldsr   r    pydantic.schemar!   r"   r#   pydantic.utilsr$   starlette.responsesr%   starlette.routingr&   starlette.statusr'   r   r   rD   r   __annotations__rW   rm   rx   r   r   r   r   r-   r   r   r  r   rX   rV   <module>r     s~                U U U U U U U U U U U U U U U U U U U U U U U U       5 5 5 5 5 5 1 1 1 1 1 1 J J J J J J J J - - - - - - C C C C C C C C * * * * * * & & & & & & & & & & & & & &                  1 1 1 1 1 1 1 1         
 . - - - - - , , , , , , ' ' ' ' ' ' : : : : : :    2VY4GHI
 

 #H55&99  '&&    #j+<<=
 

( 
( $ !& & DcN   44
4S>4S#X//04 4 4 4"z* tIT
:;S@A 
$sCx.	   >$ tIT
:;S@A d38n	   4UU(+UU U U U0)9 03 03 0 0 0 0(+<?H	#s(^   4f/f/04T3Yf/PSTWPXf/
4S>4S>4S>9:f/ f/ f/ f/RYtIT
*	+,   H #!%+/:>&*489=7Q 7Q 7Q7Q 7Q 	7Q
 #7Q Y7Q 4S#X'
(7Q d4U38_ 45677Q sm7Q d3c3h/017Q 4U38_ 4567Q 
#s(^7Q 7Q 7Q 7Q 7Q 7QrX   