Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle paginated responses better #32

Open
kdmccormick opened this issue Apr 30, 2020 · 1 comment
Open

Handle paginated responses better #32

kdmccormick opened this issue Apr 30, 2020 · 1 comment

Comments

@kdmccormick
Copy link
Member

kdmccormick commented Apr 30, 2020

Sometimes, drf-yasg can't figure out the appropriate serializer for a class. That's not a problem if we have a serializer on hand to pass to schema:

@schema(responses={200: MySerializer})
def get(...):
    """ My view """

For paginated views, this becomes a problem, because we don't have a paginated serializer to give schema.

I see two solutions to this:

1. Help drf-yasg figure out paginated serializers better

Why can't drf-yasg generate a correct paginated response schema? Are we missing a class variable on our views? Are we using DRF wrong?

2. Provide a manual paginate_serializer function as a fall-back

In the case where drf-yasg just can't figure out the response schema, it'd be great to be able to do something like:

@schema(responses={200: paginate_serializer(MySerializer, MyPaginationClass)})
def get(...):
    """ My paginated view """
@kdmccormick kdmccormick changed the title Provide utility function for paginating serializers Handle paginated responses better May 1, 2020
@kdmccormick
Copy link
Member Author

This PR would provide paginate_serializer for edx-platform, but it'd be better to add this at the api-doc-tools level.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant