diff --git a/arkindex/process/api.py b/arkindex/process/api.py index 6606b187c41a8f1a1fe4105d848d8862beb94e5a..3360070fd049097764825e74548a629623d007f3 100644 --- a/arkindex/process/api.py +++ b/arkindex/process/api.py @@ -102,6 +102,7 @@ from arkindex.project.mixins import ( SelectionMixin, WorkerACLMixin, ) +from arkindex.project.openapi import UUID_OR_STR from arkindex.project.pagination import CustomCursorPagination from arkindex.project.permissions import IsVerified, IsVerifiedOrReadOnly from arkindex.project.tools import PercentileCont, RTrimChr @@ -802,6 +803,12 @@ class RevisionRetrieve(RepositoryACLMixin, RetrieveAPIView): type=str, description='Filter workers by name.', required=False, + ), + OpenApiParameter( + 'type', + type=UUID_OR_STR, + description='Filter workers by type, using either a type UUID or a type slug.', + required=False, ) ] ), diff --git a/arkindex/project/openapi/__init__.py b/arkindex/project/openapi/__init__.py index 8395399ef460d3b7893878c85c6069fb61b58ba6..d371a6cbb07ed472a9e6e933fa5cc8bb970230d3 100644 --- a/arkindex/project/openapi/__init__.py +++ b/arkindex/project/openapi/__init__.py @@ -14,3 +14,12 @@ UUID_OR_FALSE = { {'type': 'boolean', 'enum': [False]}, ] } + +# A JSON Schema that allows either an UUID or a string, to allow filtering by either an ID or a slug, for example +# when filtering by worker type. +UUID_OR_STR = { + 'oneOf': [ + {'type': 'string', 'format': 'uuid'}, + {'type': 'string'}, + ] +}