Minor Changes
-
beccbaaThanks @js2me! - AddtypeNameSeparatorconfig option for joiningtypePrefix, type name,
andtypeSuffixinTypeNameFormatter.This separator is primarily effective with
disableFormatTypeNames: true,
or when customhooks.onFormatTypeNamepreserves separators without
normalization. -
162739aThanks @js2me! - AdddisableFormatTypeNamesoption to disable type name formatting
and normalization in the generator.When enabled, generated names keep raw separators (for example,
Foo_BarstaysFoo_Bar), which prevents collisions caused by
startCase-based normalization (such asFoo_BarandFooBar
both becomingFooBar).The option is available in config and via CLI as
--disable-format-type-names, and is covered by a dedicated
spec test intests/spec/disableFormatTypeNames.
Patch Changes
-
#1726
1b60264Thanks @mlewando-cp! - Dedupe colliding TypeScript identifiers produced by theTypeNameFormatter.Two OpenAPI schema keys that differ only in separator placement — e.g.
Foo_BarandFooBar— used to collapse to the same identifier via
startCase+ whitespace-strip and emit twoexport interface FooBar
declarations (TS2717 whenever the shapes differed).TypeNameFormatternow exposes aprecommit(rawNames)method the generator
calls once after loading schema components and before schema parsing. It
resolves every raw name in two passes — canonical names (raw === formatted
output) claim their slot first, then non-canonical names suffix-until-free —
so user-declared identifiers likeFooBar1are preserved regardless of
source order, and collisions deterministically produceFooBar,FooBar1,
FooBar2, … References to each schema (including inline generics in route
handlers) stay consistent with the emittedexport interfacedeclarations.format()is now a pure cache lookup with a fallback for names discovered
after precommit (enum keys,extractEnums/extractResponsesresults). All
formatting logic is concentrated in a single privatecomputeFormattedName
helper, so the new behavior composes cleanly withdisableFormatTypeNames
andtypeNameSeparator.Fixes #1724.