Skip to content

docs(downgrader): note datamodel-code-generator writing an IntEnum for a mixed enum - #147

Merged
dinwwwh merged 3 commits into
mainfrom
claude/project-thread-mmrczx
Oct 27, 2026
Merged

dinwwwh merged 3 commits into
mainfrom
claude/project-thread-mmrczx

Conversation

@dinwwwh

@dinwwwh dinwwwh commented Oct 27, 2026

Copy link
Copy Markdown
Member

Requested by dinwwwh · project thread

Docs only. Adds two sentences to the datamodel-code-generator bullet in packages/downgrader/README.md.

A 3.1 type list with integer and an enum, such as Litestar's Literal["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 writes class G(IntEnum) for that, so importing the generated models raises ValueError: invalid literal for int() with base 10: 'a'. From the 3.1 input it writes one Enum, and the import works. I reproduced both results on current main.

Only an integer branch triggers it, so Valibot's mixed picklist (number) is fine. The per-type oneOf and bare enum shapes were already ruled out because they make NSwag, Kiota and oapi-codegen worse. An enum beside a type list that holds integer appears 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

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
@dinwwwh dinwwwh self-assigned this Oct 27, 2026
@codecov

codecov Bot commented Oct 27, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@codspeed

codspeed Bot commented Oct 27, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 21 untouched benchmarks


Comparing claude/project-thread-mmrczx (cfa65ab) with main (46cabee)

Open in CodSpeed

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ 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 IntEnum note — records that a 3.1 type list holding integer beside an enum, such as Litestar's Literal["a", 1], downgrades to an enum beside an anyOf, which datamodel-code-generator 0.86.0 reads as an IntEnum whose import then raises ValueError: 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).

Pullfrog  | View workflow run | Using deepseek-v4.1-flash (free via Pullfrog for OSS) | 𝕏

@dinwwwh
dinwwwh merged commit 5b91477 into main Oct 27, 2026
11 checks passed
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.

2 participants