Skip to content

Handle paginated responses better #32

@kdmccormick

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

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