mirror of
https://github.com/encode/django-rest-framework.git
synced 2024-11-22 09:36:49 +03:00
OpenAPI: Use 201 status code for POST requests. (#7206)
This commit is contained in:
parent
2a5c2f3f70
commit
94a09149b6
|
@ -558,9 +558,9 @@ class AutoSchema(ViewInspector):
|
|||
response_schema = paginator.get_paginated_response_schema(response_schema)
|
||||
else:
|
||||
response_schema = item_schema
|
||||
|
||||
status_code = '201' if method == 'POST' else '200'
|
||||
return {
|
||||
'200': {
|
||||
status_code: {
|
||||
'content': {
|
||||
ct: {'schema': response_schema}
|
||||
for ct in self.response_media_types
|
||||
|
|
|
@ -275,9 +275,10 @@ class TestOperationIntrospection(TestCase):
|
|||
inspector.view = view
|
||||
|
||||
responses = inspector._get_responses(path, method)
|
||||
assert responses['200']['content']['application/json']['schema']['required'] == ['text']
|
||||
assert list(responses['200']['content']['application/json']['schema']['properties'].keys()) == ['text']
|
||||
assert 'description' in responses['200']
|
||||
assert '201' in responses
|
||||
assert responses['201']['content']['application/json']['schema']['required'] == ['text']
|
||||
assert list(responses['201']['content']['application/json']['schema']['properties'].keys()) == ['text']
|
||||
assert 'description' in responses['201']
|
||||
|
||||
def test_response_body_nested_serializer(self):
|
||||
path = '/'
|
||||
|
@ -302,7 +303,7 @@ class TestOperationIntrospection(TestCase):
|
|||
inspector.view = view
|
||||
|
||||
responses = inspector._get_responses(path, method)
|
||||
schema = responses['200']['content']['application/json']['schema']
|
||||
schema = responses['201']['content']['application/json']['schema']
|
||||
assert sorted(schema['required']) == ['nested', 'text']
|
||||
assert sorted(list(schema['properties'].keys())) == ['nested', 'text']
|
||||
assert schema['properties']['nested']['type'] == 'object'
|
||||
|
|
Loading…
Reference in New Issue
Block a user