Internal functions documentation

Core wrapper functions:

flask_restful_swagger.swagger.docs(api, **kwargs)[source]

This function adds endpoints for the swagger. It also handles all the model loading by replacing original add_resource with the patched one.

:version changed 1.0.0 The old docs() function before version 1.0.0 had ‘camelCase’ kwargs, which was not-PEP8, and now it is recommended to use ‘snake_case’. But for backward compatibility ‘cameCase’ is also accepted.
Parameters:
  • api – flask-resful’s Api object
  • kwargs – key-word arguments described in _docs function.
Returns:

flask-resful’s Api object passed as api.

flask_restful_swagger.swagger.extract_path_arguments(path)[source]

Extracts a swagger path arguments from the given flask path.

Examples

This /path/<parameter> extracts [{name: ‘parameter’}]

And this /<string(length=2):lang_code>/<string:id>/<float:probability> extracts: [ {name: ‘lang_code’, dataType: ‘string’}, {name: ‘id’, dataType: ‘string’} {name: ‘probability’, dataType: ‘float’}]

flask_restful_swagger.swagger.extract_swagger_path(path)[source]

Extracts a swagger type path from the given flask style path. This /path/<parameter> turns into this /path/{parameter} And this /<string(length=2):lang_code>/<string:id>/<float:probability> to this: /{lang_code}/{id}/{probability}

flask_restful_swagger.swagger.operation(**kwargs)[source]

This decorator marks a function as a swagger operation so that we can easily extract attributes from it. It saves the decorator’s key-values at the function level so we can later extract them later when add_resource is invoked.