https://github.com/sveint/flask-swagger-ui
Swagger UI blueprint for flask
https://github.com/sveint/flask-swagger-ui
Last synced: 2 days ago
JSON representation
Swagger UI blueprint for flask
- Host: GitHub
- URL: https://github.com/sveint/flask-swagger-ui
- Owner: sveint
- License: mit
- Created: 2016-10-05T14:07:19.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2024-04-18T17:57:07.000Z (12 months ago)
- Last Synced: 2025-04-03T18:15:17.454Z (11 days ago)
- Language: Python
- Homepage:
- Size: 11.7 MB
- Stars: 183
- Watchers: 3
- Forks: 62
- Open Issues: 26
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- jimsghstars - sveint/flask-swagger-ui - Swagger UI blueprint for flask (Python)
README
# flask-swagger-ui
Simple Flask blueprint for adding [Swagger UI](https://github.com/swagger-api/swagger-ui) to your flask application.
Included Swagger UI version: 4.11.1.
## Installation
`pip install flask-swagger-ui`
## Usage
Example application:
```python
from flask import Flask
from flask_swagger_ui import get_swaggerui_blueprintapp = 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={ # Swagger UI config overrides
'app_name': "Test application"
},
# oauth_config={ # OAuth config. See https://github.com/swagger-api/swagger-ui#oauth2-configuration .
# '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/
```
## Configuration
The blueprint supports overloading all Swagger UI configuration options that can be JSON serialized.
See https://github.com/swagger-api/swagger-ui/blob/master/docs/usage/configuration.md#parameters for options.Plugins and function parameters are not supported at this time.
OAuth2 parameters can be found at https://github.com/swagger-api/swagger-ui#oauth2-configuration .