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

Add support for pagination in OpenAPI response schemas #6867

Merged
merged 1 commit into from Sep 3, 2019

Conversation

reupen
Copy link
Contributor

@reupen reupen commented Aug 11, 2019

Description

Refs #6846

This provides a way for pagination classes to add pagination properties (count, next, results etc.) to OpenAPI response schemas.

A new method get_paginated_response_schema() has been added to BasePagination. This method is intended to mirror get_paginated_response() (which takes a list and typically wraps it in a dict).

Hence, get_paginated_response_schema() takes an unpaginated response schema (of type array) and wraps that with a schema object of type object containing the relevant properties that the pagination class adds to responses.

The default implementation of BasePagination.get_paginated_response_schema() simply passes the schema through unmodified, for backwards compatibility.

Refs encode#6846

This provides a way for pagination classes to add pagination properties (`count`, `next`, `results` etc.) to OpenAPI response schemas.

A new method `get_paginated_response_schema()` has been added to `BasePagination`. This method is intended to mirror `get_paginated_response()` (which takes a `list` and wraps it in a `dict`). 

Hence, `get_paginated_response_schema()` takes an unpaginated response schema (of type `array`) and wraps that with a schema object of type `object` containing the relevant properties that the pagination class adds to responses.

The default implementation of `BasePagination.get_paginated_response_schema()` simply passes the schema through unmodified, for backwards compatibility.
@carltongibson carltongibson self-requested a review Aug 12, 2019
@reupen reupen marked this pull request as ready for review Aug 12, 2019
@peterfarrell
Copy link
Contributor

peterfarrell commented Aug 19, 2019

Looking forward to seeing this PR merged and released.

Copy link
Collaborator

@carltongibson carltongibson left a comment

OK, this looks good. Thanks @reupen

@carltongibson carltongibson merged commit f8c1644 into encode:master Sep 3, 2019
1 check passed
@reupen reupen deleted the pagination-schema branch Sep 4, 2019
pchiquet pushed a commit to pchiquet/django-rest-framework that referenced this pull request Nov 17, 2020
Refs encode#6846

This provides a way for pagination classes to add pagination properties (`count`, `next`, `results` etc.) to OpenAPI response schemas.

A new method `get_paginated_response_schema()` has been added to `BasePagination`. This method is intended to mirror `get_paginated_response()` (which takes a `list` and wraps it in a `dict`). 

Hence, `get_paginated_response_schema()` takes an unpaginated response schema (of type `array`) and wraps that with a schema object of type `object` containing the relevant properties that the pagination class adds to responses.

The default implementation of `BasePagination.get_paginated_response_schema()` simply passes the schema through unmodified, for backwards compatibility.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants