1
0
mirror of https://github.com/netbox-community/netbox.git synced 2024-05-10 07:54:54 +00:00

Replace custom JSONField inspector with the one from drf_yasg

This commit is contained in:
Andreas Nieß
2022-08-28 21:03:18 +02:00
parent 83db8d2072
commit cd6911f83c
2 changed files with 1 additions and 11 deletions

View File

@@ -1,4 +1,3 @@
from django.contrib.postgres.fields import JSONField
from drf_yasg import openapi
from drf_yasg.inspectors import FieldInspector, NotHandled, PaginatorInspector, SwaggerAutoSchema
from drf_yasg.utils import get_serializer_ref_name
@@ -131,15 +130,6 @@ class CustomFieldsDataFieldInspector(FieldInspector):
return NotHandled
class JSONFieldInspector(FieldInspector):
"""Required because by default, Swagger sees a JSONField as a string and not dict
"""
def process_result(self, result, method_name, obj, **kwargs):
if isinstance(result, openapi.Schema) and isinstance(obj, JSONField):
result.type = 'dict'
return result
class NullablePaginatorInspector(PaginatorInspector):
def process_result(self, result, method_name, obj, **kwargs):
if method_name == 'get_paginated_response' and isinstance(result, openapi.Schema):