|
@@ -5,6 +5,7 @@ from drf_yasg.utils import get_serializer_ref_name
|
|
|
from rest_framework.fields import ChoiceField
|
|
from rest_framework.fields import ChoiceField
|
|
|
from rest_framework.relations import ManyRelatedField
|
|
from rest_framework.relations import ManyRelatedField
|
|
|
|
|
|
|
|
|
|
+from extras.api.customfields import CustomFieldsDataField
|
|
|
from utilities.api import ChoiceField, SerializedPKRelatedField, WritableNestedSerializer
|
|
from utilities.api import ChoiceField, SerializedPKRelatedField, WritableNestedSerializer
|
|
|
|
|
|
|
|
|
|
|
|
@@ -60,6 +61,17 @@ class NullableBooleanFieldInspector(FieldInspector):
|
|
|
return result
|
|
return result
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
+class CustomFieldsDataFieldInspector(FieldInspector):
|
|
|
|
|
+
|
|
|
|
|
+ def field_to_swagger_object(self, field, swagger_object_type, use_references, **kwargs):
|
|
|
|
|
+ SwaggerType, ChildSwaggerType = self._get_partial_types(field, swagger_object_type, use_references, **kwargs)
|
|
|
|
|
+
|
|
|
|
|
+ if isinstance(field, CustomFieldsDataField) and swagger_object_type == openapi.Schema:
|
|
|
|
|
+ return SwaggerType(type=openapi.TYPE_OBJECT)
|
|
|
|
|
+
|
|
|
|
|
+ return NotHandled
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
class JSONFieldInspector(FieldInspector):
|
|
class JSONFieldInspector(FieldInspector):
|
|
|
"""Required because by default, Swagger sees a JSONField as a string and not dict
|
|
"""Required because by default, Swagger sees a JSONField as a string and not dict
|
|
|
"""
|
|
"""
|