-
Notifications
You must be signed in to change notification settings - Fork 61
/
Copy pathexample.py
31 lines (24 loc) · 1002 Bytes
/
example.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
from flask import Flask
from flask_swagger_ui import get_swaggerui_blueprint
app = Flask(__name__)
SWAGGER_URL = "/api/docs" # URL for exposing Swagger UI (without trailing '/')
API_URL = (
"http://petstore.swagger.io/v2/swagger.json"
) # Our API url (can of course be a local resource)
# Call factory function to create our blueprint
swaggerui_blueprint = get_swaggerui_blueprint(
SWAGGER_URL, # Swagger UI static files will be mapped to '{SWAGGER_URL}/dist/'
API_URL,
config={"app_name": "Test application"}, # Swagger UI config overrides
# oauth_config={ # OAuth config. See swagger-ui docs.
# 'clientId': "your-client-id",
# 'clientSecret': "your-client-secret-if-required",
# 'realm': "your-realms",
# 'appName': "your-app-name",
# 'scopeSeparator': " ",
# 'additionalQueryStringParams': {'test': "hello"}
# }
)
app.register_blueprint(swaggerui_blueprint)
app.run()
# Now point your browser to localhost:5000/api/docs/