type in swagger

I am using flask_restplus to generate swagger. I have to accept Content-Type: application/x-www-form-urlencoded on one of the POST endpoint. But the auto generated swagger document only shows applicatin/json. How can I change this behavior? Thanks.


Just stumbled on this myself, and found a workaround.

The fix is to use @api.expect to annotate the method, not the class.

For example, say you have a parser called someparser that has an attribute with location='form' .

Instead of

@api.route('/someroute')
@api.expect(someparser)
class SomeResource(Resource):
    def post(self):
        ...

You should do

@api.route('/someroute')
class SomeResource(Resource):
    @api.expect(someparser)
    def post(self):
        ...
链接地址: http://www.djcxy.com/p/50964.html

上一篇: 使用Boost进程间共享内存构建错误

下一篇: 输入招摇