Sanic-OpenAPI provides following configurable items:
- API Server
- API information
- Authentication(Security Definitions)
- URI filter
- Swagger UI configurations
By default, Swagger will use exactly the same host which served itself as the API server. But you can still override this by setting following configurations. For more information, please check document at here.
-
Key:
API_HOST
-
Type:
str
of IP, or hostname -
Default:
None
-
Usage:
from sanic import Sanic from sanic_openapi import openapi3_blueprint app = Sanic() app.blueprint(openapi3_blueprint) app.config.API_HOST = "petstore.swagger.io"
-
Key:
API_BASEPATH
-
Type:
str
-
Default:
None
-
Usage:
from sanic import Sanic from sanic_openapi import openapi3_blueprint app = Sanic() app.blueprint(openapi3_blueprint) app.config.API_BASEPATH = "/api"
-
Key:
API_SCHEMES
-
Type:
list
of schemes -
Default:
["http"]
-
Usage:
from sanic import Sanic from sanic_openapi import openapi3_blueprint app = Sanic() app.blueprint(openapi3_blueprint) app.config.API_SCHEMES = ["https"]
You can provide some additional information of your APIs by using Sanic-OpenAPI configurations. For more detail of those additional information, please check the document from Swagger.
-
Key:
API_VERSION
-
Type:
str
-
Default:
1.0.0
-
Usage:
from sanic import Sanic from sanic_openapi import openapi3_blueprint app = Sanic() app.blueprint(openapi3_blueprint) app.config.API_VERSION = "0.1.0"
-
Key:
API_TITLE
-
Type:
str
-
Default:
API
-
Usage:
from sanic import Sanic from sanic_openapi import openapi3_blueprint app = Sanic() app.blueprint(openapi3_blueprint) app.config.API_TITLE = "Sanic-Example-OpenAPI"
-
Key:
API_DESCRIPTION
-
Type:
str
-
Deafult:
""
-
Usage:
from sanic import Sanic from sanic_openapi import openapi3_blueprint app = Sanic() app.blueprint(openapi3_blueprint) app.config.API_DESCRIPTION = "An example Swagger from Sanic-OpenAPI"
-
Key:
API_TERMS_OF_SERVICE
-
Type:
str
of a URL -
Deafult:
""
-
Usage:
from sanic import Sanic from sanic_openapi import openapi3_blueprint app = Sanic() app.blueprint(openapi3_blueprint) app.config.API_TERMS_OF_SERVICE = "https://github.com/sanic-org/sanic-openapi/blob/master/README.md"
-
Key:
API_CONTACT_EMAIL
-
Type:
str
of email address -
Deafult:
None"
-
Usage:
from sanic import Sanic from sanic_openapi import openapi3_blueprint app = Sanic() app.blueprint(openapi3_blueprint) app.config.API_CONTACT_EMAIL = "foo@bar.com"
-
Key:
API_LICENSE_NAME
-
Type:
str
-
Default:
None
-
Usage:
python from sanic import Sanic from sanic_openapi import openapi3_blueprint
app = Sanic() app.blueprint(openapi3_blueprint) app.config.API_LICENSE_NAME = "MIT"