
    g=                       S SK Jr  S SKrS SKrS SKrS SKJr  S SKJr  S SK	J
r
JrJrJr   S SKr " S S\5      r " S S	\R"                  5      r\R&                  " S
5      r " S S5      r " S S\5      rg! \ a    Sr NRf = f)    )annotationsN)Request)Response)	BaseRouteHostMountRoutec                  "    \ rS rSrSrSS jrSrg)OpenAPIResponse   zapplication/vnd.oai.openapic                    [         c   S5       e[        U[        5      (       d   S5       e[         R                  " USS9R	                  S5      $ )Nz2`pyyaml` must be installed to use OpenAPIResponse.z<The schema passed to OpenAPIResponse should be a dictionary.F)default_flow_stylezutf-8)yaml
isinstancedictdumpencode)selfcontents     J/home/matz/Project1/venv/lib/python3.13/site-packages/starlette/schemas.pyrenderOpenAPIResponse.render   sI    U!UU'4((h*hh(yyU;BB7KK     N)r   z
typing.Anyreturnbytes)__name__
__module____qualname____firstlineno__
media_typer   __static_attributes__r   r   r   r   r      s    .JLr   r   c                  4    \ rS rSr% S\S'   S\S'   S\S'   Srg)	EndpointInfo   strpathhttp_method typing.Callable[..., typing.Any]funcr   N)r   r   r   r    __annotations__r"   r   r   r   r$   r$      s    
I
**r   r$   z:\w+}c                  F    \ rS rSrS	S jrS
S jrSS jrSS jrSS jrSr	g)BaseSchemaGenerator#   c                    [        5       eN)NotImplementedError)r   routess     r   
get_schemaBaseSchemaGenerator.get_schema$   s    !##r   c           
        / nU GH:  n[        U[        [        45      (       a  UR                  =(       d    / n[        U[        5      (       a  U R	                  UR
                  5      nOSnU R                  U5       Vs/ s H<  n[        SR                  XER
                  45      UR                  UR                  S9PM>     nnUR                  U5        M  [        U[        5      (       a  UR                  (       d  M  [        R                  " UR                   5      (       d%  [        R"                  " UR                   5      (       av  U R	                  UR
                  5      nUR$                  =(       d    S/ H>  nUS:X  a  M  UR'                  [        XGR)                  5       UR                   5      5        M@     GM  U R	                  UR
                  5      nS H_  n[+        UR                   U5      (       d  M   [-        UR                   U5      nUR'                  [        XGR)                  5       U5      5        Ma     GM=     U$ s  snf )z
Given the routes, yields the following information:

- path
    eg: /users/
- http_method
    one of 'get', 'post', 'put', 'patch', 'delete', 'options'
- func
    method ready to extract the docstring
 )r'   r(   r*   GETHEAD)getpostputpatchdeleteoptions)r   r   r   r2   _remove_converterr'   get_endpointsr$   joinr(   r*   extendr	   include_in_schemainspect
isfunctionendpointismethodmethodsappendlowerhasattrgetattr)	r   r2   endpoints_inforouter'   sub_endpointsub_endpointsmethodr*   s	            r   r@   !BaseSchemaGenerator.get_endpoints'   s    .0E%%//+eU++11%**=DD )-(:(:6(B! )C !WWd,=,=%>?$0$<$<)..
 )C  ! %%m4u--U5L5L##ENN33w7G7G7W7W--ejj9#mm6w6F' ")),t\\^U^^*\] 7
 --ejj9RF"5>>6:: "5>>6:D")),t\\^T*RS	 S9 D 7!s   ?AIc                .    [         R                  SU5      $ )z
Remove the converter from the path.
For example, a route like this:
    Route("/users/{id:int}", endpoint=get_user, methods=["GET"])
Should be represented as `/users/{id}` in the OpenAPI schema.
})_remove_converter_patternsub)r   r'   s     r   r?   %BaseSchemaGenerator._remove_converterX   s     ),,S$77r   c                    UR                   nU(       d  0 $ [        c   S5       eUR                  S5      S   n[        R                  " U5      n[	        U[
        5      (       d  0 $ U$ )zP
Given a function, parse the docstring as YAML and return a dictionary of info.
z2`pyyaml` must be installed to use parse_docstring.z---)__doc__r   split	safe_loadr   r   )r   func_or_method	docstringparseds       r   parse_docstring#BaseSchemaGenerator.parse_docstringa   se     #**	IU!UU
 OOE*2.		*&$'' Ir   c                b    UR                   R                  nU R                  US9n[        U5      $ )N)r2   )appr2   r3   r   )r   requestr2   schemas       r   r   #BaseSchemaGenerator.OpenAPIResponsey   s,    ##/v&&r   r   Nr2   list[BaseRoute]r   dict[str, typing.Any])r2   rh   r   zlist[EndpointInfo])r'   r&   r   r&   )r]   r)   r   ri   )rd   r   r   r   )
r   r   r   r    r3   r@   r?   r`   r   r"   r   r   r   r-   r-   #   s    $/b80'r   r-   c                  (    \ rS rSrSS jrSS jrSrg)SchemaGenerator   c                    Xl         g r0   base_schema)r   ro   s     r   __init__SchemaGenerator.__init__   s    &r   c                V   [        U R                  5      nUR                  S0 5        U R                  U5      nU Hj  nU R	                  UR
                  5      nU(       d  M'  UR                  US   ;  a  0 US   UR                  '   XRS   UR                     UR                  '   Ml     U$ )Npaths)r   ro   
setdefaultr@   r`   r*   r'   r(   )r   r2   re   rM   rF   r_   s         r   r3   SchemaGenerator.get_schema   s    d&&''2&++F3&H))(--8F}}F7O313w.CI7OHMM*8+?+?@ ' r   rn   N)ro   ri   r   Nonerg   )r   r   r   r    rp   r3   r"   r   r   r   rk   rk      s    'r   rk   )
__future__r   rD   retypingstarlette.requestsr   starlette.responsesr   starlette.routingr   r   r   r	   r   ModuleNotFoundErrorr   
NamedTupler$   compilerU   r-   rk   r   r   r   <module>r      s    "  	  & ( ; ;
Lh L+6$$ + JJx0 Y' Y'x) e  Ds   A8 8BB