OpenQuizz
Une application de gestion des contenus pédagogiques
flask_apispec.annotations Namespace Reference

Functions

def use_kwargs (args, location=None, inherit=None, apply=None, **kwargs)
 
def marshal_with (schema, code='default', description='', inherit=None, apply=None)
 
def doc (inherit=None, **kwargs)
 
def wrap_with (wrapper_cls)
 
def annotate (func, key, options, **kwargs)
 
def activate (func)
 

Function Documentation

◆ activate()

def flask_apispec.annotations.activate (   func)

◆ annotate()

def flask_apispec.annotations.annotate (   func,
  key,
  options,
**  kwargs 
)

◆ doc()

def flask_apispec.annotations.doc (   inherit = None,
**  kwargs 
)
Annotate the decorated view function or class with the specified Swagger
attributes.

Usage:

.. code-block:: python

    @doc(tags=['pet'], description='a pet store')
    def get_pet(pet_id):
        return Pet.query.filter(Pet.id == pet_id).one()

:param inherit: Inherit Swagger documentation from parent classes

◆ marshal_with()

def flask_apispec.annotations.marshal_with (   schema,
  code = 'default',
  description = '',
  inherit = None,
  apply = None 
)
Marshal the return value of the decorated view function using the
specified schema.

Usage:

.. code-block:: python

    class PetSchema(Schema):
        class Meta:
            fields = ('name', 'category')

    @marshal_with(PetSchema)
    def get_pet(pet_id):
        return Pet.query.filter(Pet.id == pet_id).one()

:param schema: :class:`Schema <marshmallow.Schema>` class or instance, or `None`
:param code: Optional HTTP response code
:param description: Optional response description
:param inherit: Inherit schemas from parent classes
:param apply: Marshal response with specified schema

◆ use_kwargs()

def flask_apispec.annotations.use_kwargs (   args,
  location = None,
  inherit = None,
  apply = None,
**  kwargs 
)
Inject keyword arguments from the specified webargs arguments into the
decorated view function.

Usage:

.. code-block:: python

    from marshmallow import fields

    @use_kwargs({'name': fields.Str(), 'category': fields.Str()})
    def get_pets(**kwargs):
        return Pet.query.filter_by(**kwargs).all()

:param args: Mapping of argument names to :class:`Field <marshmallow.fields.Field>`
    objects, :class:`Schema <marshmallow.Schema>`, or a callable which accepts a
    request and returns a :class:`Schema <marshmallow.Schema>`
:param location: Default request location to parse
:param inherit: Inherit args from parent classes
:param apply: Parse request with specified args

◆ wrap_with()

def flask_apispec.annotations.wrap_with (   wrapper_cls)
Use a custom `Wrapper` to apply annotations to the decorated function.

:param wrapper_cls: Custom `Wrapper` subclass