我正在使用flask_restplus生成swagger。我必须接受其中一个POST端点上的Content-Type: application/x-www-form-urlencoded。但是自动生成的swagger文档只显示applicatin/json。如何更改此行为?谢谢。
发布于 2018-01-20 12:32:02
我自己偶然发现了这一点,并找到了一种解决方法。
修复方法是使用@api.expect来注释方法,而不是类。
例如,假设您有一个具有location='form'属性的名为someparser的解析器。
而不是
@api.route('/someroute')
@api.expect(someparser)
class SomeResource(Resource):
def post(self):
...你应该这样做
@api.route('/someroute')
class SomeResource(Resource):
@api.expect(someparser)
def post(self):
...https://stackoverflow.com/questions/47901223
复制相似问题