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 August 12, 2019 08:23
@reupen reupen marked this pull request as ready for review August 12, 2019 20:06
@peterfarrell
Copy link
Contributor

Looking forward to seeing this PR merged and released.

Copy link
Collaborator

@carltongibson carltongibson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, this looks good. Thanks @reupen

@carltongibson carltongibson merged commit f8c1644 into encode:master Sep 3, 2019
@reupen reupen deleted the pagination-schema branch September 4, 2019 18:21
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.
sigvef pushed a commit to sigvef/django-rest-framework that referenced this pull request Dec 3, 2022
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