I'm trying to create a restful web services with flask-restx and marshmallow.
I'm using marshmallow for both request and response validations.
Since flask-restx api docs does not support marshmallow schemas in swagger ui, i want to add it using doc decorator.
Controller Code:
@ns.route('/')
class Test(Resource):
@ns.doc(params={'test': 'test'})
def get(self):
_input_schema = MySchema()
errors = _input_schema.validate(request.args)
if errors:
return Response(str(errors), status=400)
other_things()
Schema Code:
class MySchema(Schema):
title = fields.Str()
id = fields.Integer()
slug = fields.Str()
I'm trying to automatically add parameters from schema to api docs like that
@ns.doc(params=MySchema.ReturnAFieldDict())
And it will give something like that
@ns.doc(params={"title":"A string", "id": "Int value with min and max", "slug":"A str"})
Is there any way to do that?