flask_openapi.extension¶
This module contains the actual Flask extension.
-
class
flask_openapi.extension.OpenAPI(app=None)¶ The Flask extension that handles all magic.
Parameters: app (flask.Flask) – The Flask app to apply this extension to. -
add_definition(definition, name=None)¶ Add a new named definition.
Parameters: - definition – A
dictdescribing a Swagger schemaObject. This may also be astrorpathlib.Pathreferring to a file to read. - name (str) – A name for the schema. If this is not specified, the title of the schema definition will be used.
- definition – A
-
add_response(name, response)¶ Define a possible response to be reused accross operations.
Parameters: - name (str) – The name of the response. See Swagger rdName.
- response (dict) – The response to add. See Swagger responseObject.
-
base_path¶ str– The relative URL prefix for all API calls.See Swagger swaggerBasePath for details.
-
definitions¶ dict– The top level Swagger definitionsObject.
-
deprecated(fn)¶ Mark an operation as deprecated.
This will be exposed through the OpenAPI operation object. Additionally a warning will be emitted when the API is used. This can be configured using the
OPENAPI_WARN_DEPRECATEDconfiguration option. This must be one ofwarnorlog.
-
host¶ str– The server host name.This is only returned if
show_hostisTrue.See Swagger swaggerHost for details.
-
info¶ dict– The top level Swagger infoObject.
-
init_app(app)¶ Initialize the OpenAPI instance for the given app.
This should be used for a deferred initialization, supporting the Flask factory pattern.
Parameters: app (flask.Flask) – The Flask app to apply this extension to.
-
paths¶ dict– The top level Swagger pathsObject.
-
response(status_code, response)¶ Describe a possible response for a Flask handler.
Parameters: - status_code – The status code for which the response is
described.
str,intorhttp.HTTPStatusare accepted. The result will be exposed as a string. See Swagger responsesCode. - response – A description of the response object. This may be
a dict describing a response or a string referring to a
response added using
add_response. See Swagger responseObject.
- status_code – The status code for which the response is
described.
-
responses¶ dict– The top level Swagger responsesObject.
-
schema(schema)¶ A decorator to validate a request using a Swagger schemaObject.
Parameters: schema – Either a dictto use as a schema directly or astrreferring to a named schema. (Seeadd_definition.)
-
schemes¶ list– The supported schemes for all API calls.See Swagger swaggerSchemes for details.
-
swagger¶ dict– The top level Swagger swaggerObject.
-
tag(*tags)¶ Tag an operation using one or more tags.
These tags are exposed through the OpenAPI operation object.
Parameters: *tags (str) – The tags to apply to the operation.
dict– A list of tag descriptions.See Swagger tagObject.
-