|
19 | 19 | from unittest.mock import AsyncMock, MagicMock, patch |
20 | 20 |
|
21 | 21 | import pytest |
22 | | -from fastapi import HTTPException, Request |
| 22 | +from fastapi import FastAPI, HTTPException, Request |
23 | 23 | from fastapi.responses import JSONResponse |
24 | 24 | from temporalio.client import Client |
25 | 25 | from temporalio.common import TypedSearchAttributes, WorkflowIDReusePolicy |
|
37 | 37 | ) |
38 | 38 | from tracecat.storage.utils import deserialize_object |
39 | 39 | from tracecat.webhooks.router import _incoming_webhook, incoming_webhook_wait |
| 40 | +from tracecat.webhooks.router import router as webhook_router |
40 | 41 | from tracecat.workflow.executions.enums import ( |
41 | 42 | ExecutionType, |
42 | 43 | TemporalSearchAttr, |
@@ -1051,6 +1052,22 @@ async def test_wait_webhook_unwrap_returns_413_for_collection_object(self): |
1051 | 1052 | assert detail["kind"] == "download_export" |
1052 | 1053 | assert detail["download_url"] == "https://example.com/presigned/collection" |
1053 | 1054 |
|
| 1055 | + def test_wait_webhook_openapi_keeps_default_200_schema_enveloped(self): |
| 1056 | + """The default /wait 200 schema should stay discriminated for generated clients.""" |
| 1057 | + app = FastAPI() |
| 1058 | + app.include_router(webhook_router) |
| 1059 | + |
| 1060 | + responses = app.openapi()["paths"]["/webhooks/{workflow_id}/{secret}/wait"][ |
| 1061 | + "post" |
| 1062 | + ]["responses"] |
| 1063 | + success_schema = responses["200"]["content"]["application/json"]["schema"] |
| 1064 | + overflow_schema = responses["413"]["content"]["application/json"]["schema"] |
| 1065 | + |
| 1066 | + assert success_schema == {"$ref": "#/components/schemas/WaitResultOutput"} |
| 1067 | + assert overflow_schema == { |
| 1068 | + "$ref": "#/components/schemas/WaitResultUnwrapOverflowResponse" |
| 1069 | + } |
| 1070 | + |
1054 | 1071 |
|
1055 | 1072 | # --------------------------------------------------------------------------- |
1056 | 1073 | # _dispatch_workflow invariants (for /wait webhook endpoint) |
|
0 commit comments