-
Notifications
You must be signed in to change notification settings - Fork 440
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
Response schemas from serializers will optionally be paginated #499
base: master
Are you sure you want to change the base?
Response schemas from serializers will optionally be paginated #499
Conversation
Signed-off-by: Paul Wayper <paulway@redhat.com>
@axnsan12 wondering if it is possible to merge this PR? |
@PaulWay do you have a workaround for this? |
Yeah, unfortunately the workaround is to subclass the view inspector and copy the @axnsan12 What's your take on this? |
Could you please provide an example with code (the workaround) that works for this use-case? Thanks. |
@axnsan12 this would be very helpful to have (assuming it's fixed) |
@@ -264,9 +264,12 @@ def get_response_schemas(self, response_serializers): | |||
) | |||
else: | |||
serializer = force_serializer_instance(serializer) | |||
schema = self.serializer_to_schema(serializer) | |||
if self.should_page(): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if self.should_page(): | |
if self.has_list_response(): | |
schema = openapi.Schema(type=openapi.TYPE_ARRAY, items=schema) | |
if self.should_page(): |
This needs another step to work with current code.
Any chance there is an update on this? Such a useful feature. |
Sorry, have had this on the back burner - will update this soon! |
Some update about this issue? What's missing to finish and release it? |
fix map source mapping
[readme] Fix missing re_path import
Add utf-8 support for generated formats
Remove universal wheel, python 2 is unsupported
Fix old spelling errors and add a cspell configuration.
…-arbitrary-references Allow specifying response as a reference
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This exact same changes need to be done as well to line 259, so it also work when you want to add a description to the method:
schema = self.serializer_to_schema(serializer)
if self.has_list_response():
schema = openapi.Schema(type=openapi.TYPE_ARRAY, items=schema)
if self.should_page():
schema = self.get_paginated_response(schema) or schema
response.schema = schema
This relays on axnsan12#730 and axnsan12#499 but with the newest code, as I need to implement it in my own project
This relays on axnsan12#730 and axnsan12#499 but with the newest code, as I need to implement it in my own project.
This relays on axnsan12#730 and axnsan12#499 but with the newest code, as I need to implement it in my own project
At the moment, if a non-default response serializer is set via
responses
inswagger_auto_schema
, it will not pick up any pagination schema that might apply from any paginator inspectors.This patch will take any serializers provided in the
responses
section and apply a pagination schema to them if the view should be paged. This does not apply to the default serializer fromget_default_responses
because that is already converted into a schema.Signed-off-by: Paul Wayper paulway@redhat.com