pointsecio.apis.flask_api¶
This module defines a Flask PointSecIO API which implements translations between Flask and PointSecIO requests / responses.
Module Contents¶
Classes¶
Defines an abstract interface for a Swagger API |
Attributes¶
- pointsecio.apis.flask_api.logger¶
- class pointsecio.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:
pointsecio.apis.abstract.AbstractAPIDefines an abstract interface for a Swagger API
- Parameters
validator_map (dict) – Custom validators for the types “parameter”, “body” and “response”.
resolver – Callable that maps operationID to a function
resolver_error_handler (callable | None) – If given, a callable that generates an Operation used for handling ResolveErrors
pythonic_params (bool) – When True CamelCase parameters are converted to snake_case and an underscore is appended to any shadowed built-ins
options (dict | None) – New style options dictionary.
pass_context_arg_name (str | None) – If not None URL request handling functions with an argument matching this name will be passed the framework’s request context.
- static make_security_handler_factory(pass_context_arg_name)¶
Create default SecurityHandlerFactory to create all security check handlers
- 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 PointSecIOResponse 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) pointsecio.lifecycle.PointSecIORequest¶
Gets PointSecIORequest 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_pointsecio_response(cls, response, mimetype=None)¶
Cast framework dependent response to PointSecIOResponse used for schema validation
- json_loads(self, data)¶
- pointsecio.apis.flask_api.context¶