fix: hoist inline string enums in array items to named enums#34
Open
lightsofapollo wants to merge 2 commits into
Open
fix: hoist inline string enums in array items to named enums#34lightsofapollo wants to merge 2 commits into
lightsofapollo wants to merge 2 commits into
Conversation
Array items with `type: string` + `enum` collapsed to `Vec<String>`
because analyze_array_schema mapped string items straight to a String
primitive, while property-level inline enums were already hoisted to
named StringEnum types.
Extract the property path's hoisting (naming, same-value dedup,
collision disambiguation) into hoist_inline_string_enum and route array
items through it, naming item enums `{Parent}Item`. Covers plain
arrays, anyOf-nullable arrays, and typeless OpenAPI 3.1 enum items.
Fixes #33
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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.
Fixes #33
Problem
Array items with
type: string+enumcollapsed toVec<String>:analyze_array_schemamapped string items straight to aStringprimitive, while property-level inline enums were already hoisted into namedStringEnumtypes byanalyze_property_schema_with_context.Fix
Extracted the property path's enum-hoisting logic (naming, same-value dedup, collision disambiguation with value/numeric suffixes) into a shared
hoist_inline_string_enumhelper, and routed array items through it. Item enums are named{Parent}Item, matching the existing{Parent}Itemconvention for inline objects in arrays:Covers the issue's exact
anyOf [array, null]repro, plain arrays of enums, and typeless OpenAPI 3.1 enum items (items: {enum: [...]}with notype). Plain string arrays are unchanged.Verification
tests/array_item_enum_test.rswith insta snapshotscargo test --all-features— 411 passed, 0 failed, no churn in existing snapshotscargo clippy --all-features -- -D warningsandcargo fmt --checkcleanREQUIRED_DEPS.toml, and verified a serde roundtrip through the new enum types🤖 Generated with Claude Code