OpenQuizz
Une application de gestion des contenus pédagogiques
Namespace Class Reference
Inheritance diagram for Namespace:
Collaboration diagram for Namespace:

Public Member Functions

def __init__ (self, name, description=None, path=None, decorators=None, validate=None, authorizations=None, ordered=False, **kwargs)
 
def path (self)
 
def add_resource (self, resource, *urls, **kwargs)
 
def route (self, *urls, **kwargs)
 
def doc (self, shortcut=None, **kwargs)
 
def hide (self, func)
 
def abort (self, *args, **kwargs)
 
def add_model (self, name, definition)
 
def model (self, name=None, model=None, mask=None, **kwargs)
 
def schema_model (self, name=None, schema=None)
 
def extend (self, name, parent, fields)
 
def clone (self, name, *specs)
 
def inherit (self, name, *specs)
 
def expect (self, *inputs, **kwargs)
 
def parser (self)
 
def as_list (self, field)
 
def marshal_with (self, fields, as_list=False, code=HTTPStatus.OK, description=None, **kwargs)
 
def marshal_list_with (self, fields, **kwargs)
 
def marshal (self, *args, **kwargs)
 
def errorhandler (self, exception)
 
def param (self, name, description=None, _in='query', **kwargs)
 
def response (self, code, description, model=None, **kwargs)
 
def header (self, name, description=None, **kwargs)
 
def produces (self, mimetypes)
 
def deprecated (self, func)
 
def vendor (self, *args, **kwargs)
 
def payload (self)
 

Data Fields

 name
 
 description
 
 models
 
 urls
 
 decorators
 
 resources
 
 error_handlers
 
 default_error_handler
 
 authorizations
 
 ordered
 
 apis
 

Detailed Description

Group resources together.

Namespace is to API what :class:`flask:flask.Blueprint` is for :class:`flask:flask.Flask`.

:param str name: The namespace name
:param str description: An optionale short description
:param str path: An optional prefix path. If not provided, prefix is ``/+name``
:param list decorators: A list of decorators to apply to each resources
:param bool validate: Whether or not to perform validation on this namespace
:param bool ordered: Whether or not to preserve order on models and marshalling
:param Api api: an optional API to attache to the namespace

Constructor & Destructor Documentation

◆ __init__()

def __init__ (   self,
  name,
  description = None,
  path = None,
  decorators = None,
  validate = None,
  authorizations = None,
  ordered = False,
**  kwargs 
)

Member Function Documentation

◆ abort()

def abort (   self,
args,
**  kwargs 
)
Properly abort the current request

See: :func:`~flask_restplus.errors.abort`

◆ add_model()

def add_model (   self,
  name,
  definition 
)

◆ add_resource()

def add_resource (   self,
  resource,
urls,
**  kwargs 
)
Register a Resource for a given API Namespace

:param Resource resource: the resource ro register
:param str urls: one or more url routes to match for the resource,
         standard flask routing rules apply.
         Any url variables will be passed to the resource method as args.
:param str endpoint: endpoint name (defaults to :meth:`Resource.__name__.lower`
    Can be used to reference this route in :class:`fields.Url` fields
:param list|tuple resource_class_args: args to be forwarded to the constructor of the resource.
:param dict resource_class_kwargs: kwargs to be forwarded to the constructor of the resource.

Additional keyword arguments not specified above will be passed as-is
to :meth:`flask.Flask.add_url_rule`.

Examples::

    namespace.add_resource(HelloWorld, '/', '/hello')
    namespace.add_resource(Foo, '/foo', endpoint="foo")
    namespace.add_resource(FooSpecial, '/special/foo', endpoint="foo")

◆ as_list()

def as_list (   self,
  field 
)
Allow to specify nested lists for documentation

◆ clone()

def clone (   self,
  name,
specs 
)
Clone a model (Duplicate all fields)

:param str name: the resulting model name
:param specs: a list of models from which to clone the fields

.. seealso:: :meth:`Model.clone`

◆ deprecated()

def deprecated (   self,
  func 
)
A decorator to mark a resource or a method as deprecated

◆ doc()

def doc (   self,
  shortcut = None,
**  kwargs 
)
A decorator to add some api documentation to the decorated object

◆ errorhandler()

def errorhandler (   self,
  exception 
)
A decorator to register an error handler for a given exception

◆ expect()

def expect (   self,
inputs,
**  kwargs 
)
A decorator to Specify the expected input model

:param ModelBase|Parse inputs: An expect model or request parser
:param bool validate: whether to perform validation or not

◆ extend()

def extend (   self,
  name,
  parent,
  fields 
)
Extend a model (Duplicate all fields)

:deprecated: since 0.9. Use :meth:`clone` instead

◆ header()

def header (   self,
  name,
  description = None,
**  kwargs 
)
A decorator to specify one of the expected headers

:param str name: the HTTP header name
:param str description: a description about the header

◆ hide()

def hide (   self,
  func 
)
A decorator to hide a resource or a method from specifications

◆ inherit()

def inherit (   self,
  name,
specs 
)
Inherit a modal (use the Swagger composition pattern aka. allOf)

.. seealso:: :meth:`Model.inherit`

◆ marshal()

def marshal (   self,
args,
**  kwargs 
)
A shortcut to the :func:`marshal` helper

◆ marshal_list_with()

def marshal_list_with (   self,
  fields,
**  kwargs 
)
A shortcut decorator for :meth:`~Api.marshal_with` with ``as_list=True``

◆ marshal_with()

def marshal_with (   self,
  fields,
  as_list = False,
  code = HTTPStatus.OK,
  description = None,
**  kwargs 
)
A decorator specifying the fields to use for serialization.

:param bool as_list: Indicate that the return type is a list (for the documentation)
:param int code: Optionally give the expected HTTP response code if its different from 200

◆ model()

def model (   self,
  name = None,
  model = None,
  mask = None,
**  kwargs 
)
Register a model

.. seealso:: :class:`Model`

◆ param()

def param (   self,
  name,
  description = None,
  _in = 'query',
**  kwargs 
)
A decorator to specify one of the expected parameters

:param str name: the parameter name
:param str description: a small description
:param str _in: the parameter location `(query|header|formData|body|cookie)`

◆ parser()

def parser (   self)
Instanciate a :class:`~RequestParser`

◆ path()

def path (   self)

◆ payload()

def payload (   self)
Store the input payload in the current request context

◆ produces()

def produces (   self,
  mimetypes 
)
A decorator to specify the MIME types the API can produce

◆ response()

def response (   self,
  code,
  description,
  model = None,
**  kwargs 
)
A decorator to specify one of the expected responses

:param int code: the HTTP status code
:param str description: a small description about the response
:param ModelBase model: an optional response model

◆ route()

def route (   self,
urls,
**  kwargs 
)
A decorator to route resources.

◆ schema_model()

def schema_model (   self,
  name = None,
  schema = None 
)
Register a model

.. seealso:: :class:`Model`

◆ vendor()

def vendor (   self,
args,
**  kwargs 
)
A decorator to expose vendor extensions.

Extensions can be submitted as dict or kwargs.
The ``x-`` prefix is optionnal and will be added if missing.

See: http://swagger.io/specification/#specification-extensions-128

Field Documentation

◆ apis

apis

◆ authorizations

authorizations

◆ decorators

decorators

◆ default_error_handler

default_error_handler

◆ description

description

◆ error_handlers

error_handlers

◆ models

models

◆ name

name

◆ ordered

ordered

◆ resources

resources

◆ urls

urls

The documentation for this class was generated from the following file: