OpenQuizz
Une application de gestion des contenus pédagogiques
apispec.utils Namespace Reference

Data Structures

class  OpenAPIVersion
 

Functions

def build_reference (component_type, openapi_major_version, component_name)
 
def validate_spec (spec)
 
def trim_docstring (docstring)
 
def dedent (content)
 
def deepupdate (original, update)
 

Variables

dictionary COMPONENT_SUBSECTIONS
 

Detailed Description

Various utilities for parsing OpenAPI operations from docstrings and validating against
the OpenAPI spec.

Function Documentation

◆ build_reference()

def apispec.utils.build_reference (   component_type,
  openapi_major_version,
  component_name 
)
Return path to reference

:param str component_type: Component type (schema, parameter, response, security_scheme)
:param int openapi_major_version: OpenAPI major version (2 or 3)
:param str component_name: Name of component to reference

◆ dedent()

def apispec.utils.dedent (   content)
Remove leading indent from a block of text.
Used when generating descriptions from docstrings.
Note that python's `textwrap.dedent` doesn't quite cut it,
as it fails to dedent multiline docstrings that include
unindented text on the initial line.

◆ deepupdate()

def apispec.utils.deepupdate (   original,
  update 
)
Recursively update a dict.

Subdict's won't be overwritten but also updated.

◆ trim_docstring()

def apispec.utils.trim_docstring (   docstring)
Uniformly trims leading/trailing whitespace from docstrings.

Based on http://www.python.org/peps/pep-0257.html#handling-docstring-indentation

◆ validate_spec()

def apispec.utils.validate_spec (   spec)
Validate the output of an :class:`APISpec` object against the
OpenAPI specification.

Note: Requires installing apispec with the ``[validation]`` extras.
::

    pip install 'apispec[validation]'

:raise: apispec.exceptions.OpenAPIError if validation fails.

Variable Documentation

◆ COMPONENT_SUBSECTIONS

dictionary COMPONENT_SUBSECTIONS
Initial value:
1 = {
2  2: {
3  "schema": "definitions",
4  "response": "responses",
5  "parameter": "parameters",
6  "security_scheme": "securityDefinitions",
7  },
8  3: {
9  "schema": "schemas",
10  "response": "responses",
11  "parameter": "parameters",
12  "header": "headers",
13  "example": "examples",
14  "security_scheme": "securitySchemes",
15  },
16 }