From d20c44afd6674cd3e66ea350564e6c08e1f16cc1 Mon Sep 17 00:00:00 2001 From: groshev artem Date: Tue, 25 May 2021 16:31:16 +0300 Subject: [PATCH] Fix extend schema with pagination for actions with customized responses/serializers. --- src/drf_yasg/inspectors/view.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/drf_yasg/inspectors/view.py b/src/drf_yasg/inspectors/view.py index 334c274a..e54bb947 100644 --- a/src/drf_yasg/inspectors/view.py +++ b/src/drf_yasg/inspectors/view.py @@ -264,9 +264,18 @@ def get_response_schemas(self, response_serializers): ) else: serializer = force_serializer_instance(serializer) + + 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 = openapi.Response( description='', - schema=self.serializer_to_schema(serializer), + schema=schema, ) responses[str(sc)] = response