
    h                     x    d Z ddlmZ ddlmZ ddlmZ ddlmZ ddl	m
Z
 ddlmZ dd	lmZmZ  G d
 dee
      Zy)zApi extension initialization    )abort   )APISpecMixin)	Blueprint)Page)ErrorHandlerMixin)current_api)PrefixedMappingProxynormalize_config_prefixc                   8    e Zd ZdZd
ddddZdddZddd	Zy)Apia  Main class

    Provides helpers to build a REST API using Flask.

    :param Flask app: Flask application
    :param spec_kwargs: kwargs to pass to internal APISpec instance
    :param str config_prefix: Prefix to Api parameters in application config

    The ``spec_kwargs`` dictionary is passed as kwargs to the internal APISpec
    instance. **flask-smorest** adds a few parameters to the original
    parameters documented in :class:`apispec.APISpec <apispec.APISpec>`:

    :param apispec.BasePlugin flask_plugin: Flask plugin
    :param apispec.BasePlugin marshmallow_plugin: Marshmallow plugin
    :param list|tuple extra_plugins: List of additional ``BasePlugin``
        instances
    :param str title: API title. Can also be passed as
        application parameter `API_TITLE`.
    :param str version: API version. Can also be passed as
        application parameter `API_VERSION`.
    :param str openapi_version: OpenAPI version. Can also be passed as
        application parameter `OPENAPI_VERSION`.

    This allows the user to override default Flask and marshmallow plugins.

    For more flexibility, additional spec kwargs can also be passed as app
    parameter `API_SPEC_OPTIONS`.
    N )spec_kwargsconfig_prefixc                    || _         |xs i | _        t        |      | _        d | _        d | _        g | _        g | _        || j                  |       y y N)	_app_spec_kwargsr   r   configspec_fields_convertersinit_app)selfappr   r   s       P/var/www/html/engine/venv/lib/python3.12/site-packages/flask_smorest/__init__.py__init__zApi.__init__+   sV    	'-24]C	?MM#     )r   c                n   || _         t        |j                  | j                        | _        t	        |di       |_        |j
                  j                  di i d      }d| i|d   | j                  <    | j                  di i | j                  |xs i  | j                          | j                          y)zInitialize Api with application

        :param spec_kwargs: kwargs to pass to internal APISpec instance.
            Updates ``spec_kwargs`` passed in ``Api`` init.
        
extensionsflask-smorest)apisblp_name_to_apiext_objr"   N )r   r
   r   r   getattrr    
setdefault
_init_specr   _register_doc_blueprint_register_error_handlers)r   r   r   exts       r   r   zApi.init_app7   s     	*3::t7I7IJ !lB7nn'' #%	
 ,5d*;FD&&' 	GFT..F;3D"FG 	$$& 	%%'r   )
parametersc                X   |j                  d|j                        }| | j                  j                  d   d   |<    | j                  j                  |fi | |j                  | | j                  | j                  ||       | j                  j                  ||j                  d       y)a  Register a blueprint in the application

        Also registers documentation for the blueprint/resource

        :param Blueprint blp: Blueprint to register
        :param list parameters: List of parameter descriptions for the path parameters
            in the ``url_prefix`` of the Blueprint. Only used to document the resource.
        :param options: Keyword arguments overriding
            :class:`Blueprint <flask.Blueprint>` defaults

        Must be called after app is initialized.
        namer!   r#   )r.   r,   )r.   descriptionN)	getr.   r   r    register_blueprintregister_views_in_docr   tagr/   )r   blpr,   optionsblp_names        r   r1   zApi.register_blueprintV   s     ;;vsxx0MQ		_-.?@J$		$$S4G4 	!!IIII! 	" 	
 			xHIr   r   )__name__
__module____qualname____doc__r   r   r1   r%   r   r   r   r      s*    :
B 
 ,0 (> 59 Jr   r   N)r:   webargs.flaskparserr   r   r   	blueprintr   
paginationr   error_handlerr   globalsr	   utilsr
   r   r   r%   r   r   <module>rA      s0    " %     ,   @fJ,) fJr   