Skip to content

Commit

Permalink
[#513] add descriptions for nested endpoint
Browse files Browse the repository at this point in the history
Seems related to a update of drf-nested-routers>=0.93.4
  • Loading branch information
Sonny Bakker committed Jan 15, 2025
1 parent 76dfd3e commit 2caaf50
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 116 deletions.
120 changes: 6 additions & 114 deletions src/objecttypes/api/v2/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
26 changes: 24 additions & 2 deletions src/objecttypes/api/v2/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down

0 comments on commit 2caaf50

Please sign in to comment.