connexion.apps.aiohttp_app

Module Contents

Classes

AioHttpApp

Attributes

logger

connexion.apps.aiohttp_app.logger
class connexion.apps.aiohttp_app.AioHttpApp(import_name, only_one_api=False, **kwargs)

Bases: connexion.apps.abstract.AbstractApp

create_app(self)

Creates the user framework application

get_root_path(self)

Gets the root path of the user framework application

set_errors_handlers(self)

Sets all errors handlers of the user framework application

add_api(self, specification, **kwargs)

Adds an API to the application based on a swagger file or API dict

Parameters
  • specification (pathlib.Path or str or dict) – swagger file with the specification | specification dict

  • base_path (str | None) – base path where to add this api

  • arguments (dict | None) – api version specific arguments to replace on the specification

  • auth_all_paths (bool) – whether to authenticate not defined paths

  • validate_responses (bool) – True enables validation. Validation errors generate HTTP 500 responses.

  • strict_validation (bool) – True enables validation on invalid request parameters

  • resolver (Resolver | types.FunctionType) – Operation resolver.

  • resolver_error (int | None) – If specified, turns ResolverError into error responses with the given status code.

  • pythonic_params (bool) – When True CamelCase parameters are converted to snake_case

  • options (dict | None) – New style options dictionary.

  • pass_context_arg_name (str | None) – Name of argument in handler functions to pass request context to.

  • validator_map (dict) – map of validators

Return type

AbstractAPI

run(self, port=None, server=None, debug=None, host=None, **options)

Runs the application on a local development server. :param host: the host interface to bind on. :type host: str :param port: port to listen to :type port: int :param server: which wsgi server to use :type server: str | None :param debug: include debugging information :type debug: bool :param options: options to be forwarded to the underlying server

add_url_rule(self, rule, endpoint=None, view_func=None, **options)

Connects a URL rule. Works exactly like the route decorator. If a view_func is provided it will be registered with the endpoint.

Basically this example:

@app.route('/')
def index():
    pass

Is equivalent to the following:

def index():
    pass
app.add_url_rule('/', 'index', index)

If the view_func is not provided you will need to connect the endpoint to a view function like so:

app.view_functions['index'] = index

Internally`route` invokes add_url_rule so if you want to customize the behavior via subclassing you only need to change this method.

Parameters
  • rule (str) – the URL rule as string

  • endpoint (str) – the endpoint for the registered URL rule. Flask itself assumes the name of the view function as endpoint

  • view_func (types.FunctionType) – the function to call when serving a request to the provided endpoint

  • options – the options to be forwarded to the underlying werkzeug.routing.Rule object. A change to Werkzeug is handling of method options. methods is a list of methods this rule should be limited to (GET, POST etc.). By default a rule just listens for GET (and implicitly HEAD).

route(self, rule, **options)

A decorator that is used to register a view function for a given URL rule. This does the same thing as add_url_rule but is intended for decorator usage:

@app.route('/')
def index():
    return 'Hello World'
Parameters
  • rule (str) – the URL rule as string

  • endpoint – the endpoint for the registered URL rule. Flask itself assumes the name of the view function as endpoint

  • options – the options to be forwarded to the underlying werkzeug.routing.Rule object. A change to Werkzeug is handling of method options. methods is a list of methods this rule should be limited to (GET, POST etc.). By default a rule just listens for GET (and implicitly HEAD).

__call__(self, environ, start_response)

Makes the class callable to be WSGI-compliant. As Flask is used to handle requests, this is a passthrough-call to the Flask callable class. This is an abstraction to avoid directly referencing the app attribute from outside the class and protect it from unwanted modification.