diff --git a/rest_framework/schemas/openapi.py b/rest_framework/schemas/openapi.py index 0fd33cd11..a3970ff7a 100644 --- a/rest_framework/schemas/openapi.py +++ b/rest_framework/schemas/openapi.py @@ -344,6 +344,7 @@ class AutoSchema(ViewInspector): serializers.BooleanField: 'boolean', serializers.JSONField: 'object', serializers.DictField: 'object', + serializers.HStoreField: 'object', } return {'type': FIELD_CLASS_SCHEMA_TYPE.get(field.__class__, 'string')} diff --git a/tests/schemas/test_openapi.py b/tests/schemas/test_openapi.py index e1d29f6fe..78c00d985 100644 --- a/tests/schemas/test_openapi.py +++ b/tests/schemas/test_openapi.py @@ -462,6 +462,22 @@ class TestOperationIntrospection(TestCase): assert properties['date']['format'] == 'date' assert properties['datetime']['format'] == 'date-time' + def test_serializer_hstorefield(self): + path = '/' + method = 'GET' + view = create_view( + views.ExampleGenericAPIView, + method, + create_request(path), + ) + inspector = AutoSchema() + inspector.view = view + + responses = inspector._get_responses(path, method) + response_schema = responses['200']['content']['application/json']['schema'] + properties = response_schema['items']['properties'] + assert properties['hstore']['type'] == 'object' + def test_serializer_validators(self): path = '/' method = 'GET' diff --git a/tests/schemas/views.py b/tests/schemas/views.py index d1fc75eb8..6b83e5bde 100644 --- a/tests/schemas/views.py +++ b/tests/schemas/views.py @@ -33,6 +33,7 @@ class ExampleDetailView(APIView): class ExampleSerializer(serializers.Serializer): date = serializers.DateField() datetime = serializers.DateTimeField() + hstore = serializers.HStoreField() class ExampleGenericAPIView(generics.GenericAPIView):