[英]Difficulty serving Swagger API documentation in Falcon with falcon-swagger-ui
我正在嘗試基於falcon-swagger-ui軟件包提供swagger API技巧: https : //github.com/rdidyk/falcon-swagger-ui並使用回購中的示例我有:
# example.py
import falcon
from falcon_swagger_ui import StaticSinkAdapter
from falcon_swagger_ui import register_swaggerui_app
SWAGGERUI_URL = '/swagger'
SCHEMA_URL = '/swagger.json'
app = falcon.API()
app.add_sink(
StaticSinkAdapter('/home/greg/falcon-swagger-example/schema.json'), SCHEMA_URL
)
register_swaggerui_app(app, SWAGGERUI_URL, SCHEMA_URL, config={
'supportedSubmitMethods': ['get'],
})
我的模式json文件已經存在的位置。 如果然后運行gunicorn example:app
並轉到http://127.0.0.1:8000/swagger, gunicorn example:app
出現以下錯誤:
[2017-11-30 13:51:59 +0000] [23935] [ERROR] Error handling request /swagger.json
Traceback (most recent call last):
File "/home/greg/falcon-swagger-example/.env/local/lib/python2.7/site-packages/gunicorn/workers/sync.py", line 135, in handle
self.handle_request(listener, req, client, addr)
File "/home/greg/falcon-swagger-example/.env/local/lib/python2.7/site-packages/gunicorn/workers/sync.py", line 176, in handle_request
respiter = self.wsgi(environ, resp.start_response)
File "/home/greg/falcon-swagger-example/.env/local/lib/python2.7/site-packages/falcon/api.py", line 242, in __call__
responder(req, resp, **params)
TypeError: __call__() takes exactly 4 arguments (3 given)
有什么想法我做錯了嗎? 在任何人看來,是否有更好的軟件包可以與Falcon API一起使用swagger API文檔?
自原始帖子發布以來,falcon-swagger-ui進行了一些更新。
現在,如果您在倉庫中使用示例:
https://github.com/rdidyk/falcon-swagger-ui/blob/master/example.py#L9-L17
並將您的招搖模式放置在static / v1 / swagger.json中,那么當您前往http://127.0.0.1:8000/swagger時,招搖將正確顯示
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.