
    @|hw                    n    d Z ddlmZ ddlZdddddd	ddd
ddddZ	 	 	 	 	 	 	 	 ddZddZddZddZy)zjVarious utilities for parsing OpenAPI operations from docstrings and validating against
the OpenAPI spec.
    )annotationsNdefinitions	responses
parameterssecurityDefinitions)schemaresponse	parametersecurity_schemeschemasheadersexamplessecuritySchemes)r   r	   r
   headerexampler   )      c                N    ddj                  |dk\  rdndt        |   |    |      iS )zReturn path to reference

    :param str component_type: Component type (schema, parameter, response, security_scheme)
    :param int openapi_major_version: OpenAPI major version (2 or 3)
    :param str component_name: Name of component to reference
    z$refz	#/{}{}/{}r   zcomponents/ )formatCOMPONENT_SUBSECTIONS)component_typeopenapi_major_versioncomponent_names      L/var/www/html/test/engine/venv/lib/python3.12/site-packages/apispec/utils.pybuild_referencer      s;     	""2a7MR!"78H
     c                B   | r| j                         sy| j                         j                         }t        d |D              }|d   j	                         g|dd D cg c]  }||d j                          c}z   }dj                  |      j                         S c c}w )zUniformly trims leading/trailing whitespace from docstrings.

    Based on http://www.python.org/peps/pep-0257.html#handling-docstring-indentation
    r   c              3     K   | ]:  }|j                         st        |      t        |j                               z
   < y w)N)lstriplen).0lines     r   	<genexpr>z!trim_docstring.<locals>.<genexpr>7   s,     SDT[[]TS//Ss
   A*Ar      N
)strip
expandtabs
splitlinesminr    rstripjoin)	docstringlinesindentr#   trimmeds        r   trim_docstringr1   .   s    
 IOO-  "--/ESESSFQx !ab	$RT&']%9%9%;$RRG99W##%% %Ss   Bc           	     l   | j                         dd D cg c]8  }|j                         r&t        |      t        |j                  d            z
  : }}|rJddt        |      z  z   }t	        j
                  t	        j                  |t        j                        d|       } | j                         S c c}w )a  
    Remove leading indent from a block of text.
    Used when generating descriptions from docstrings.
    Note that python's `textwrap.dedent` doesn't quite cut it,
    as it fails to dedent multiline docstrings that include
    unindented text on the initial line.
    r%   N ^r   )	r)   r    r!   r*   resubcompile	MULTILINEr'   )contentr#   whitespace_countswhitespace_patterns       r   dedentr<   =   s     &&(,;;= 	D	CC())   C#.?*@$@A&&$6Er7S==?s   =B1c                    | j                         D ]/  \  }}||vr|||<   t        |t              s!t        |||          1 |S )zURecursively update a dict.

    Subdict's won't be overwritten but also updated.
    )items
isinstancedict
deepupdate)originalupdatekeyvalues       r   rA   rA   T   sN    
 nn& +
UfF3Kt$ufSk*	+
 Mr   )r   strr   intr   rF   returnzdict[str, str])r-   rF   rH   rF   )r9   rF   rH   rF   )rB   r@   rC   r@   rH   r@   )	__doc__
__future__r   r5   r   r   r1   r<   rA    r   r   <module>rL      sz    # 	  !0	 !, $03EH&&.
r   