TornOpen
TornOpen is an extension of Tornado that relies on both Python's type annotation and pydantic to generate OpenAPI compliant documentation using apispec for Redoc
Supports
- For Python versions 3.6 to 3.9, Tornado versions 4.5 to 6.1 are supported
- For Python version 3.10, Tornado versions 6.0 to 6.1 are supported
Installation
pip install torn-open
Usage
Example Code
from typing import Optional
from tornado.web import url
from tornado.ioloop import IOLoop
from torn_open import (
AnnotatedHandler,
Application,
RequestModel,
ResponseModel,
ClientError,
tags,
summary,
)
class MyRequestModel(RequestModel):
"""
Docsting here will show up as description of the request model on redoc
"""
var1: str
var2: int
class MyResponseModel(ResponseModel):
"""
Docsting here will show up as description of the response on redoc
"""
path_param: str
query_parm: int
req_body: MyRequestModel
class MyAnnotatedHandler(AnnotatedHandler):
@tags("tag_1", "tag_2")
@summary("this is a summary")
def post(
self,
*,
path_param: str,
query_param: Optional[int] = 1,
req_body: MyRequestModel,
) -> MyResponseModel:
"""
Docstrings will show up as descriptions on redoc
"""
try:
"""do something here"""
except:
raise ClientError(status_code=403, error_type="forbiddon")
return MyResponseModel(
path_param=path_param,
query_param=query_param,
req_body=req_body,
)
def make_app():
return Application(
[
url(r"/annotated/(?P<path_param>[^/]+)", MyAnnotatedHandler),
],
)
if __name__ == "__main__":
app = make_app()
app.listen(8888)
IOLoop.current().start()
Result
Documentation
Documentation and links to additional resources can be found here: https://b34nst4lk.github.io/tornopen/
Acknowledgements
Metadata
Release files for torn-open 0.0.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| torn_open-0.0.3.tar.gz | 13.0 kB | Without provenance | Details for torn_open-0.0.3.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| torn_open-0.0.3-py3-none-any.whl | Python 3 | none | any | Details for torn_open-0.0.3-py3-none-any.whl |
Total release size: 27.9 kB
Release files / torn_open-0.0.3.tar.gz
| Download URL | torn_open-0.0.3.tar.gz |
|---|---|
| Size | 13.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
689ac019ec6c5ecbb5d8e9c67ae3b330708370eebeba5d6c3b007acc77228972
|
|
BLAKE2b-256 checksum How to use checksums |
e13ea0cbee36446255f389d3b5cf5ef63af37b932126f2a3c3c21fddef00a7ce
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.9
|
Release files / torn_open-0.0.3-py3-none-any.whl
| Download URL | torn_open-0.0.3-py3-none-any.whl |
|---|---|
| Size | 14.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
cf3576d92f68197cd9bfab73c26a09ab07a9d3c6571f43b837e23fc7e2728d13
|
|
BLAKE2b-256 checksum How to use checksums |
b2f3314e6406224633829d02ef7d93ed564f486d27120494d20f25fa57ea8d9b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.9
|
Security for torn-open 0.0.3
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.