connexion.resolver

This module contains resolvers, functions that resolves the user defined view functions from the operations defined in the OpenAPI spec.

Module Contents

Classes

Resolution

Represents the result of operation resolution

Resolver

Standard resolver

RelativeResolver

Resolves endpoint functions relative to a given root path or module.

RestyResolver

Resolves endpoint functions using REST semantics (unless overridden by specifying operationId)

MethodResolverBase

Resolves endpoint functions based on Flask's MethodView semantics, e.g.

MethodResolver

A generic method resolver that instantiates a class a extracts the method

MethodViewResolver

A specialized method resolver that works with flask's method views.

Attributes

logger

connexion.resolver.logger
class connexion.resolver.Resolution(function, operation_id)

Represents the result of operation resolution

Parameters:

function (types.FunctionType) – The endpoint function

class connexion.resolver.Resolver(function_resolver=utils.get_function_from_name)

Standard resolver

Parameters:

function_resolver (types.FunctionType) – Function that resolves functions using an operationId

resolve(self, operation)

Default operation resolver

resolve_operation_id(self, operation)

Default operationId resolver

resolve_function_from_operation_id(self, operation_id)

Invokes the function_resolver

class connexion.resolver.RelativeResolver(root_path, function_resolver=utils.get_function_from_name)

Bases: Resolver

Resolves endpoint functions relative to a given root path or module.

Parameters:
  • root_path (Union[str, types.ModuleType]) – The root path relative to which an operationId is resolved. Can also be a module. Has the same effect as setting x-swagger-router-controller or x-openapi-router-controller equal to root_path for every operation individually.

  • function_resolver (types.FunctionType) – Function that resolves functions using an operationId

resolve_operation_id(self, operation)

Resolves the operationId relative to the root path, unless x-swagger-router-controller or x-openapi-router-controller is specified.

Parameters:

operation (connexion.operations.AbstractOperation) – The operation to resolve

resolve(self, operation)

Default operation resolver

resolve_function_from_operation_id(self, operation_id)

Invokes the function_resolver

class connexion.resolver.RestyResolver(default_module_name, collection_endpoint_name='search')

Bases: Resolver

Resolves endpoint functions using REST semantics (unless overridden by specifying operationId)

Parameters:

default_module_name (str) – Default module name for operations

resolve_operation_id(self, operation)

Resolves the operationId using REST semantics unless explicitly configured in the spec

resolve_operation_id_using_rest_semantics(self, operation)

Resolves the operationId using REST semantics

resolve(self, operation)

Default operation resolver

resolve_function_from_operation_id(self, operation_id)

Invokes the function_resolver

class connexion.resolver.MethodResolverBase(*args, class_arguments: _class_arguments_type = None, **kwargs)

Bases: RestyResolver

Resolves endpoint functions based on Flask’s MethodView semantics, e.g.

paths:
    /foo_bar:
        get:
            # Implied function call: api.FooBarView().get

class FooBarView(MethodView):
    def get(self):
        return ...
    def post(self):
        return ...
Parameters:

class_arguments

Arguments to instantiate the View Class in the format # noqa {

”ViewName”: {

“args”: (positional arguments,) “kwargs”: {

”keyword”: “argument”

}

}

}

resolve_operation_id(self, operation)

Resolves the operationId using REST semantics unless explicitly configured in the spec Once resolved with REST semantics the view_name is capitalised and has ‘View’ added to it so it now matches the Class names of the MethodView

resolve_function_from_operation_id(self, operation_id)

Invokes the function_resolver

abstract resolve_method_from_class(self, view_name, meth_name, view_cls)

Returns the view function for the given view class.

resolve_operation_id_using_rest_semantics(self, operation)

Resolves the operationId using REST semantics

resolve(self, operation)

Default operation resolver

class connexion.resolver.MethodResolver(*args, class_arguments: _class_arguments_type = None, **kwargs)

Bases: MethodResolverBase

A generic method resolver that instantiates a class a extracts the method from it, based on the operation id.

Parameters:

class_arguments

Arguments to instantiate the View Class in the format # noqa {

”ViewName”: {

“args”: (positional arguments,) “kwargs”: {

”keyword”: “argument”

}

}

}

resolve_method_from_class(self, view_name, meth_name, view_cls)

Returns the view function for the given view class.

resolve_operation_id(self, operation)

Resolves the operationId using REST semantics unless explicitly configured in the spec Once resolved with REST semantics the view_name is capitalised and has ‘View’ added to it so it now matches the Class names of the MethodView

resolve_function_from_operation_id(self, operation_id)

Invokes the function_resolver

resolve_operation_id_using_rest_semantics(self, operation)

Resolves the operationId using REST semantics

resolve(self, operation)

Default operation resolver

class connexion.resolver.MethodViewResolver(*args, class_arguments: _class_arguments_type = None, **kwargs)

Bases: MethodResolverBase

A specialized method resolver that works with flask’s method views. It resolves the method by calling as_view on the class.

Parameters:

class_arguments

Arguments to instantiate the View Class in the format # noqa {

”ViewName”: {

“args”: (positional arguments,) “kwargs”: {

”keyword”: “argument”

}

}

}

resolve_method_from_class(self, view_name, meth_name, view_cls)

Returns the view function for the given view class.

resolve_operation_id(self, operation)

Resolves the operationId using REST semantics unless explicitly configured in the spec Once resolved with REST semantics the view_name is capitalised and has ‘View’ added to it so it now matches the Class names of the MethodView

resolve_function_from_operation_id(self, operation_id)

Invokes the function_resolver

resolve_operation_id_using_rest_semantics(self, operation)

Resolves the operationId using REST semantics

resolve(self, operation)

Default operation resolver