Skip to content

fix(generate): type integer enums closed and prefix underscore schemas with Field - #28

Merged
jm-rivera merged 1 commit into
mainfrom
fix/wire-integer-enums
Nov 1, 2026
Merged

jm-rivera merged 1 commit into
mainfrom
fix/wire-integer-enums

Conversation

@jm-rivera

@jm-rivera jm-rivera commented Nov 1, 2026 •

Copy link
Copy Markdown
Contributor

The TypeScript wire generator can now read the served document in spec-kit#44, which it refused twice. That document carries EnrichmentOptionModel.in_long_layout, which the website needs typed.

Changes

  • openEnums in typescript/scripts/generate-wire.ts leaves an enum holding a value other than a string or null to openapi-typescript, so _Ref.format_version (enum 1, 2) reads 1 | 2, matching Literal[1, 2] in the Python wire.py. String enums stay open as before. The generator used to throw "an enum holds a value other than a string or null".
  • aliasName prefixes Field to a schema name that starts with an underscore, so _ExportFrame exports as FieldExportFrame beside ExportFrame, as datamodel-code-generator names it in Python. The two used to collide and stop the generator.
  • typescript/test/generate-wire.test.ts, one test per rule, each failing without its change. CONTRIBUTING.md states both rules.

Notes for reviewers

The contract stays at 5132aa0, which has neither an integer enum nor an underscore schema, so src/generated/openapi.ts is unchanged and generate:check passes. The contract bump to the spec-kit#44 commit follows once dfo-apis pins it. Against that document, generate, typecheck and build pass, and four tests fail on re-recorded fixture data (answer-choose-candidate-two-parts.json, candidate readings, a nested spec in strict.test.ts), which the bump has to update.

Testing: pnpm lint, pnpm typecheck, pnpm generate:check, pnpm test (2,064 passed) and pnpm build pass at contract 5132aa0. Both new tests fail with the generator reverted. pnpm generate against spec-kit e497889 writes format_version: 1 | 2, in_long_layout?: boolean and FieldRef, and that output was discarded.

…s with Field

The wire generator refused an enum holding a value other than a string
or null, so it could not read a served document with the derived ref's
integer `_Ref.format_version` (enum 1, 2). `openEnums` now leaves such
an enum to openapi-typescript, which writes its closed literal union,
`1 | 2`, as the Python wire types write `Literal[1, 2]`.

The same document names `_ExportFrame` beside `ExportFrame`, which
shared one alias. A schema whose name starts with an underscore now
takes the prefix `Field`, so `_ExportFrame` is `FieldExportFrame`, as
in Python.
@jm-rivera
jm-rivera marked this pull request as ready for review November 1, 2026 09:48
@jm-rivera
jm-rivera merged commit 7adfa77 into main Nov 1, 2026
5 checks passed
@jm-rivera
jm-rivera deleted the fix/wire-integer-enums branch November 1, 2026 09:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant