Skip to content

fix(shared): support non-string discriminator property types#3385

Open
SipanP wants to merge 3 commits intohey-api:mainfrom
SipanP:fix/discriminator-non-string-type-support
Open

fix(shared): support non-string discriminator property types#3385
SipanP wants to merge 3 commits intohey-api:mainfrom
SipanP:fix/discriminator-non-string-type-support

Conversation

@SipanP
Copy link

@SipanP SipanP commented Feb 12, 2026

OpenAPI discriminator mappings use string keys, but the actual discriminator property may be boolean, integer, or number. Previously, all discriminator values were hardcoded as type 'string'. This change detects the actual property type from the schema and converts mapping values accordingly.

@bolt-new-by-stackblitz
Copy link

Review PR in StackBlitz Codeflow Run & review this pull request in StackBlitz Codeflow.

@vercel
Copy link

vercel bot commented Feb 12, 2026

@SipanP is attempting to deploy a commit to the Hey API Team on Vercel.

A member of the Team first needs to authorize it.

@changeset-bot
Copy link

changeset-bot bot commented Feb 12, 2026

🦋 Changeset detected

Latest commit: 53413ef

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 3 packages
Name Type
@hey-api/shared Patch
@hey-api/openapi-python Patch
@hey-api/openapi-ts Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@dosubot dosubot bot added size:XL This PR changes 500-999 lines, ignoring generated files. bug 🔥 Broken or incorrect behavior. labels Feb 12, 2026
@codecov
Copy link

codecov bot commented Feb 12, 2026

Codecov Report

❌ Patch coverage is 3.57143% with 81 lines in your changes missing coverage. Please review.
✅ Project coverage is 39.43%. Comparing base (a55a5e1) to head (53413ef).

Files with missing lines Patch % Lines
packages/shared/src/openApi/3.1.x/parser/schema.ts 2.94% 23 Missing and 10 partials ⚠️
packages/shared/src/openApi/3.0.x/parser/schema.ts 3.70% 18 Missing and 8 partials ⚠️
...s/shared/src/openApi/shared/utils/discriminator.ts 4.34% 18 Missing and 4 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3385      +/-   ##
==========================================
- Coverage   39.59%   39.43%   -0.17%     
==========================================
  Files         473      473              
  Lines       17080    17158      +78     
  Branches     5224     5267      +43     
==========================================
+ Hits         6763     6766       +3     
- Misses       8266     8319      +53     
- Partials     2051     2073      +22     
Flag Coverage Δ
unittests 39.43% <3.57%> (-0.17%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@mrlubos
Copy link
Member

mrlubos commented Feb 12, 2026

@SipanP are you able to resolve the typecheck fail? And since OpenAPI 2.0 parser was affected, can you add a spec + test the same way you did for 3.x? Looks good otherwise!

OpenAPI discriminator mappings use string keys, but the actual discriminator
property may be boolean, integer, or number. Previously, all discriminator
values were hardcoded as type 'string'. This change detects the actual
property type from the schema and converts mapping values accordingly.
@SipanP SipanP force-pushed the fix/discriminator-non-string-type-support branch from 73cecc5 to 53413ef Compare February 14, 2026 17:16
@SipanP
Copy link
Author

SipanP commented Feb 14, 2026

@mrlubos Fixed the typecheck. Ultimately, decided to remove the change in 2.0.x, as this version resolves discriminators by directly matching the discriminator value to a schema name and doesn't have the flexibility of mapping.

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

Labels

bug 🔥 Broken or incorrect behavior. size:XL This PR changes 500-999 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants