Package: tornado-rest-swagger
tornado-rest-swaggerPyPILinuxWindowstornado-rest-swagger: Swagger API Documentation builder for tornado server. Inspired byaiohttp-swaggerpackage (based on this package sources).Documentationhttps://github.com/Cluas/tornado-rest-swagger/wikiCodehttps://github.com/Cluas/tornado-rest-swaggerIssueshttps://github.com/Cluas/tornado-rest-swagger/issuesPython versionpython2.7 and Python 3.4 and aboveSwagger Language Specificationhttps://swagger.io/specificationInstallationpip install -U tornado-rest-swaggerWhat's tornado-rest-swaggertornado-rest-swagger is a plugin for tornado server that allow to document APIs using Swagger show the Swagger-ui console.Exampleimporttornado.ioloopimporttornado.optionsimporttornado.webfromtornado_swagger.componentsimportcomponentsfromtornado_swagger.setupimportsetup_swaggerclassBaseHandler(tornado.web.RequestHandler):defdata_received(self,chunk):passclassPostsHandler(BaseHandler):defget(self):"""---tags:- Postssummary: List postsdescription: List all posts in feedoperationId: getPostresponses:'200':description: A list of userscontent:application/json:schema:$ref: '#/components/schemas/ArrayOfPostModel'application/xml:schema:$ref: '#/components/schemas/ArrayOfPostModel'text/plain:schema:type: string"""defpost(self):"""---tags:- Postssummary: Add a new Post to the blogoperationId: addPostrequestBody:description: Post object that needs to be added to the blogcontent:application/json:schema:$ref: '#/components/schemas/PostModel'application/xml:schema:$ref: '#/components/schemas/PostModel'required: trueresponses:'405':description: Invalid inputcontent: {}security:- petstore_auth:- 'write:pets'- 'read:pets'"""classPostsDetailsHandler(BaseHandler):defget(self,posts_id):"""---tags:- Postssummary: Find Post by IDdescription: Returns a single postoperationId: getPostByIdparameters:- name: post_idin: pathdescription: ID of post to returnrequired: trueschema:type: integerformat: int64responses:'200':description: successful operationcontent:application/xml:schema:$ref: '#/components/schemas/PostModel'application/json:schema:$ref: '#/components/schemas/PostModel''400':description: Invalid ID suppliedcontent: {}'404':description: Pet not foundcontent: {}security:- api_key: []"""defpatch(self,posts_id):"""---tags:- Postssummary: Find Post by IDdescription: Returns a single postoperationId: getPostByIdparameters:- name: post_idin: pathdescription: ID of post to returnrequired: trueschema:type: integerformat: int64requestBody:description: Post object that needs to be added to the blogcontent:application/json:schema:$ref: '#/components/schemas/PostModel'application/xml:schema:$ref: '#/components/schemas/PostModel'required: trueresponses:'400':description: Invalid ID suppliedcontent: {}'404':description: Pet not foundcontent: {}security:- api_key: []"""defdelete(self,posts_id):"""---tags:- Postssummary: Delete Post by IDdescription: Returns a single postoperationId: getPostByIdparameters:- name: post_idin: pathdescription: ID of post to returnrequired: trueschema:type: integerformat: int64responses:'200':description: successful operationcontent:application/json:schema:type: objectdescription: Post model representationproperties:id:type: integerformat: int64title:type: stringtext:type: stringis_visible:type: booleandefault: true'400':description: Invalid ID suppliedcontent: {}'404':description: Pet not foundcontent: {}"""@components.schemas.registerclassPostModel(object):"""---type: objectdescription: Post model representationproperties:id:type: integerformat: int64title:type: stringtext:type: stringis_visible:type: booleandefault: true"""@components.schemas.registerclassArrayOfPostModel(object):"""---type: arraydescription: Array of Post model representationitems:$ref: '#/components/schemas/PostModel'"""@components.security_schemes.registerclassJWTToken(object):"""---type: httpscheme: bearerbearerFormat: JWT"""classApplication(tornado.web.Application):_routes=[tornado.web.url(r"/api/posts",PostsHandler),tornado.web.url(r"/api/posts/(\w+)",PostsDetailsHandler)]def__init__(self):settings={"debug":True}setup_swagger(self._routes,swagger_url="/doc",description="",api_version="1.0.0",title="Journal API",contact=dict(name="test",email="test@domain.com",url="https://www.cluas.me"),)super(Application,self).__init__(self._routes,**settings)if__name__=="__main__":tornado.options.define("port",default="8080",help="Port to listen on")tornado.options.parse_command_line()app=Application()app.listen(port=8080)tornado.ioloop.IOLoop.current().start()Version 1.1.3Fully support OpenAPI3.0Version 1.1.2Support OpenAPI 3.0 AuthenticationVersion 1.1.1First version releasedLicense