From b698cf1fd8567d09f25d00207bfafb2c2c70a242 Mon Sep 17 00:00:00 2001 From: Kentalot Date: Wed, 29 Jan 2020 11:41:33 -0800 Subject: [PATCH] Update openapi.py to include a type of object to anything that requires 'properties' during schema generation (_map_serializer method). Also, fix unit tests. --- rest_framework/schemas/openapi.py | 1 + tests/schemas/test_openapi.py | 3 +++ 2 files changed, 4 insertions(+) diff --git a/rest_framework/schemas/openapi.py b/rest_framework/schemas/openapi.py index fa887d63a..9c6610eaf 100644 --- a/rest_framework/schemas/openapi.py +++ b/rest_framework/schemas/openapi.py @@ -413,6 +413,7 @@ class AutoSchema(ViewInspector): properties[field.field_name] = schema result = { + 'type': 'object', 'properties': properties } if required: diff --git a/tests/schemas/test_openapi.py b/tests/schemas/test_openapi.py index b4cb2823f..0bee0a167 100644 --- a/tests/schemas/test_openapi.py +++ b/tests/schemas/test_openapi.py @@ -335,6 +335,7 @@ class TestOperationIntrospection(TestCase): 'schema': { 'type': 'array', 'items': { + 'type': 'object', 'properties': { 'text': { 'type': 'string', @@ -386,6 +387,7 @@ class TestOperationIntrospection(TestCase): 'item': { 'type': 'array', 'items': { + 'type': 'object', 'properties': { 'text': { 'type': 'string', @@ -532,6 +534,7 @@ class TestOperationIntrospection(TestCase): 'content': { 'application/json': { 'schema': { + 'type': 'object', 'properties': { 'text': { 'type': 'string',