apryor6 / flask_accepts

Easy, opinionated Flask input/output handling mixing Marshmallow with flask-restx
BSD 3-Clause "New" or "Revised" License
169 stars 40 forks source link

Support enveloping response #74

Closed azzamsa closed 4 years ago

azzamsa commented 4 years ago

In flask-resplus marshall, I can use:

@api.marshal_with(User, envelope="data")

I don't find this in response. I would like to use something like:

@responds(schema=User, api=api, many=True, envlope='data')

I also can't do something like:

users = user_service.get_users()
return {"data": users}

My current workaround is to use @api.expect(User) (to include those param into swagger doc) and schema.dump()

    @api.expect(User)
    def get(self):
        """List all available users"""
        try:
            users = user_service.get_users()
            return {"data": user_schema.dump(users)}