Adjust names of security schemes to match prefixed name#3861
Adjust names of security schemes to match prefixed name#3861StratusFearMe21 wants to merge 2 commits into
Conversation
|
|
|
|
@StratusFearMe21 is attempting to deploy a commit to the Hey API Team on Vercel. A member of the Team first needs to authorize it. |
There was a problem hiding this comment.
No new issues found.
TL;DR — When merging multiple OpenAPI specs, components.securitySchemes entries are renamed with a per-source prefix, but operation/path-level security requirements were not, leaving them pointing at the original (now non-existent) scheme names. This PR rewrites the keys of every security requirement object during cloneAndRewrite, so the references match the renamed components.
Key changes
- Prefix
securityrequirement keys to match renamed schemes — IncloneAndRewrite, security requirement objects get each key rewritten to${opIdPrefix}_${key}, matching the prefix applied tocomponents.securitySchemesentries.
Summary | 1 file | 1 commit | base: main ← fix-merged-security-schemes
Before: Operation-level
security: [{ apiKey: [] }]survived merging unchanged while the matchingcomponents.securitySchemes.apiKeywas renamed to<prefix>_apiKey, leaving a dangling reference.
After: Both sides get the same<prefix>_apiKeyname, so the merged document is internally consistent.
The new branch is placed before the operationId handler in the same per-key chain; opIdPrefix is the same per-source prefix used for the components rename at line 505, so the strings match exactly. Empty/opt-out shapes (security: [], security: [{}]) and AND-shaped multi-key requirements ({ a: [], b: [] }) are handled correctly by the plain Object.entries(s) walk.
packages/json-schema-ref-parser/src/index.ts
Claude Opus | 𝕏
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #3861 +/- ##
==========================================
+ Coverage 39.58% 39.64% +0.06%
==========================================
Files 532 532
Lines 19581 19592 +11
Branches 5835 5833 -2
==========================================
+ Hits 7751 7768 +17
+ Misses 9582 9575 -7
- Partials 2248 2249 +1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
@hey-api/codegen-core
@hey-api/json-schema-ref-parser
@hey-api/nuxt
@hey-api/openapi-ts
@hey-api/shared
@hey-api/spec-types
@hey-api/types
@hey-api/vite-plugin
commit: |
|
@StratusFearMe21 can you add a test please? |
|
Done, the test has been added 👌. In order to make the bug testable, I did have to modify how the |

This PR fixes how security schemes are referenced when there are multiple input files. Each security scheme referenced in each path should have the same prefixes that are applied to the securitySchemes component when multiple files are used.