-
-
Notifications
You must be signed in to change notification settings - Fork 528
inline combined types by default, add useCombinedTypeAliases opt-out
#2654
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
inline combined types by default, add useCombinedTypeAliases opt-out
#2654
Conversation
…on types
When enabled, combined types (anyOf/oneOf/allOf) are inlined instead of
creating intermediate type aliases like ResponseAnyOf, MyObjectField.
- Add inlineCombinedTypes option (default: false for backward compatibility)
- Skip intermediate propName generation in combineSchemas when enabled
- Use conditional regex in resolveObject to only match '{' when enabled
|
As the real world example in the PR description shows, such an option could cut down some excessive single-use types for a project I'm working on (where the generated file is still growing fast). Let me know if you think this is a good idea or not. |
|
@anymaniax @soartec-lab what do you think? I am all for less generated code... |
|
@superxiao @melloware |
|
agreed this should be the default. |
|
@superxiao can you make this the default |
- Rename flag from inlineCombinedTypes to useCombinedTypeAliases - Default to false (inline by default, opt-in to create aliases) - Simplify logic: if (useCombinedTypeAliases) instead of === false check - Update tests to verify default behavior with unmodified context
inlineCombinedTypes option to reduce intermediate type aliasesuseCombinedTypeAliases opt-out
|
PR has been updated to make the inlining default behavior. New option is renamed from |
|
This is fantastic! |
|
@superxiao |
Breaking change: Inlines combined types by default, cleaning up generated types by removing unnecessary intermediate type aliases.
Helps with #1644 - eliminates verbose names like
ListOfActivitiesResponseAnyOfDataAnyOfItem....Estimated impact on a real project:
Fewer intermediate types means better readability and potentially faster type inference.
The change handles two cases:
1. Intermediate object types - things like
ResponseAnyOf,ResponseOneOfTwogo away:2. Primitive union properties - explicit
anyOf/oneOfwith primitives get inlined:Set
useCombinedTypeAliases: trueto restore the old behavior of creating intermediate type aliases.Property-level inline objects still get named types (complex types benefit from a name anyway):