typespec-http-zod 0.12.0 → 0.12.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/api.js +21 -0
- package/package.json +1 -1
package/dist/src/api.js
CHANGED
|
@@ -1360,7 +1360,28 @@ function responseArmsOf(route, response, alternate) {
|
|
|
1360
1360
|
* declares. Each arm resolves its own body now, so an arm with no schema is a response the document
|
|
1361
1361
|
* says carries no body, and saying `undefined` is the truthful answer rather than a guess.
|
|
1362
1362
|
*/
|
|
1363
|
+
/**
|
|
1364
|
+
* **An error arm whose status the primary arm already answers is dropped, primary winning.**
|
|
1365
|
+
*
|
|
1366
|
+
* `errorArmsOf` excludes 2xx from the failure arms, so widening the primary to include 3xx made a
|
|
1367
|
+
* redirect BOTH: `[{ status: 302, schema: undefined, headers: [...] }, { status: 302, schema:
|
|
1368
|
+
* undefined }]`, two arms for one status where the second shadows the first's headers for anything
|
|
1369
|
+
* scanning past the first match.
|
|
1370
|
+
*
|
|
1371
|
+
* Widening `isSuccessKey` to match would be wrong in the other direction: an operation declaring a
|
|
1372
|
+
* 200 AND a 302 has 200 as its primary, so the 302 must stay a failure arm to be emitted at all.
|
|
1373
|
+
* Deduplicating here keeps both cases, because it asks what was actually emitted rather than what
|
|
1374
|
+
* might have been.
|
|
1375
|
+
*/
|
|
1376
|
+
const emitted = new Set();
|
|
1377
|
+
for (const arm of arms) {
|
|
1378
|
+
const status = /status: ([^,}]+)/.exec(arm)?.[1]?.trim();
|
|
1379
|
+
if (status !== undefined)
|
|
1380
|
+
emitted.add(status);
|
|
1381
|
+
}
|
|
1363
1382
|
for (const arm of route.errorArms) {
|
|
1383
|
+
if (emitted.has(String(arm.status)) || emitted.has(JSON.stringify(arm.status)))
|
|
1384
|
+
continue;
|
|
1364
1385
|
arms.push(`{ status: ${JSON.stringify(arm.status)}, schema: ${arm.schema ?? "undefined"} }`);
|
|
1365
1386
|
}
|
|
1366
1387
|
return `[${arms.join(", ")}]`;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "typespec-http-zod",
|
|
3
|
-
"version": "0.12.
|
|
3
|
+
"version": "0.12.1",
|
|
4
4
|
"description": "TypeSpec emitter and library: turn an HTTP service definition into Zod validators and framework-free contract types that agree, keyword for keyword, with the OpenAPI document @typespec/openapi3 publishes from the same source.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"codegen",
|