这是indexloc提供的服务,不要输入任何密码
Skip to content

Conversation

@josstn
Copy link
Contributor

@josstn josstn commented Aug 18, 2025

If a type name referenced in a discriminator mapping has non-ascii characters, the resolving of the mapping into a union type failed because the $ref value used in the lookup was uri encoded, and the typename in the lookup was not.

This change fixes that by using the $ref value which has been uri decoded for the lookup.

josstn added 3 commits August 18, 2025 16:15
Adds ref with non-ascii typename to testcases with discriminator mapping that.

Before fix these generate type unions where the mapping is ignored for the non-ascii typename.
So that the ref has been resolved with "decodeURI" in parseRef.

Without this change, discriminator mapping for non-ascii typenames did not work.
@bolt-new-by-stackblitz
Copy link

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

@changeset-bot
Copy link

changeset-bot bot commented Aug 18, 2025

🦋 Changeset detected

Latest commit: 82af768

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

This PR includes changesets to release 1 package
Name Type
@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

@vercel
Copy link

vercel bot commented Aug 18, 2025

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

A member of the Team first needs to authorize it.

@dosubot dosubot bot added size:M This PR changes 30-99 lines, ignoring generated files. bug 🔥 Something isn't working labels Aug 18, 2025
@pkg-pr-new
Copy link

pkg-pr-new bot commented Aug 18, 2025

Open in StackBlitz

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

commit: 82af768

@codecov
Copy link

codecov bot commented Aug 18, 2025

Codecov Report

❌ Patch coverage is 0% with 8 lines in your changes missing coverage. Please review.
✅ Project coverage is 22.58%. Comparing base (6751a72) to head (82af768).
⚠️ Report is 7 commits behind head on main.

Files with missing lines Patch % Lines
...ages/openapi-ts/src/openApi/3.0.x/parser/schema.ts 0.00% 4 Missing ⚠️
...ages/openapi-ts/src/openApi/3.1.x/parser/schema.ts 0.00% 4 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2471   +/-   ##
=======================================
  Coverage   22.58%   22.58%           
=======================================
  Files         337      337           
  Lines       33398    33398           
  Branches     1309     1309           
=======================================
  Hits         7543     7543           
  Misses      25846    25846           
  Partials        9        9           
Flag Coverage Δ
unittests 22.58% <0.00%> (ø)

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.

Nice to see you again @josstn and thanks for the fix! Should I even ask what kind of schemas you're working with to run into this bug? 😬

@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Aug 18, 2025
@mrlubos mrlubos merged commit 5b69b17 into hey-api:main Aug 18, 2025
11 of 13 checks passed
@github-actions github-actions bot mentioned this pull request Aug 18, 2025
@josstn
Copy link
Contributor Author

josstn commented Aug 18, 2025

Thanks for the quick response @mrlubos! And to answer your question, no you don't wanna know 😉

But if you really wanna know, the spec i'm working on is generated from a somewhat big java codebase not written with openapi spec generation in mind. And it is norwegian 🙃

@josstn josstn deleted the non-ascii-discriminator-mapping-fix branch August 18, 2025 18:59
@mrlubos
Copy link
Member

mrlubos commented Aug 18, 2025

My pleasure! Literally, you created a very "easy to merge" pull request. Thanks for the additional context as well, it's fun to hear what kind of APIs people work with

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

Labels

bug 🔥 Something isn't working lgtm This PR has been approved by a maintainer size:M This PR changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants