mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-06-30 02:13:29 +03:00
Fixed incorrect OpenAPI response schema generation for a DELETE method in generic views (#6860)
This commit is contained in:
parent
f7dc6b5656
commit
a142467586
|
@ -465,6 +465,13 @@ class AutoSchema(ViewInspector):
|
||||||
|
|
||||||
def _get_responses(self, path, method):
|
def _get_responses(self, path, method):
|
||||||
# TODO: Handle multiple codes and pagination classes.
|
# TODO: Handle multiple codes and pagination classes.
|
||||||
|
if method == 'DELETE':
|
||||||
|
return {
|
||||||
|
'204': {
|
||||||
|
'description': ''
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
item_schema = {}
|
item_schema = {}
|
||||||
serializer = self._get_serializer(path, method)
|
serializer = self._get_serializer(path, method)
|
||||||
|
|
||||||
|
|
|
@ -264,6 +264,29 @@ class TestOperationIntrospection(TestCase):
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
def test_delete_response_body_generation(self):
|
||||||
|
"""Test that a view's delete method generates a proper response body schema."""
|
||||||
|
path = '/{id}/'
|
||||||
|
method = 'DELETE'
|
||||||
|
|
||||||
|
class View(generics.DestroyAPIView):
|
||||||
|
serializer_class = views.ExampleSerializer
|
||||||
|
|
||||||
|
view = create_view(
|
||||||
|
View,
|
||||||
|
method,
|
||||||
|
create_request(path),
|
||||||
|
)
|
||||||
|
inspector = AutoSchema()
|
||||||
|
inspector.view = view
|
||||||
|
|
||||||
|
responses = inspector._get_responses(path, method)
|
||||||
|
assert responses == {
|
||||||
|
'204': {
|
||||||
|
'description': '',
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
def test_retrieve_response_body_generation(self):
|
def test_retrieve_response_body_generation(self):
|
||||||
"""Test that a list of properties is returned for retrieve item views."""
|
"""Test that a list of properties is returned for retrieve item views."""
|
||||||
path = '/{id}/'
|
path = '/{id}/'
|
||||||
|
|
Loading…
Reference in New Issue
Block a user