o
    FDiw                     @  sf   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dZd$ddZd%ddZd&d!d"ZdS )'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
   )      component_typestropenapi_major_versionintcomponent_namereturndict[str, str]c                 C  s&   dd |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)r   r   r    r   F/var/www/Datamplify/venv/lib/python3.10/site-packages/apispec/utils.pybuild_reference   s   

r   	docstringc                   sd   | r|   sdS |   }tdd |D  |d  g fdd|dd D  }d	|  S )
zUniformly trims leading/trailing whitespace from docstrings.

    Based on http://www.python.org/peps/pep-0257.html#handling-docstring-indentation
    r   c                 s  s,    | ]}|  rt|t|   V  qd S Nlstriplen.0liner   r   r   	<genexpr>7   s   * z!trim_docstring.<locals>.<genexpr>r   c                   s   g | ]
}| d    qS r!   )rstripr%   indentr   r   
<listcomp>8   s    z"trim_docstring.<locals>.<listcomp>   N
)strip
expandtabs
splitlinesminr#   join)r    linestrimmedr   r*   r   trim_docstring.   s   (r6   contentc                 C  sN   dd |   dd D }|r#ddt|  }tt|tjd| } |  S )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.
    c                 S  s*   g | ]}|  rt|t| d  qS ) r"   r%   r   r   r   r,   E   s    zdedent.<locals>.<listcomp>r-   N^r8   r   )r1   r2   resubcompile	MULTILINEr/   )r7   whitespace_countswhitespace_patternr   r   r   dedent=   s   r@   originaldictupdatec                 C  s@   |   D ]\}}||vr|||< qt|trt|||  q|S )zURecursively update a dict.

    Subdict's won't be overwritten but also updated.
    )items
isinstancerB   
deepupdate)rA   rC   keyvaluer   r   r   rF   T   s   

rF   )r   r   r   r   r   r   r   r   )r    r   r   r   )r7   r   r   r   )rA   rB   rC   rB   r   rB   )	__doc__
__future__r   r:   r   r   r6   r@   rF   r   r   r   r   <module>   s(    


