我正在尝试提供基于falcon-swagger-ui软件包的招摇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 出现以下错误:
[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提供招摇的API文档?
自原始帖子以来,对falcon-swagger-ui进行了一些更新。
现在,如果您在存储库中使用示例:
https://github.com/rdidyk/falcon-swagger-ui/blob/master/example.py#L9-L17
并将您的 swagger 架构放在 static/v1/swagger.json 中,然后当您前往 http://127.0.0.1:8000/swagger