Response schemas from serializers will optionally be paginated#499
Response schemas from serializers will optionally be paginated#499PaulWay wants to merge 20 commits intoaxnsan12:masterfrom
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) |
| else: | ||
| serializer = force_serializer_instance(serializer) | ||
| schema = self.serializer_to_schema(serializer) | ||
| if self.should_page(): |
There was a problem hiding this comment.
| 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
lopezvit
left a comment
There was a problem hiding this comment.
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
responsesinswagger_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
responsessection and apply a pagination schema to them if the view should be paged. This does not apply to the default serializer fromget_default_responsesbecause that is already converted into a schema.Signed-off-by: Paul Wayper paulway@redhat.com