Skip to content

Commit

Permalink
Fix Django OpenAPI Schema (#520)
Browse files Browse the repository at this point in the history
  • Loading branch information
williamputraintan authored Aug 27, 2024
1 parent 7375d3b commit e268d93
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
"description": "Terms of service",
"url": "https://umccr.org/",
},
'CAMELIZE_NAMES': False,
'CAMELIZE_NAMES': True,
'POSTPROCESSING_HOOKS': [
'drf_spectacular.contrib.djangorestframework_camel_case.camelize_serializer_fields',
'drf_spectacular.hooks.postprocess_schema_enums'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,10 @@ def list(self, request, *args, **kwargs):
def get_queryset(self):
return Library.objects.get_by_keyword(**self.request.query_params)

@extend_schema(responses={200: LibraryFullSerializer(many=True)})
@extend_schema(
parameters=[LibrarySerializer],
responses={200: LibraryFullSerializer(many=True)}
)
@action(detail=False, methods=['get'], url_path='full')
def get_full_model_set(self, request):
qs = Library.objects.select_related("specimen__subject").all().order_by("-library_id")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,9 @@
"description": "Terms of service",
"url": "https://umccr.org/",
},
'CAMELIZE_NAMES': True,
'POSTPROCESSING_HOOKS': [
'drf_spectacular.contrib.djangorestframework_camel_case.camelize_serializer_fields',
'drf_spectacular.hooks.postprocess_schema_enums'
],
}
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,9 @@
"description": "Terms of service",
"url": "https://umccr.org/",
},
'CAMELIZE_NAMES': True,
'POSTPROCESSING_HOOKS': [
'drf_spectacular.contrib.djangorestframework_camel_case.camelize_serializer_fields',
'drf_spectacular.hooks.postprocess_schema_enums'
],
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@


class LibraryViewSet(ReadOnlyModelViewSet):
lookup_value_regex = "[^/]+"
serializer_class = LibraryModelSerializer
pagination_class = StandardResultsSetPagination
filter_backends = [filters.OrderingFilter, filters.SearchFilter]
Expand Down

0 comments on commit e268d93

Please sign in to comment.