fix: resolve root security during join#2827
Conversation
🦋 Changeset detectedLatest commit: 1ecab94 The changes in this PR will be included in the next version bump. This PR includes changesets to release 3 packages
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 |
|
Coverage Report
File CoverageNo changed files found. |
|
@cursor review |
|
@cursor review |
|
@cursor review |
5bc9605 to
ecc35f1
Compare
tatomyr
left a comment
There was a problem hiding this comment.
Please also address the bugbot comments.
| } from '../../utils/miscellaneous.js'; | ||
| import type { CommandArgs } from '../../wrapper.js'; | ||
| import { COMPONENTS } from '../split/constants.js'; | ||
| // import { COMPONENTS } from '../split/constants.js'; |
| }, | ||
| }); | ||
| } | ||
| if (!security && openapi.hasOwnProperty('security')) { |
There was a problem hiding this comment.
Why the previous solution was not working? I see it refers to the root security already.
There was a problem hiding this comment.
Yeah, good point. Previous solution was working for each case, except when we have paths: {} and security on root level. Simplified the solution to cover this case, please, review one more time.
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit fc563a9. Configure here.
11a4935 to
09e577e
Compare
| 200: | ||
| description: OK | ||
| 400: | ||
| description: Bad request No newline at end of file |
There was a problem hiding this comment.
| description: Bad request | |
| description: Bad request | |
Let's add a newline on file endings.
| info: | ||
| title: "spec1" | ||
| version: 1.0.0 | ||
| servers: |
There was a problem hiding this comment.
Let's add only essential fields and remove others.
| servers: | ||
| - url: https://api.example.com | ||
| paths: | ||
| /post: |
There was a problem hiding this comment.
It's bad practice to use verbs in paths (especially mixing post and get), so I'm against using it in our examples.
| description: Bad request | ||
| tags: | ||
| - bar_other | ||
| security: |
There was a problem hiding this comment.
If I'm getting it correctly, this path comes from an API description that doesn't have security defined on it; so how it got the security requirement from another description?
| authorizationUrl: https://example.com/oauth/authorize | ||
| tokenUrl: https://example.com/oauth/token | ||
| scopes: {} | ||
| oauth1: |
There was a problem hiding this comment.
These names are hard to follow. Please use something more meaningful.

What/Why/How?
Fixes a bug where root-level
securityfrom joined API descriptions was silently dropped in the output.Previously, the
joincommand ignored thesecurityfield defined at the root of each input spec. According to OpenAPI semantics, root-level security serves as a default for all operations that don't declare their own security. Simply merging root securities into the joined output would incorrectly apply one API's security to another API's operations.Reference
Closes #1409
Testing
Screenshots (optional)
Check yourself
Security
Note
Medium Risk
Changes how merged OpenAPI documents express authentication defaults; wrong behavior could mis-document which schemes apply to operations, though scope is limited to the join command and covered by new e2e snapshots.
Overview
Fixes
joinso root-levelsecurityfrom each input OpenAPI document is no longer dropped. Operations without their ownsecuritynow get that spec’s root default (with component prefixing), including when another joined file only defines root security and no paths.Operation-level rules are unchanged: explicit
securityon an operation wins;security: []stays public and is not overridden by root defaults. New e2e cases cover both specs with root security, root-only on a paths-empty file, and operation vs root precedence.Reviewed by Cursor Bugbot for commit 1ecab94. Bugbot is set up for automated code reviews on this repo. Configure here.