Skip to content

Handle paginated responses better #32

Description

@kdmccormick

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 """

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions