Skip to content

fix: make oneOf discriminator props required #2006

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

Merged
merged 4 commits into from
May 4, 2025

Conversation

Liooo
Copy link
Contributor

@Liooo Liooo commented May 3, 2025

Closes #1561

Fix for the issue that discriminator.propertyName becomes optional in generated type.

https://github.com/OAI/OpenAPI-Specification/blob/3.0.3/versions/3.0.3.md#discriminator-object

The expectation now is that a property with name petType MUST be present in the response payload

Seems this should be always the case according to the spec too (same for 3.1.0).

Copy link

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

Copy link

changeset-bot bot commented May 3, 2025

⚠️ No Changeset found

Latest commit: 6365286

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

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

Copy link

vercel bot commented May 3, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
hey-api-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 4, 2025 5:59am

Copy link

pkg-pr-new bot commented May 3, 2025

Open in StackBlitz

@hey-api/client-axios

npm i https://pkg.pr.new/hey-api/openapi-ts/@hey-api/client-axios@2006

@hey-api/client-fetch

npm i https://pkg.pr.new/hey-api/openapi-ts/@hey-api/client-fetch@2006

@hey-api/client-nuxt

npm i https://pkg.pr.new/hey-api/openapi-ts/@hey-api/client-nuxt@2006

@hey-api/client-next

npm i https://pkg.pr.new/hey-api/openapi-ts/@hey-api/client-next@2006

@hey-api/nuxt

npm i https://pkg.pr.new/hey-api/openapi-ts/@hey-api/nuxt@2006

@hey-api/openapi-ts

npm i https://pkg.pr.new/hey-api/openapi-ts/@hey-api/openapi-ts@2006

@hey-api/vite-plugin

npm i https://pkg.pr.new/hey-api/openapi-ts/@hey-api/vite-plugin@2006

commit: aa10522

Copy link

codecov bot commented May 3, 2025

Codecov Report

Attention: Patch coverage is 0% with 2 lines in your changes missing coverage. Please review.

Project coverage is 22.27%. Comparing base (5deefc4) to head (aa10522).
Report is 5 commits behind head on main.

Files with missing lines Patch % Lines
...ages/openapi-ts/src/openApi/3.0.x/parser/schema.ts 0.00% 1 Missing ⚠️
...ages/openapi-ts/src/openApi/3.1.x/parser/schema.ts 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2006      +/-   ##
==========================================
- Coverage   22.28%   22.27%   -0.01%     
==========================================
  Files         252      252              
  Lines       21385    21387       +2     
  Branches      795      795              
==========================================
  Hits         4765     4765              
- Misses      16614    16616       +2     
  Partials        6        6              
Flag Coverage Δ
unittests 22.27% <0.00%> (-0.01%) ⬇️

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.

Copy link
Member

@mrlubos mrlubos left a comment

Choose a reason for hiding this comment

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

Any idea why only 3.0.x snapshots are affected? You touched the 3.1.x parser too, so I'd expect those to be updated too. Perhaps different parts of the code were altered?

EDIT: I see it's because you touched the allOf function instead of oneOf in 3.1.x. I'll fix it

@Liooo
Copy link
Contributor Author

Liooo commented May 4, 2025

@mrlubos ops, thanks for that!

@mrlubos mrlubos merged commit d94c9ae into hey-api:main May 4, 2025
16 of 17 checks passed
@github-actions github-actions bot mentioned this pull request May 4, 2025
@Liooo Liooo deleted the fix/oneof-discriminator-required branch May 4, 2025 06:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Weird types for schemas with discriminator
2 participants