难以使用 falcon-swagger-ui 在 Falcon 中提供 Swagger API 文档
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 我得到以下错误:
[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 文档的更好的软件包?
自最初 post 以来,对 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
时 swagger 将正确显示
我正在尝试提供基于 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 我得到以下错误:
[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 文档的更好的软件包?
自最初 post 以来,对 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
时 swagger 将正确显示