Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/objects/api/v2/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -858,6 +858,8 @@ components:
minimum: 0
description: Version of the OBJECTTYPE for data in the object record
data:
type: object
additionalProperties: true
description: Object data, based on OBJECTTYPE
geometry:
allOf:
Expand Down Expand Up @@ -1016,6 +1018,8 @@ components:
minimum: 0
description: Version of the OBJECTTYPE for data in the object record
data:
type: object
additionalProperties: true
description: Object data, based on OBJECTTYPE
geometry:
allOf:
Expand Down Expand Up @@ -1178,6 +1182,8 @@ components:
type: boolean
description: Use field-based authorization
fields:
type: object
additionalProperties: true
nullable: true
title: Mode
description: Fields allowed for this token in relation to objecttype versions.
Expand Down
7 changes: 7 additions & 0 deletions src/objects/utils/apps.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
from django.apps import AppConfig
from django.db import models

from drf_spectacular.extensions import OpenApiFilterExtension
from rest_framework.serializers import ModelSerializer

from .fields import JSONObjectField


def unregister_camelize_filter_extension():
Expand All @@ -23,3 +27,6 @@ def ready(self):
from . import oas_extensions # noqa

unregister_camelize_filter_extension()

field_mapping = ModelSerializer.serializer_field_mapping
field_mapping[models.JSONField] = JSONObjectField
9 changes: 9 additions & 0 deletions src/objects/utils/fields.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
from drf_spectacular.utils import extend_schema_field
from rest_framework import serializers


@extend_schema_field({"type": "object", "additionalProperties": True})
class JSONObjectField(serializers.JSONField):
"""
serializers.JSONField does not have a type by default and will show `any` in api spec.
"""