diff --git a/src/documents/tests/test_api_schema.py b/src/documents/tests/test_api_schema.py index 4e44963de..78e6e3a6d 100644 --- a/src/documents/tests/test_api_schema.py +++ b/src/documents/tests/test_api_schema.py @@ -102,3 +102,23 @@ class TestTasksSummarySchema: assert "total_count" in props, ( "summary items must have 'total_count' (TaskSummarySerializer)" ) + + +class TestTasksActiveSchema: + """tasks_active_retrieve: response must be an array of TaskSerializerV10.""" + + def test_active_response_is_array(self, api_schema): + op = api_schema["paths"]["/api/tasks/active/"]["get"] + resp_200 = op["responses"]["200"]["content"]["application/json"]["schema"] + assert resp_200["type"] == "array", ( + "tasks_active_retrieve response must be type:array" + ) + + def test_active_items_ref_named_schema(self, api_schema): + op = api_schema["paths"]["/api/tasks/active/"]["get"] + resp_200 = op["responses"]["200"]["content"]["application/json"]["schema"] + items = resp_200.get("items", {}) + ref = items.get("$ref", "") + component_name = ref.split("/")[-1] if ref else "" + assert component_name, "items should be a $ref to a named schema" + assert component_name in api_schema["components"]["schemas"] diff --git a/src/documents/views.py b/src/documents/views.py index 104999987..ed281a0e1 100644 --- a/src/documents/views.py +++ b/src/documents/views.py @@ -3795,6 +3795,10 @@ class RemoteVersionView(GenericAPIView[Any]): ), ], ), + active=extend_schema( + description="Currently pending and running tasks (capped at 50).", + responses={200: TaskSerializerV10(many=True)}, + ), ) class TasksViewSet(ReadOnlyModelViewSet[PaperlessTask]): permission_classes = (IsAuthenticated, PaperlessObjectPermissions)