Skip to content

fix(typescript-fetch): skip scalar enum comparison for array-typed properties in instanceOf#24217

Merged
wing328 merged 2 commits into
OpenAPITools:masterfrom
mstojanovic8:fix/typescript-fetch-instanceof-array-enum
Jul 7, 2026
Merged

fix(typescript-fetch): skip scalar enum comparison for array-typed properties in instanceOf#24217
wing328 merged 2 commits into
OpenAPITools:masterfrom
mstojanovic8:fix/typescript-fetch-instanceof-array-enum

Conversation

@mstojanovic8

@mstojanovic8 mstojanovic8 commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

Required properties typed as Array<SingleValueEnum> triggered two bugs in the instanceOf guard (side effect of #23497):

  1. The enum-literal check fired for array properties — comparing value['types'] !== 'x' against an array is always truthy, permanently breaking instanceOf.
  2. For array properties, isString resolves against the container type (Array), not the item type, so the literal was emitted unquoted (boatbooker_activities instead of 'boatbooker_activities'), causing TS2304: Cannot find name.

Fix: wrap the enum-literal block in {{^isContainer}} so it only fires for scalar properties. Scalar enum behavior is unchanged.


Apologies for the burst of PRs in a short time — we are integrating this generator into production at FishingBooker and kept uncovering issues along the way.
Also sorry for skipping a prior issue on this one; if a release is coming soon we'd love to see it included. Happy to open a follow-up issue if preferred.

Fixes a regression introduced by #23497.

PR checklist

  • Read the contribution guidelines.
  • Ran unit tests: ./mvnw test -pl modules/openapi-generator -Dtest=TypeScriptFetchClientCodegenTest
  • Regenerated typescript-fetch samples: ./bin/generate-samples.sh ./bin/configs/typescript-fetch*
  • @mention the technical committee members.

cc @TiFu @taxpon @sebastianhaas @kenisteward @Vrolijkx @macjohnny @topce @akehir @petejohansonxo @amakhrov @davidgamero @mkusaka @joscha @dennisameling


Summary by cubic

Fixes the instanceOf guard in typescript-fetch to skip scalar enum comparisons for array-typed enum properties (e.g., Array<SingleValueEnum>), preventing false negatives and TypeScript literal name errors. Scalar enum behavior is unchanged.

  • Bug Fixes
    • Wrapped the enum-literal check with {{^isContainer}} in modelGeneric.mustache so array enums no longer emit invalid !== comparisons or unquoted literals.
    • Added a test (testInstanceOfArrayEnumNoScalarComparison) with a minimal OpenAPI fixture to verify no scalar comparison is emitted and the field presence check remains.

Written for commit 6018a9d. Summary will update on new commits.

Review in cubic

…ies in instanceOf

  The instanceOf guard was emitting an invalid scalar !== comparison for
  required properties typed as Array<SingleValueEnum>, introduced as a
  side effect of PR OpenAPITools#23497. The enum-literal check block now only fires
  for non-container (scalar) properties

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

No issues found across 4 files

Re-trigger cubic

@wing328

wing328 commented Jul 7, 2026

Copy link
Copy Markdown
Member

tested locally and the change looks good.

thanks for the fix

@wing328 wing328 added this to the 7.24.0 milestone Jul 7, 2026
@wing328 wing328 merged commit 4e35b66 into OpenAPITools:master Jul 7, 2026
15 checks passed
@wing328

wing328 commented Jul 7, 2026

Copy link
Copy Markdown
Member

cc @jasperpatterson who's the author of #23497.

@wing328

wing328 commented Jul 7, 2026

Copy link
Copy Markdown
Member

Apologies for the burst of PRs in a short time — we are integrating this generator into production at FishingBooker and kept uncovering issues along the way.

We appreciate you and your team contributing back to make this project better.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants