From 3e81c7a3d8fd27de8c7e269848495a9089771103 Mon Sep 17 00:00:00 2001 From: mlbonhomme <bonhomme@teklia.com> Date: Mon, 12 Jun 2023 13:21:49 +0200 Subject: [PATCH] Document worker type filter --- arkindex/process/api.py | 7 +++++++ arkindex/project/openapi/__init__.py | 9 +++++++++ 2 files changed, 16 insertions(+) diff --git a/arkindex/process/api.py b/arkindex/process/api.py index 6606b187c4..3360070fd0 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 8395399ef4..d371a6cbb0 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'}, + ] +} -- GitLab