flaskdoc.pallets package¶
Submodules¶
flaskdoc.pallets.app module¶
- class flaskdoc.pallets.app.Flask(import_name, version, static_url_path=None, static_folder='templates', template_folder='templates', instance_path=None, instance_relative_config=False, open_api_version='3.0.2', api_title=None)¶
Bases:
flask.app.Flask
,flaskdoc.pallets.mixin.SwaggerMixin
- init_swagger()¶
- register_blueprint(blueprint, **options)¶
Register a
Blueprint
on the application. Keyword arguments passed to this method will override the defaults set on the blueprint.Calls the blueprint’s
register()
method after recording the blueprint in the application’sblueprints
.- Parameters
blueprint – The blueprint to register.
url_prefix – Blueprint routes will be prefixed with this.
subdomain – Blueprint routes will match on this subdomain.
url_defaults – Blueprint routes will use these default values for view arguments.
options – Additional keyword arguments are passed to
BlueprintSetupState
. They can be accessed inrecord()
callbacks.
Changed in version 2.0.1: The
name
option can be used to change the (pre-dotted) name the blueprint is registered with. This allows the same blueprint to be registered multiple times with unique names forurl_for
.New in version 0.7.
- register_json_path()¶
- register_yaml_path()¶
- route(rule, ref=None, description=None, summary=None, **options)¶
Decorate a view function to register it with the given URL rule and options. Calls
add_url_rule()
, which has more details about the implementation.@app.route("/") def index(): return "Hello, World!"
See url-route-registrations.
The endpoint name for the route defaults to the name of the view function if the
endpoint
parameter isn’t passed.The
methods
parameter defaults to["GET"]
.HEAD
andOPTIONS
are added automatically.- Parameters
rule – The URL rule string.
options – Extra options passed to the
Rule
object.
- flaskdoc.pallets.app.docs()¶
- flaskdoc.pallets.app.get_api_docs(app)¶
Traverses all flask mappings and retrieves all specified paths and parsing the specs
- Parameters
app (flask.Flask) – flask app instance
- Returns
#fixme doesn’t seem like a useful return value
- Return type
int
- flaskdoc.pallets.app.get_api_rule(fn, app)¶
- flaskdoc.pallets.app.json_path()¶
- flaskdoc.pallets.app.parse_specs(rule, spec, api)¶
Parses spec for a given flask route
- Parameters
rule (werkzeug.routing.Rule) – route rule
spec (list) – swagger model objects associated with this route
api (swagger.OpenApi) – flaskdoc api container
- Returns
PathItem spec for the route
- Return type
swagger.PathItem
- flaskdoc.pallets.app.register_openapi(app, info, examples=None, servers=None, tags=None, security=None, docs_path='/docs', use_redoc=False, links=None)¶
Registers flaskdoc api specs to an existing flask app
- Parameters
app (flask.Flask) – an existing flask app instance
info (swagger.Info) – OpenAPI info block
examples (dict[str, swagger.Example]) – reusable mappings of examples
servers (list[swagger.Server]) – list of servers used for testing
tags (list[swagger.Tag]) – list of tags with name and description
security (dict[str, swagger.SecurityScheme]) – security schemes to apply
docs_path (str) – custom path name for the swagger ui docs, defaults to docs
use_redoc (bool) – disable normal swagger ui and use redoc ui instead
links (dict[str, swagger.Link]) – reusable links mapping
- flaskdoc.pallets.app.static_resources(path='default.html')¶
- flaskdoc.pallets.app.yaml_path()¶
flaskdoc.pallets.blueprints module¶
- class flaskdoc.pallets.blueprints.Blueprint(name, import_name, static_folder=None, static_url_path=None, template_folder=None, url_prefix=None, subdomain=None, url_defaults=None)¶
Bases:
flask.blueprints.Blueprint
,flaskdoc.pallets.mixin.SwaggerMixin
- name: str¶
- route(rule, ref=None, description=None, summary=None, servers=None, parameters=None, responses=None, **options)¶
Extends flask blueprint route :param rule: rule name :type rule: str :param ref: Allows for an external definition of this path item. :type ref: str :param description: An optional, string description, intended to apply to all operations in this path. :type description: str :param summary: An optional, string summary, intended to apply to all operations in this path. :type summary: str :param servers: server list :type servers: List[swagger.Server] :param parameters: list of parameters :type parameters: List[swagger.Parameter] :param responses: :type responses: swagger.ResponsesObject :param **options:
- Returns
- Return type
callback
flaskdoc.pallets.mixin module¶
- class flaskdoc.pallets.mixin.SwaggerMixin¶
Bases:
object
- add_path(relative_path, path_item)¶
Adds a path_item to existing list :param relative_path: path :type relative_path: str :param path_item: :type path_item: swagger.PathItem
- static extract_operations(methods, responses)¶
Extracts operations :param methods: operations :type methods: swagger.Operation|list[str|swagger.Operation])
- Returns
swagger operations and flask methods
- Return type
tuple list[swagger.Operations], list[str]
- static extract_path(path)¶
- static extract_tags(tags)¶
Extract tags from list :param tags: tags to add :type tags: str|list[str|tag.Tag]
- Returns
list of tags
- Return type
list[swagger.Tag]
- parse_route(rule, ref=None, description=None, summary=None, servers=None, parameters=None, responses=None, **options)¶
- property paths¶
flaskdoc.pallets.plugins module¶
- flaskdoc.pallets.plugins.get_docs()¶
- flaskdoc.pallets.plugins.parse_flask_rule(rule: str)¶
Parses a flask rule (URL), and returns an openapi compatible version of the url
- flaskdoc.pallets.plugins.register_spec(func, spec)¶