nadia.common module

Functionalities related to all builders.

class nadia.common.Builder(builder_provider)

Bases: abc.ABC

Base class for all field builders.

Parameters:builder_provider – a provider used for obtaining builders for other OpenAPI types.
build_schema(spec, **kwargs)

Build marshmallow schema from definition extracted from OpenAPI specs.

Parameters:spec – an object definition extracted from OpenAPI specification.
Returns:Schema or a Field constructed from the spec dictionary.
Return type:marshmallow.Schema or :py:class:marshmallow.Field


The return type as well as the nature of the object constructed depends on the concrete implementation of Builder. Usually the builder designed for handling object types will return Schema object, while builders designed for handling other data types will return Field instances.

key = None
marshmallow_class = None
static translate_args(spec, **kwargs)

Translate arguments given in OpenAPI spec to keyword arguments for marshmallow classes.

Parameters:spec (dict) – a dictionary extracted from OpenAPI spec containing definition of some object.
Returns:A mapping containing keyword arguments used for constructing marshmallow objects.
Return type:dict