4

我正在尝试基于 falcon-swagger-ui 包提供 swagger API 文档:https ://github.com/rdidyk/falcon-swagger-ui 并使用我拥有的 repo 中的示例:

# 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 文档?

4

1 回答 1

1

自原始帖子以来,falcon-swagger-ui 已经进行了一些更新。

现在,如果您使用 repo 中的示例:

https://github.com/rdidyk/falcon-swagger-ui/blob/master/example.py#L9-L17

并将您的招摇模式放在 static/v1/swagger.json 中,然后当您前往http://127.0.0.1:8000/swagger时,招摇将正确显示

于 2018-09-27T15:31:45.173 回答