| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Changepacks@devup-api/generator@0.1.25 → 0.1.26 - packages/generator/package.jsonPatch
@devup-api/next-plugin@0.1.14 → 0.1.15 - packages/next-plugin/package.jsonPatch
@devup-api/rsbuild-plugin@0.1.14 → 0.1.15 - packages/rsbuild-plugin/package.jsonPatch
@devup-api/vite-plugin@0.1.14 → 0.1.15 - packages/vite-plugin/package.jsonPatch
@devup-api/webpack-plugin@0.1.14 → 0.1.15 - packages/webpack-plugin/package.jsonPatch
|
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
Problem
OpenAPI 3.1 expresses a nullable $ref as a union with the JSON Schema null type:
{ "anyOf": [{ "$ref": "#/components/schemas/Item" }, { "type": "null" }] }The generator treated anyOf / oneOf as a plain union, so { "type": "null" } was
converted to unknown and the $ref lost its component identity:
(T | unknown) collapses to unknown in TypeScript, which is the reported
TS2322: Type 'unknown' is not assignable to .... On the zod side the result became a
ZodUnion, which has no .unwrap().
Fix
anyOf: [S, { type: "null" }] is 3.1's nullable notation, not a union. Two helpers in
openapi-utils.ts normalize it to the OpenAPI 3.0 equivalent { ...S, nullable: true }
before any union handling, so the existing nullable machinery applies unchanged:
preserving sibling keywords (description, default) and returning the input
unchanged when there is nothing to collapse
Applied on all three paths:
name lookup that fed postPathSchemas
reference shortcut and the raw-multipart check see the normalized schema
Unions that keep two or more members stay unions and now additionally reflect a removed
null member, so anyOf: [string, number, null] generates (string | number | null)
instead of (string | number | unknown).
Not regressed
(string | number) / z.union([...]) / z.ZodUnion<...>.
isNullableSchema() and are unchanged.
Tests
New nullable-union.test.ts asserts that every 3.1 nullable form generates a
byte-identical result to its 3.0 counterpart across generateInterface,
generateZodSchemas, and generateZodTypeDeclarations, in both a request-body and a
component-property position. Verified TDD: 14 of the new tests fail without the fix and
all 31 pass with it, while the genuine-union guards pass in both states.
bun test 1148 pass / 0 fail, 100% line and function coverage on all four changed files,
bun run lint and bun run build clean.