Skip to content

Commit

Permalink
Update view.py
Browse files Browse the repository at this point in the history
This relays on axnsan12#730 and axnsan12#499 but with the newest code, as I need to implement it in my own project.
  • Loading branch information
lopezvit committed Aug 31, 2022
1 parent d73cffc commit d3ee4bd
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions src/drf_yasg/inspectors/view.py
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,13 @@ def get_response_schemas(self, response_serializers):
response = serializer
if hasattr(response, 'schema') and not isinstance(response.schema, openapi.Schema.OR_REF):
serializer = force_serializer_instance(response.schema)
response.schema = self.serializer_to_schema(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.schema = schema
elif isinstance(serializer, openapi.Schema.OR_REF):
response = openapi.Response(
description='',
Expand All @@ -266,9 +272,15 @@ def get_response_schemas(self, response_serializers):
response = serializer
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
Expand Down

0 comments on commit d3ee4bd

Please sign in to comment.