用于Python Web框架的Swagger UI,例如Tornado,Flask和Sanic

网友投稿 963 2022-10-28

用于Python Web框架的Swagger UI,例如Tornado,Flask和Sanic

用于Python Web框架的Swagger UI,例如Tornado,Flask和Sanic

swagger-ui-py

Swagger UI for Python web framework, such Tornado, Flask, Quart, aiohttp, Sanic and Falcon.

Only support Python3.

Supported

tornadoflasksanicaiohttpquartstarlettefalconbottle

Usage

Installpip3 install swagger-ui-py Code Using the local config filefrom swagger_ui import api_docapi_doc(app, config_path='./config/test.yaml', url_prefix='/api/doc', title='API doc') Using config url, but need to suport CORSapi_doc(app, config_url='https://petstore.swagger.io/v2/swagger.json', url_prefix='/api/doc', title='API doc') And suport config file editorapi_doc(app, config_path='./config/test.yaml', editor=True) And keep the old way# for Tornadofrom swagger_ui import tornado_api_doctornado_api_doc(app, config_path='./conf/test.yaml', url_prefix='/api/doc', title='API doc')# for Sanicfrom swagger_ui import sanic_api_docsanic_api_doc(app, config_path='./conf/test.yaml', url_prefix='/api/doc', title='API doc')# for Flaskfrom swagger_ui import flask_api_docflask_api_doc(app, config_path='./conf/test.yaml', url_prefix='/api/doc', title='API doc')# for Quartfrom swagger_ui import quart_api_docquart_api_doc(app, config_path='./conf/test.yaml', url_prefix='/api/doc', title='API doc')# for aiohttpfrom swagger_ui import aiohttp_api_docaiohttp_api_doc(app, config_path='./conf/test.yaml', url_prefix='/api/doc', title='API doc')# for Falconfrom swagger_ui import falcon_api_docfalcon_api_doc(app, config_path='./conf/test.yaml', url_prefix='/api/doc', title='API doc') Edit Swagger config file (JSON or YAML) Please see https://swagger.io/resources/open-api/. Access Open http://:/api/doc/editor, you can edit api doc config file. Open http://:/api/doc view api doc.

Swagger UI

Swagger UI version is 3.25.1. see https://github.com/swagger-api/swagger-ui.

Swagger Editor

Swagger Editor version is 3.8.1. see https://github.com/swagger-api/swagger-editor.

Update

You can update swagger ui and swagger editor version with

cd swagger-ui-py/toolspython update.py ui# orpython update.py editor

版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。

上一篇:获取年数,季度数.星期数,天数,小时…
下一篇:集成react + react-router + react-redux的轻量级前端框架
相关文章

 发表评论

暂时没有评论,来抢沙发吧~