|
OpenQuizz
Une application de gestion des contenus pédagogiques
|


Public Member Functions | |
| def | __init__ (self, schema_name_resolver=None) |
| def | init_spec (self, spec) |
| def | map_to_openapi_type (self, *args) |
| def | schema_helper (self, name, _, schema=None, **kwargs) |
| def | parameter_helper (self, parameter, **kwargs) |
| def | response_helper (self, response, **kwargs) |
| def | operation_helper (self, operations, **kwargs) |
| def | warn_if_schema_already_in_spec (self, schema_key) |
Public Member Functions inherited from BasePlugin | |
| def | schema_helper (self, name, definition, **kwargs) |
| def | path_helper (self, path=None, operations=None, parameters=None, **kwargs) |
| def | operation_helper (self, path=None, operations=None, **kwargs) |
Data Fields | |
| schema_name_resolver | |
| spec | |
| openapi_version | |
| converter | |
| resolver | |
Static Public Attributes | |
| Converter = OpenAPIConverter | |
| Resolver = SchemaResolver | |
APISpec plugin for translating marshmallow schemas to OpenAPI/JSONSchema format.
:param callable schema_name_resolver: Callable to generate the schema definition name.
Receives the `Schema` class and returns the name to be used in refs within
the generated spec. When working with circular referencing this function
must must not return `None` for schemas in a circular reference chain.
Example: ::
from apispec.ext.marshmallow.common import resolve_schema_cls
def schema_name_resolver(schema):
schema_cls = resolve_schema_cls(schema)
return schema_cls.__name__
| def __init__ | ( | self, | |
schema_name_resolver = None |
|||
| ) |
| def init_spec | ( | self, | |
| spec | |||
| ) |
Initialize plugin with APISpec object :param APISpec spec: APISpec object this plugin instance is attached to
Reimplemented from BasePlugin.
| def map_to_openapi_type | ( | self, | |
| * | args | ||
| ) |
Decorator to set mapping for custom fields.
``*args`` can be:
- a pair of the form ``(type, format)``
- a core marshmallow field type (in which case we reuse that type's mapping)
Examples: ::
@ma_plugin.map_to_openapi_type('string', 'uuid')
class MyCustomField(Integer):
# ...
@ma_plugin.map_to_openapi_type(Integer) # will map to ('integer', None)
class MyCustomFieldThatsKindaLikeAnInteger(Integer):
# ...
| def operation_helper | ( | self, | |
| operations, | |||
| ** | kwargs | ||
| ) |
| def parameter_helper | ( | self, | |
| parameter, | |||
| ** | kwargs | ||
| ) |
Parameter component helper that allows using a marshmallow
:class:`Schema <marshmallow.Schema>` in parameter definition.
:param dict parameter: parameter fields. May contain a marshmallow
Schema class or instance.
Reimplemented from BasePlugin.
| def response_helper | ( | self, | |
| response, | |||
| ** | kwargs | ||
| ) |
Response component helper that allows using a marshmallow
:class:`Schema <marshmallow.Schema>` in response definition.
:param dict parameter: response fields. May contain a marshmallow
Schema class or instance.
Reimplemented from BasePlugin.
| def schema_helper | ( | self, | |
| name, | |||
| _, | |||
schema = None, |
|||
| ** | kwargs | ||
| ) |
Definition helper that allows using a marshmallow :class:`Schema <marshmallow.Schema>` to provide OpenAPI metadata. :param type|Schema schema: A marshmallow Schema class or instance.
| def warn_if_schema_already_in_spec | ( | self, | |
| schema_key | |||
| ) |
Method to warn the user if the schema has already been added to the spec.
|
static |
| converter |
| openapi_version |
|
static |
| resolver |
| schema_name_resolver |
| spec |