You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Our use case is that in a Resource View we want to return either a single item for GET /foo/pk or a list of items for GET /foo. Not only does one schema have many=True and the other doesn't, but often we have different fields in them because listing may use a stripped-down schema for efficiency.
Right now if we want to declare this in the documentation we have to use different status codes, which is obviously not ideal:
(permission checks etc removed):
@marshal_with(Ref('_marshal_schema_class'), code=200)
@marshal_with(Ref('_marshal_schema_class_multi'), code=201)
def get(self, id):
"""Get single resource or list of resources."""
if id:
item = self._get(id)
return item, 200
else:
return self._query_for_current_user().all(), 201
Is there some way to support both schemas for code 200?
The text was updated successfully, but these errors were encountered:
Our use case is that in a Resource View we want to return either a single item for
GET /foo/pk
or a list of items forGET /foo
. Not only does one schema havemany=True
and the other doesn't, but often we have different fields in them because listing may use a stripped-down schema for efficiency.Right now if we want to declare this in the documentation we have to use different status codes, which is obviously not ideal:
(permission checks etc removed):
Is there some way to support both schemas for code 200?
The text was updated successfully, but these errors were encountered: