Swagger UI for Tornado
Project description
# tornado-swagger-ui
Simple Tornado Handler for adding [Swagger UI](https://github.com/swagger-api/swagger-ui) to your tornado application.
Included Swagger UI version: 3.22.1.
## Installation
`pip install git+https://gitlab.com/api-projects-boilerplates/tornado-swagger-ui.git`
## Usage
Example application:
```python
import tornado.ioloop
import tornado.web
from tornado_swagger_ui import get_tornado_handler
SWAGGER_URL = '/api/docs' # URL for exposing Swagger UI (without trailing '/')
# Our API url (can of course be a local resource)
API_URL = 'http://petstore.swagger.io/v2/swagger.json'
# Call factory function to create our handler
swagger_handlers = get_tornado_handler(
base_url=SWAGGER_URL,
api_url=API_URL,
config={
"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"}
# }
)
class IndexHandler(tornado.web.RequestHandler):
def get(self):
self.finish("Tornado Swagger UI")
handlers = [
(r"/", IndexHandler)
]
handlers.extend(swagger_handlers)
def make_app():
return tornado.web.Application(handlers)
if __name__ == "__main__":
app = make_app()
app.listen(5000)
tornado.ioloop.IOLoop.current().start()
# Now point your browser to localhost:5000/api/docs/
```
## Configuration
The handler supports overloading all Swagger UI configuration options that can be JSON serialized.
See https://github.com/swagger-api/swagger-ui#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 .
##
Based on the package:
* https://github.com/sveint/flask-swagger-ui
Simple Tornado Handler for adding [Swagger UI](https://github.com/swagger-api/swagger-ui) to your tornado application.
Included Swagger UI version: 3.22.1.
## Installation
`pip install git+https://gitlab.com/api-projects-boilerplates/tornado-swagger-ui.git`
## Usage
Example application:
```python
import tornado.ioloop
import tornado.web
from tornado_swagger_ui import get_tornado_handler
SWAGGER_URL = '/api/docs' # URL for exposing Swagger UI (without trailing '/')
# Our API url (can of course be a local resource)
API_URL = 'http://petstore.swagger.io/v2/swagger.json'
# Call factory function to create our handler
swagger_handlers = get_tornado_handler(
base_url=SWAGGER_URL,
api_url=API_URL,
config={
"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"}
# }
)
class IndexHandler(tornado.web.RequestHandler):
def get(self):
self.finish("Tornado Swagger UI")
handlers = [
(r"/", IndexHandler)
]
handlers.extend(swagger_handlers)
def make_app():
return tornado.web.Application(handlers)
if __name__ == "__main__":
app = make_app()
app.listen(5000)
tornado.ioloop.IOLoop.current().start()
# Now point your browser to localhost:5000/api/docs/
```
## Configuration
The handler supports overloading all Swagger UI configuration options that can be JSON serialized.
See https://github.com/swagger-api/swagger-ui#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 .
##
Based on the package:
* https://github.com/sveint/flask-swagger-ui
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Filename, size | File type | Python version | Upload date | Hashes |
---|---|---|---|---|
Filename, size tornado_swagger_ui-0.1-py3-none-any.whl (565.1 kB) | File type Wheel | Python version py3 | Upload date | Hashes View |
Filename, size tornado_swagger_ui-0.1.tar.gz (560.2 kB) | File type Source | Python version None | Upload date | Hashes View |
Close
Hashes for tornado_swagger_ui-0.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 04520c479a6ce6859274e94a6d72d8e86b44f9c6f697798f1f6c0ce3af58b2a2 |
|
MD5 | 29e38669d7cc07de51085a897e337941 |
|
BLAKE2-256 | 24bb0bcc245a60788600d31f5ada67188e1ab1e7e2d21d5c2346cac796add346 |