Skip to content

A community-supported supercharged document management system: scan, index and archive all your documents

Fix: fix the id__none schema in the right place (#14604)

shamoon11248f776d5b
diff --git a/src/documents/tests/test_api_schema.py b/src/documents/tests/test_api_schema.py
index 886e4bceb..f5c60e80d 100644
--- a/src/documents/tests/test_api_schema.py
+++ b/src/documents/tests/test_api_schema.py
@@ -308,3 +308,32 @@ class TestBulkDownloadSchema:
def test_bulk_download_response_403(self, api_schema: SchemaGenerator) -> None:
op = api_schema["paths"]["/api/documents/bulk_download/"]["post"]
assert "403" in op["responses"]
+
+
+class TestDocumentListObjectFilterSchema:
+ """documents_list: comma-separated ObjectFilter params must be typed as integer arrays."""
+
+ @pytest.mark.parametrize(
+ "param_name",
+ [
+ "tags__id__all",
+ "tags__id__none",
+ "tags__id__in",
+ "correspondent__id__none",
+ "document_type__id__none",
+ "storage_path__id__none",
+ "owner__id__none",
+ "custom_fields__id__all",
+ "custom_fields__id__none",
+ "custom_fields__id__in",
+ ],
+ )
+ def test_object_filter_param_is_integer_array(
+ self,
+ api_schema: SchemaGenerator,
+ param_name: str,
+ ) -> None:
+ params = api_schema["paths"]["/api/documents/"]["get"]["parameters"]
+ param = next(p for p in params if p["name"] == param_name)
+ assert param["schema"] == {"type": "array", "items": {"type": "integer"}}
+ assert param["explode"] is False
diff --git a/src/documents/views.py b/src/documents/views.py
index 5a4a78296..51dab2ecd 100644
--- a/src/documents/views.py
+++ b/src/documents/views.py
@@ -687,19 +687,6 @@ class EmailDocumentDetailSchema(EmailSerializer):
@extend_schema_view(
- list=extend_schema(
- parameters=[
- OpenApiParameter(
- name=name,
- type=OpenApiTypes.INT,
- many=True,
- style="form",
- explode=False,
- )
- for name, field in DocumentFilterSet.base_filters.items()
- if isinstance(field, ObjectFilter)
- ],
- ),
retrieve=extend_schema(
description="Retrieve a single document",
responses={
@@ -2470,6 +2457,17 @@ class ChatStreamingView(GenericAPIView[Any]):
list=extend_schema(
description="Document views including search",
parameters=[
+ *(
+ OpenApiParameter(
+ name=name,
+ type=OpenApiTypes.INT,
+ many=True,
+ style="form",
+ explode=False,
+ )
+ for name, field in DocumentFilterSet.base_filters.items()
+ if isinstance(field, ObjectFilter)
+ ),
OpenApiParameter(
name="text",
type=OpenApiTypes.STR,