fix(typescript-angular): generate union for oneOf models with taggedUnions
With taggedUnions=true model that is plain oneOf without discriminator is generated as empty interface, for spec from issue zooInner.ts gets export interface ZooInner { } instead of export type ZooInner = Cat | Dog;, so narrowing on z.type fails with TS2339
Without taggedUnions same model is allready union
When option is on model.mustache sends every model except enums and aliases to modelTaggedUnion.mustache, and there branch for model without discriminator and parent renders only modelGeneric
Now that branch picks modelOneOf for oneOf models, same check model.mustache does when option is off, models with discriminator or parent are not touched
Added testTaggedUnionsOneOfWithoutDiscriminator with spec from issue, it fails on master
Client generated from that spec now compiles with strict tsc, narrowing on type included
Sample config with taggedUnions (composed-schemas) has no oneOf, so regenerated typescript-angular samples have no diff
Fixes #20859
PR checklist
- Read the contribution guidelines.
- Run the following to build the project and update samples:
Commit all changed files../mvnw clean package || exit ./bin/generate-samples.sh ./bin/configs/*.yaml || exit ./bin/utils/export_docs_generators.sh || exit - If your PR is targeting a particular programming language, @mention the technical committee members, so they are more likely to review the pull request.
@TiFu @taxpon @sebastianhaas @kenisteward @Vrolijkx @macjohnny @topce @akehir @petejohansonxo @amakhrov @davidgamero @mkusaka @joscha @KannaKim
Summary by cubic
Fixes typescript-angular generating an empty interface for oneOf models without a discriminator when taggedUnions=true is enabled, instead of a union type like export type ZooInner = Cat | Dog;. This caused type narrowing on z.type to fail with TS2339.
The tagged union template now falls back to the standard oneOf generation for models that have oneOf but no discriminator or parent; models with a discriminator or parent are unchanged. Adds a regression test with the spec from issue #20859.