Repository navigation
docs(downgrader): note datamodel-code-generator writing an IntEnum for a mixed enum - #147
Conversation
typia writes a nullable tagged union as a oneOf with a discriminator
mapping beside the null branch. oapi-codegen 2.8.1 wants every branch
there other than { type: "null" } to be a $ref, so it fails on our
3.0 null branch with "ambiguous discriminator.mapping". It reads 3.1
too, which keeps { type: "null" }.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VVaw7QuAPaCNmVAw2a3fuB
…r a mixed enum A 3.1 type list with integer and an enum, such as Litestar's Literal["a", 1], becomes an enum beside an anyOf with an integer branch in 3.0. datamodel-code-generator writes an IntEnum for it, so importing its models fails when the enum holds a string. It reads 3.1 too, which keeps the type list. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VVaw7QuAPaCNmVAw2a3fuB
…to claude/project-thread-mmrczx
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
Docs-only change to packages/downgrader/README.md (one line appended to the datamodel-code-generator bullet). I verified the claim end-to-end rather than taking it on trust.
- datamodel-code-generator
IntEnumnote — records that a 3.1typelist holdingintegerbeside anenum, such as Litestar'sLiteral["a", 1], downgrades to anenumbeside ananyOf, which datamodel-code-generator 0.86.0 reads as anIntEnumwhose import then raisesValueError: invalid literal for int() with base 10: 'a'.
Verification: a downgradeSchemaV31ToV30 probe produced exactly { enum: ["a", 1], anyOf: [{ type: "integer" }, { type: "string" }] }; datamodel-code-generator==0.86.0 emitted class G1(IntEnum) and failed to import for that shape, emitted a single Enum with a clean import for the 3.1 input, and emitted Enum (not IntEnum) when the branch is number — so the note's integer specificity is correct. uncheck packages/downgrader/README.md passes (oxlint + oxfmt).
deepseek-v4.1-flash (free via Pullfrog for OSS) | 𝕏

Requested by dinwwwh · project thread
Docs only. Adds two sentences to the datamodel-code-generator bullet in
packages/downgrader/README.md.A 3.1
typelist withintegerand anenum, such as Litestar'sLiteral["a", "b", 1]({ type: ["integer", "string"], enum: ["a", "b", 1] }), becomes{ enum: [...], anyOf: [{ type: "integer" }, { type: "string" }] }in 3.0. datamodel-code-generator 0.86.0 writesclass G(IntEnum)for that, so importing the generated models raisesValueError: invalid literal for int() with base 10: 'a'. From the 3.1 input it writes oneEnum, and the import works. I reproduced both results on current main.Only an
integerbranch triggers it, so Valibot's mixedpicklist(number) is fine. The per-typeoneOfand bareenumshapes were already ruled out because they make NSwag, Kiota and oapi-codegen worse. Anenumbeside atypelist that holdsintegerappears in only 2 of about 11,750 corpus documents. So it gets a README note, not a change to the converter.Generated by Claude Code