connexion.apis.flask_api

This module defines a Flask Connexion API which implements translations between Flask and Connexion requests / responses.

Module Contents

Classes

FlaskApi

Defines an abstract interface for a Swagger API

Attributes

logger

context

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, debug=False, resolver_error_handler=None, validator_map=None, pythonic_params=False, pass_context_arg_name=None, options=None, **kwargs)

Bases: connexion.apis.abstract.AbstractAPI

Defines an abstract interface for a Swagger API

Parameters:
  • validator_map (dict) – Custom validators for the types “parameter”, “body” and “response”.

  • pythonic_params (bool) – When True CamelCase parameters are converted to snake_case and an underscore is appended to any shadowed built-ins

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:

ConnexionResponse

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:

ConnexionRequest

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.

classmethod get_connexion_response(cls, response, mimetype=None)

Cast framework dependent response to ConnexionResponse used for schema validation

json_loads(self, data)
add_paths(self, paths: Optional[dict] = None) None

Adds the paths defined in the specification as endpoints

connexion.apis.flask_api.context