connexion.apis.flask_api
¶
This module defines a Flask Connexion API which implements translations between Flask and Connexion requests / responses.
Module Contents¶
Classes¶
Defines an abstract interface for a Swagger API |
|
Flask handlers for internally registered endpoints. |
Attributes¶
- connexion.apis.flask_api.logger¶
- class connexion.apis.flask_api.FlaskApi(specification, base_path=None, arguments=None, validate_responses=False, strict_validation=False, resolver=None, auth_all_paths=False, debug=False, resolver_error_handler=None, validator_map=None, pythonic_params=False, pass_context_arg_name=None, options=None)¶
Bases:
connexion.apis.abstract.AbstractAPI
Defines an abstract interface for a Swagger API
- static make_security_handler_factory(pass_context_arg_name)¶
Create default SecurityHandlerFactory to create all security check handlers
- add_openapi_json(self)¶
Adds spec json to {base_path}/swagger.json or {base_path}/openapi.json (for oas3)
- add_openapi_yaml(self)¶
Adds spec yaml to {base_path}/swagger.yaml or {base_path}/openapi.yaml (for oas3)
- add_swagger_ui(self)¶
Adds swagger ui to {base_path}/ui/
- add_auth_on_not_found(self, security, security_definitions)¶
Adds a 404 error handler to authenticate and only expose the 404 status if the security validation pass.
- classmethod get_response(cls, response, mimetype=None, request=None)¶
Gets ConnexionResponse instance for the operation handler result. Status Code and Headers for response. If only body data is returned by the endpoint function, then the status code will be set to 200 and no headers will be added.
If the returned object is a flask.Response then it will just pass the information needed to recreate it.
- Return type
- classmethod get_request(cls: Any, *args: Any, **params) connexion.lifecycle.ConnexionRequest ¶
Gets ConnexionRequest instance for the operation handler result. Status Code and Headers for response. If only body data is returned by the endpoint function, then the status code will be set to 200 and no headers will be added.
If the returned object is a flask.Response then it will just pass the information needed to recreate it.
- Return type
- add_operation(self, path, method)¶
Adds one operation to the api.
This method uses the OperationID identify the module and function that will handle the operation
From Swagger Specification:
OperationID
A friendly name for the operation. The id MUST be unique among all operations described in the API. Tools and libraries MAY use the operation id to uniquely identify an operation.
- add_paths(self, paths=None)¶
Adds the paths defined in the specification as endpoints
- classmethod get_connexion_response(cls, response, mimetype=None)¶
Cast framework dependent response to ConnexionResponse used for schema validation
- json_loads(self, data)¶
- connexion.apis.flask_api.context¶
- class connexion.apis.flask_api.InternalHandlers(base_path, options, specification)¶
Flask handlers for internally registered endpoints.
- console_ui_home(self)¶
Home page of the OpenAPI Console UI.
- Returns
- console_ui_static_files(self, filename)¶
Servers the static files for the OpenAPI Console UI.
- Parameters
filename – Requested file contents.
- Returns
- get_json_spec(self)¶
- get_yaml_spec(self)¶