From 2caaf508793063cd8b7bcbf0c60210342f55a355 Mon Sep 17 00:00:00 2001 From: Sonny Bakker Date: Wed, 15 Jan 2025 15:34:44 +0100 Subject: [PATCH] [#513] add descriptions for nested endpoint Seems related to a update of drf-nested-routers>=0.93.4 --- src/objecttypes/api/v2/openapi.yaml | 120 ++-------------------------- src/objecttypes/api/v2/views.py | 26 +++++- 2 files changed, 30 insertions(+), 116 deletions(-) diff --git a/src/objecttypes/api/v2/openapi.yaml b/src/objecttypes/api/v2/openapi.yaml index e98846e1..3dff2a0a 100644 --- a/src/objecttypes/api/v2/openapi.yaml +++ b/src/objecttypes/api/v2/openapi.yaml @@ -111,25 +111,7 @@ paths: /objecttypes/{objecttype_uuid}/versions: get: operationId: objectversion_list - description: |- - Abstract base class for generic types. - - A generic type is typically declared by inheriting from - this class parameterized with one or more type variables. - For example, a generic mapping type might be defined as:: - - class Mapping(Generic[KT, VT]): - def __getitem__(self, key: KT) -> VT: - ... - # Etc. - - This class can then be used as follows:: - - def lookup_name(mapping: Mapping[KT, VT], key: KT, default: VT) -> VT: - try: - return mapping[key] - except KeyError: - return default + description: Retrieve all versions of an OBJECTTYPE parameters: - in: path name: objecttype_uuid @@ -163,25 +145,7 @@ paths: description: OK post: operationId: objectversion_create - description: |- - Abstract base class for generic types. - - A generic type is typically declared by inheriting from - this class parameterized with one or more type variables. - For example, a generic mapping type might be defined as:: - - class Mapping(Generic[KT, VT]): - def __getitem__(self, key: KT) -> VT: - ... - # Etc. - - This class can then be used as follows:: - - def lookup_name(mapping: Mapping[KT, VT], key: KT, default: VT) -> VT: - try: - return mapping[key] - except KeyError: - return default + description: Create an OBJECTTYPE with the given version. parameters: - in: header name: Content-Type @@ -217,25 +181,7 @@ paths: /objecttypes/{objecttype_uuid}/versions/{version}: get: operationId: objectversion_read - description: |- - Abstract base class for generic types. - - A generic type is typically declared by inheriting from - this class parameterized with one or more type variables. - For example, a generic mapping type might be defined as:: - - class Mapping(Generic[KT, VT]): - def __getitem__(self, key: KT) -> VT: - ... - # Etc. - - This class can then be used as follows:: - - def lookup_name(mapping: Mapping[KT, VT], key: KT, default: VT) -> VT: - try: - return mapping[key] - except KeyError: - return default + description: Retrieve an OBJECTTYPE with the given version. parameters: - in: path name: objecttype_uuid @@ -265,25 +211,7 @@ paths: description: OK put: operationId: objectversion_update - description: |- - Abstract base class for generic types. - - A generic type is typically declared by inheriting from - this class parameterized with one or more type variables. - For example, a generic mapping type might be defined as:: - - class Mapping(Generic[KT, VT]): - def __getitem__(self, key: KT) -> VT: - ... - # Etc. - - This class can then be used as follows:: - - def lookup_name(mapping: Mapping[KT, VT], key: KT, default: VT) -> VT: - try: - return mapping[key] - except KeyError: - return default + description: Update an OBJECTTYPE with the given version. parameters: - in: header name: Content-Type @@ -326,25 +254,7 @@ paths: description: OK patch: operationId: objectversion_partial_update - description: |- - Abstract base class for generic types. - - A generic type is typically declared by inheriting from - this class parameterized with one or more type variables. - For example, a generic mapping type might be defined as:: - - class Mapping(Generic[KT, VT]): - def __getitem__(self, key: KT) -> VT: - ... - # Etc. - - This class can then be used as follows:: - - def lookup_name(mapping: Mapping[KT, VT], key: KT, default: VT) -> VT: - try: - return mapping[key] - except KeyError: - return default + description: Partially update an OBJECTTYPE with the given version. parameters: - in: header name: Content-Type @@ -387,25 +297,7 @@ paths: description: OK delete: operationId: objectversion_delete - description: |- - Abstract base class for generic types. - - A generic type is typically declared by inheriting from - this class parameterized with one or more type variables. - For example, a generic mapping type might be defined as:: - - class Mapping(Generic[KT, VT]): - def __getitem__(self, key: KT) -> VT: - ... - # Etc. - - This class can then be used as follows:: - - def lookup_name(mapping: Mapping[KT, VT], key: KT, default: VT) -> VT: - try: - return mapping[key] - except KeyError: - return default + description: Destroy the given OBJECTTYPE. parameters: - in: path name: objecttype_uuid diff --git a/src/objecttypes/api/v2/views.py b/src/objecttypes/api/v2/views.py index 12849517..57e38035 100644 --- a/src/objecttypes/api/v2/views.py +++ b/src/objecttypes/api/v2/views.py @@ -42,8 +42,30 @@ def perform_destroy(self, instance): @extend_schema_view( - retrieve=extend_schema(operation_id="objectversion_read"), - destroy=extend_schema(operation_id="objectversion_delete"), + retrieve=extend_schema( + operation_id="objectversion_read", + description=_("Retrieve an OBJECTTYPE with the given version.") + ), + list=extend_schema( + operation_id="objectversion_list", + description=_("Retrieve all versions of an OBJECTTYPE") + ), + create=extend_schema( + operation_id="objectversion_create", + description=_("Create an OBJECTTYPE with the given version.") + ), + destroy=extend_schema( + operation_id="objectversion_delete", + description=_("Destroy the given OBJECTTYPE.") + ), + update=extend_schema( + operation_id="objectversion_update", + description=_("Update an OBJECTTYPE with the given version.") + ), + partial_update=extend_schema( + operation_id="objectversion_partial_update", + description=_("Partially update an OBJECTTYPE with the given version.") + ), ) class ObjectVersionViewSet(NestedViewSetMixin, viewsets.ModelViewSet): queryset = ObjectVersion.objects.order_by("object_type", "-version")