Open wangshunping opened 8 years ago
just do api.route over your class instead of type=json
class Test(fields.Raw): def format(self, value): return {'x': ['whatever']}
test_fields = api.model('Test', { 'a': fields.String(required=True, description='...', example='an example'), 'b': Test(example="hey") })
use @api.route('/whatever', methods=[post]) class whatever(Resource): def post(self): @api.expect(fields=test_fields) all_params = request.json()
it is a formatted copy of @harishkashyap 's comment:
just do api.route over your class instead of type=json
class Test(fields.Raw):
def format(self, value):
return {'x': ['whatever']}
test_fields = api.model('Test', {
'a': fields.String(required=True, description='...', example='an example'),
'b': Test(example="hey")
})
# use
@api.route('/whatever', methods=["post"])
class whatever(Resource):
def post(self):
@api.expect(fields=test_fields)
all_params = request.json()
@maxkoryukov
This helped, except I needed to use request.json for it to work
@maxkoryukov
This helped, except I needed to use request.json for it to work
Could you explain how you solved it with request.json?
as I see in a demo from swagger.io, i could post a json file
flask-restplus support it ?
can can i modify argument ?
I modify parser this way and it doesn't work.