Repository navigation
fix(generate): type integer enums closed and prefix underscore schemas with Field - #28
Merged
Merged
Conversation
…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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
openEnumsintypescript/scripts/generate-wire.tsleaves an enum holding a value other than a string or null to openapi-typescript, so_Ref.format_version(enum 1, 2) reads1 | 2, matchingLiteral[1, 2]in the Pythonwire.py. String enums stay open as before. The generator used to throw "an enum holds a value other than a string or null".aliasNameprefixesFieldto a schema name that starts with an underscore, so_ExportFrameexports asFieldExportFramebesideExportFrame, 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.mdstates both rules.Notes for reviewers
The contract stays at
5132aa0, which has neither an integer enum nor an underscore schema, sosrc/generated/openapi.tsis unchanged andgenerate:checkpasses. 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 instrict.test.ts), which the bump has to update.Testing:
pnpm lint,pnpm typecheck,pnpm generate:check,pnpm test(2,064 passed) andpnpm buildpass at contract5132aa0. Both new tests fail with the generator reverted.pnpm generateagainst spec-kite497889writesformat_version: 1 | 2,in_long_layout?: booleanandFieldRef, and that output was discarded.