mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-02-19 21:11:04 +03:00
Schemas: Don't generate component for DELETE method. (#7229)
This commit is contained in:
parent
e6c1afbcf9
commit
41f27c3b43
|
@ -185,6 +185,10 @@ class AutoSchema(ViewInspector):
|
||||||
"""
|
"""
|
||||||
Return components with their properties from the serializer.
|
Return components with their properties from the serializer.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
if method.lower() == 'delete':
|
||||||
|
return {}
|
||||||
|
|
||||||
serializer = self._get_serializer(path, method)
|
serializer = self._get_serializer(path, method)
|
||||||
|
|
||||||
if not isinstance(serializer, serializers.Serializer):
|
if not isinstance(serializer, serializers.Serializer):
|
||||||
|
|
|
@ -1087,3 +1087,15 @@ class TestGenerator(TestCase):
|
||||||
assert 'components' in schema
|
assert 'components' in schema
|
||||||
assert 'schemas' in schema['components']
|
assert 'schemas' in schema['components']
|
||||||
assert 'Duplicate' in schema['components']['schemas']
|
assert 'Duplicate' in schema['components']['schemas']
|
||||||
|
|
||||||
|
def test_component_should_not_be_generated_for_delete_method(self):
|
||||||
|
class ExampleView(generics.DestroyAPIView):
|
||||||
|
schema = AutoSchema(operation_id_base='example')
|
||||||
|
|
||||||
|
url_patterns = [
|
||||||
|
url(r'^example/?$', ExampleView.as_view()),
|
||||||
|
]
|
||||||
|
generator = SchemaGenerator(patterns=url_patterns)
|
||||||
|
schema = generator.get_schema(request=create_request('/'))
|
||||||
|
assert 'components' not in schema
|
||||||
|
assert 'content' not in schema['paths']['/example/']['delete']['responses']['204']
|
||||||
|
|
Loading…
Reference in New Issue
Block a user