Repository navigation
feat: add support for duplicate request url + type in OpenAPI spec - #8028
naman-bruno merged 3 commits into
Conversation
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
Hidden review stack artifactWalkthroughExport assigns unique component IDs per request, aggregates duplicate {url,method} operations into operation.x-bruno-variants, and records per-variant components and security schemes; the importer expands x-bruno-variants into separate Bruno requests, preserving variant servers, tags, parameters, and component/security references. ChangesOpenAPI duplicate operation variants
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Possibly related PRs
Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
packages/bruno-converters/tests/openapi/openapi-to-bruno/openapi-server-variables.spec.js (1)
383-383: ⚡ Quick winAssert extension removal on the request item object.
On Line 383, the check targets
request.request['x-bruno-variants'], but extension leakage would occur on the request item object itself. This can hide regressions.Proposed test fix
- expect(requests.every((request) => !request.request['x-bruno-variants'])).toBe(true); + expect(requests.every((request) => request['x-bruno-variants'] === undefined)).toBe(true);🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@packages/bruno-converters/tests/openapi/openapi-to-bruno/openapi-server-variables.spec.js` at line 383, The test currently checks for the extension on request.request (expect(requests.every((request) => !request.request['x-bruno-variants']))) but the extension would be attached to the request item itself; update the predicate to assert the extension is removed from the request item by checking request['x-bruno-variants'] (i.e., expect(requests.every((request) => !request['x-bruno-variants'])).toBe(true)). Ensure you update the assertion that iterates over the requests array in openapi-server-variables.spec.js accordingly.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In
`@packages/bruno-converters/tests/openapi/openapi-to-bruno/openapi-server-variables.spec.js`:
- Line 383: The test currently checks for the extension on request.request
(expect(requests.every((request) => !request.request['x-bruno-variants']))) but
the extension would be attached to the request item itself; update the predicate
to assert the extension is removed from the request item by checking
request['x-bruno-variants'] (i.e., expect(requests.every((request) =>
!request['x-bruno-variants'])).toBe(true)). Ensure you update the assertion that
iterates over the requests array in openapi-server-variables.spec.js
accordingly.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: a497594c-ef7b-4ea0-9211-8ac8fd27218c
📒 Files selected for processing (4)
packages/bruno-app/src/utils/exporters/openapi-spec.jspackages/bruno-app/src/utils/exporters/openapi-spec.spec.jspackages/bruno-converters/src/openapi/openapi-to-bruno.jspackages/bruno-converters/tests/openapi/openapi-to-bruno/openapi-server-variables.spec.js
There was a problem hiding this comment.
Actionable comments posted: 2
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
packages/bruno-app/src/utils/exporters/openapi-spec.js (1)
342-445:⚠️ Potential issue | 🟠 Major | ⚡ Quick winFix OpenAPI
securityand auth scheme serialization
pathBody['security']is still emitted as an object ({ [componentId]: [] }), but OpenAPI requiressecurityto be an array of security requirement objects (e.g.,[{ [componentId]: [] }]) across all these auth variants.- OAuth2
client_credentialsis mapped toflows.password; it should useflows.clientCredentials.- Digest auth is emitted as
type: 'digest'; it should betype: 'http'withscheme: 'digest'.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@packages/bruno-app/src/utils/exporters/openapi-spec.js` around lines 342 - 445, The code emits invalid OpenAPI security and flow types: update all places where pathBody['security'] is assigned so it becomes an array of requirement objects (e.g., wrap the existing { [componentId]: [] } inside [ ... ]), change the oauth2 client_credentials branch in the switch under auth?.oauth2.grantType (the case 'client_credentials' in the oauth2 handling) to use flows.clientCredentials instead of flows.password, and adjust the digest branch (the case 'digest' that currently sets components.securitySchemes[componentId] = { type: 'digest', scheme: 'digest', ... }) to use { type: 'http', scheme: 'digest', description: 'Digest Authentication' } while keeping components.securitySchemes and pathBody updates consistent with the other cases.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@packages/bruno-app/src/utils/exporters/openapi-spec.js`:
- Around line 283-287: In components.requestBodies[componentId] you are using
invalid media-type keys with trailing colons ('multipart/form-data:' and
'application/x-www-form-urlencoded:'); remove the trailing ':' so the keys are
exactly 'multipart/form-data' and 'application/x-www-form-urlencoded' (update
the object literals where these strings are used around the requestBodies
creation to use the corrected media-type keys).
- Around line 360-361: The switch case for 'oauth2' declares const {
authorizationUrl, accessTokenUrl, callbackUrl, scope } = auth?.oauth2; directly
under the case label which violates noSwitchDeclarations; fix it by wrapping the
entire case 'oauth2' branch in braces (i.e. case 'oauth2': { ... break; }) so
the const destructuring and any local variables are in a block scope and Biome
will stop flagging it; ensure you keep the existing guard if
(!auth?.oauth2?.grantType) break; and existing logic inside the new { } block.
---
Outside diff comments:
In `@packages/bruno-app/src/utils/exporters/openapi-spec.js`:
- Around line 342-445: The code emits invalid OpenAPI security and flow types:
update all places where pathBody['security'] is assigned so it becomes an array
of requirement objects (e.g., wrap the existing { [componentId]: [] } inside [
... ]), change the oauth2 client_credentials branch in the switch under
auth?.oauth2.grantType (the case 'client_credentials' in the oauth2 handling) to
use flows.clientCredentials instead of flows.password, and adjust the digest
branch (the case 'digest' that currently sets
components.securitySchemes[componentId] = { type: 'digest', scheme: 'digest',
... }) to use { type: 'http', scheme: 'digest', description: 'Digest
Authentication' } while keeping components.securitySchemes and pathBody updates
consistent with the other cases.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: c856212d-88e8-43b2-9718-d9199aecb44e
📒 Files selected for processing (2)
packages/bruno-app/src/utils/exporters/openapi-spec.jspackages/bruno-app/src/utils/exporters/openapi-spec.spec.js
6f14181 to
64c9a3e
Compare
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@packages/bruno-app/src/utils/exporters/openapi-spec.js`:
- Around line 304-349: The switch cases for 'multipartForm' and 'formUrlEncoded'
declare const/let bindings directly under the case labels which violates
noSwitchDeclarations; fix by wrapping each case body in its own block (i.e., add
{ ... } around the code for the 'multipartForm' and 'formUrlEncoded' branches)
so getItemComponentId, multipartFormToKeyValue, formUrlEncodedToKeyValue,
components.schemas/ requestBodies assignments, generateProperyShape calls, and
the pathBody['requestBody'] = ... lines are block-scoped; keep the existing
break statements inside those new blocks.
In `@packages/bruno-app/src/utils/exporters/openapi-spec.spec.js`:
- Around line 220-230: The helper flattenItemsForExport currently hardcodes
Windows backslashes in pathname and depth computation; update
flattenItemsForExport to build pathnames using Node's path.join (import path)
and compute depth using path.sep (or splitting on path.sep), e.g., join
parentPath and item.name plus '.bru' for pathname and derive depth from
parentPath.split(path.sep). Also update the exporter parsing/normalization code
that consumes pathname to use path.normalize or split on path.sep so tests are
OS-agnostic (refer to flattenItemsForExport and the exporter parse/normalize
function names in the diff when making the changes).
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 29137dfc-bcb9-43d2-90ee-1433715fb290
📒 Files selected for processing (2)
packages/bruno-app/src/utils/exporters/openapi-spec.jspackages/bruno-app/src/utils/exporters/openapi-spec.spec.js
There was a problem hiding this comment.
Actionable comments posted: 1
♻️ Duplicate comments (3)
packages/bruno-app/src/utils/exporters/openapi-spec.spec.js (1)
220-232:⚠️ Potential issue | 🟠 Major | ⚡ Quick win
flattenItemsForExporthelper (and the surrounding fixtures) still hardcode Windows-style\\separators.Same concern as the previous round of review — the
pathname/depthplumbing here pins variant coverage to Windows. Build paths withpath.join()and derive depth viapath.sep(orpath.split(path.sep)) so the suite runs identically on macOS/Linux. Note that the source-sideextractTagFromDepthinopenapi-spec.jsalso splits on'\\', so the fix likely needs a coordinated touch on the exporter too.Sketch of an OS-agnostic helper
+const path = require('path'); + describe('exportApiSpec - duplicate operation variants', () => { - const flattenItemsForExport = (items, parentPath = 'collection') => { - return items.flatMap((item) => { - if (item.type === 'folder') { - return flattenItemsForExport(item.items || [], `${parentPath}\\${item.name}`); - } - - return [{ - ...item, - pathname: `${parentPath}\\${item.name}.bru`, - depth: parentPath.split('\\').length - }]; - }); - }; + const flattenItemsForExport = (items, parentPath = 'collection') => { + return items.flatMap((item) => { + if (item.type === 'folder') { + return flattenItemsForExport(item.items || [], path.join(parentPath, item.name)); + } + + return [{ + ...item, + pathname: path.join(parentPath, `${item.name}.bru`), + depth: parentPath.split(path.sep).length + }]; + }); + };As per coding guidelines: "File paths must use
path.join()orpath.resolve()instead of hardcoded/or\\separators".🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@packages/bruno-app/src/utils/exporters/openapi-spec.spec.js` around lines 220 - 232, The flattenItemsForExport helper currently hardcodes Windows backslashes; update flattenItemsForExport to build pathname using path.join(parentPath, `${item.name}.bru`) (importing Node's path) and compute depth by splitting parentPath on path.sep (e.g., parentPath.split(path.sep).length) instead of '\\'; also update the recursive call to use path.join(parentPath, item.name) for folders. Make a coordinated change to the corresponding source helper extractTagFromDepth in openapi-spec.js so it derives depth/tags by splitting on path.sep rather than '\\', and adjust any test fixtures that hardcode backslashes to use path.join or platform-agnostic values.packages/bruno-app/src/utils/exporters/openapi-spec.js (2)
304-348:⚠️ Potential issue | 🟠 Major | ⚡ Quick winBlock-scope the
multipartFormandformUrlEncodedcases, and also fix the stray:in the media-type keys.Two issues survive in this hunk that prior reviews already called out:
- Biome
noSwitchDeclarationsstill trips on theconst multipartFormComponentId/const formUrlEncodedComponentId(andlet …KeyValue) declared directly under thecaselabels (lines 306, 307–310, 329, 330–333).- The media-type keys are still
'multipart/form-data:'and'application/x-www-form-urlencoded:'— that trailing:makes consumers miss the body entirely.Both can be fixed in one go:
Proposed fix
- case 'multipartForm': + case 'multipartForm': { if (!body?.multipartForm) break; const multipartFormComponentId = getItemComponentId(); let multipartFormToKeyValue = body?.multipartForm.reduce((acc, f) => { acc[f?.name] = f.value; return acc; }, {}); components.schemas[multipartFormComponentId] = generateProperyShape(multipartFormToKeyValue); components.requestBodies[multipartFormComponentId] = { content: { - 'multipart/form-data:': { + 'multipart/form-data': { schema: { $ref: `#/components/schemas/${multipartFormComponentId}` } } }, description: '', required: true }; pathBody['requestBody'] = { $ref: `#/components/requestBodies/${multipartFormComponentId}` }; break; - case 'formUrlEncoded': + } + case 'formUrlEncoded': { if (!body?.formUrlEncoded) break; const formUrlEncodedComponentId = getItemComponentId(); let formUrlEncodedToKeyValue = body?.formUrlEncoded.reduce((acc, f) => { acc[f?.name] = f.value; return acc; }, {}); components.schemas[formUrlEncodedComponentId] = generateProperyShape(formUrlEncodedToKeyValue); components.requestBodies[formUrlEncodedComponentId] = { content: { - 'application/x-www-form-urlencoded:': { + 'application/x-www-form-urlencoded': { schema: { $ref: `#/components/schemas/${formUrlEncodedComponentId}` } } }, description: '', required: true }; pathBody['requestBody'] = { $ref: `#/components/requestBodies/${formUrlEncodedComponentId}` }; break; + }🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@packages/bruno-app/src/utils/exporters/openapi-spec.js` around lines 304 - 348, The switch cases for multipartForm and formUrlEncoded declare block-scoped variables (multipartFormComponentId, formUrlEncodedComponentId, multipartFormToKeyValue, formUrlEncodedToKeyValue) directly under the case labels which trips noSwitchDeclarations; wrap each case body in braces to create a proper block so those const/let declarations are scoped correctly, and while editing fix the media-type keys in components.requestBodies to remove the stray trailing colons (use 'multipart/form-data' and 'application/x-www-form-urlencoded' as the content keys) so consumers can find the requestBody referenced by pathBody['requestBody'] (keep using getItemComponentId and generateProperyShape as before).
391-457:⚠️ Potential issue | 🟡 Minor | ⚡ Quick winWrap the
oauth2case in a block.
const { authorizationUrl, accessTokenUrl, callbackUrl, scope } = auth?.oauth2;is still declared directly undercase 'oauth2':, so Biome keeps flagging it (noSwitchDeclarationsat line 394). Quick fix:Proposed fix
- case 'oauth2': + case 'oauth2': { if (!auth?.oauth2?.grantType) break; componentId = getItemComponentId(); const { authorizationUrl, accessTokenUrl, callbackUrl, scope } = auth?.oauth2; switch (auth?.oauth2?.grantType) { @@ } break; + }🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@packages/bruno-app/src/utils/exporters/openapi-spec.js` around lines 391 - 457, The switch case for 'oauth2' declares variables directly under the case which triggers noSwitchDeclarations; fix it by wrapping the case 'oauth2' body in a block (add { ... } after case 'oauth2':) and move the destructuring line const { authorizationUrl, accessTokenUrl, callbackUrl, scope } = auth?.oauth2; (and any other local declarations like componentId) inside that block so all declarations are scoped properly; keep the existing logic that sets components.securitySchemes[componentId] and pathBody['security'] for the authorization_code, password, and client_credentials branches unchanged.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@packages/bruno-converters/src/openapi/openapi-to-bruno.js`:
- Around line 859-877: Variants are currently using only operationObjectCleaned,
causing sparse variants to drop base operation fields (like parameters and
servers); update the loop to first merge each variant with the base operation
(e.g., build a mergedOperation by spreading base operationObject and then
spreading the variant to let per-variant values override), then delete
'x-bruno-variants' from that mergedOperation and compute mergedParams =
mergeParams(pathItemParams, mergedOperation.parameters || []), and use
mergedOperation.servers || pathItemObject.servers || null when constructing the
request pushed into requests so variants inherit base fields before overrides.
---
Duplicate comments:
In `@packages/bruno-app/src/utils/exporters/openapi-spec.js`:
- Around line 304-348: The switch cases for multipartForm and formUrlEncoded
declare block-scoped variables (multipartFormComponentId,
formUrlEncodedComponentId, multipartFormToKeyValue, formUrlEncodedToKeyValue)
directly under the case labels which trips noSwitchDeclarations; wrap each case
body in braces to create a proper block so those const/let declarations are
scoped correctly, and while editing fix the media-type keys in
components.requestBodies to remove the stray trailing colons (use
'multipart/form-data' and 'application/x-www-form-urlencoded' as the content
keys) so consumers can find the requestBody referenced by
pathBody['requestBody'] (keep using getItemComponentId and generateProperyShape
as before).
- Around line 391-457: The switch case for 'oauth2' declares variables directly
under the case which triggers noSwitchDeclarations; fix it by wrapping the case
'oauth2' body in a block (add { ... } after case 'oauth2':) and move the
destructuring line const { authorizationUrl, accessTokenUrl, callbackUrl, scope
} = auth?.oauth2; (and any other local declarations like componentId) inside
that block so all declarations are scoped properly; keep the existing logic that
sets components.securitySchemes[componentId] and pathBody['security'] for the
authorization_code, password, and client_credentials branches unchanged.
In `@packages/bruno-app/src/utils/exporters/openapi-spec.spec.js`:
- Around line 220-232: The flattenItemsForExport helper currently hardcodes
Windows backslashes; update flattenItemsForExport to build pathname using
path.join(parentPath, `${item.name}.bru`) (importing Node's path) and compute
depth by splitting parentPath on path.sep (e.g.,
parentPath.split(path.sep).length) instead of '\\'; also update the recursive
call to use path.join(parentPath, item.name) for folders. Make a coordinated
change to the corresponding source helper extractTagFromDepth in openapi-spec.js
so it derives depth/tags by splitting on path.sep rather than '\\', and adjust
any test fixtures that hardcode backslashes to use path.join or
platform-agnostic values.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 97bc1602-58d0-496c-a1b0-c9257f74716d
📒 Files selected for processing (4)
packages/bruno-app/src/utils/exporters/openapi-spec.jspackages/bruno-app/src/utils/exporters/openapi-spec.spec.jspackages/bruno-converters/src/openapi/openapi-to-bruno.jspackages/bruno-converters/tests/openapi/openapi-to-bruno/openapi-server-variables.spec.js
Co-authored-by: Prateek Sunal <[email protected]>
64c9a3e to
eae6523
Compare
Co-authored-by: Prateek Sunal <[email protected]>
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
packages/bruno-app/src/utils/exporters/openapi-spec.js (1)
439-458:⚠️ Potential issue | 🟠 Major | ⚡ Quick winFix OAuth2
client_credentialsOpenAPI flow mapping
client_credentialscurrently maps toflows.password; OpenAPI 3.0 requiresflows.clientCredentials.
- Also, when
scope.length === 0, the current code omitsscopes, but OpenAPI requiresscopes(an empty object{}is acceptable).🐛 Proposed fix
case 'client_credentials': components.securitySchemes[componentId] = { type: 'oauth2', flows: { - password: { + clientCredentials: { tokenUrl: accessTokenUrl, ...(scope.length > 0 ? { scopes: { [scope]: '' } } : {}) } } };🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@packages/bruno-app/src/utils/exporters/openapi-spec.js` around lines 439 - 458, The OAuth2 mapping for the 'client_credentials' case is wrong: change the flows key from password to clientCredentials and ensure scopes is always present (use an empty object {} when scope.length === 0). Specifically, update the switch case handling 'client_credentials' that sets components.securitySchemes[componentId] so flows uses clientCredentials with tokenUrl set to accessTokenUrl, and adjust the scopes construction so it yields either { [scope]: '' } or {} (never omitted); leave the pathBody['security'] assignment as-is.
♻️ Duplicate comments (3)
packages/bruno-converters/src/openapi/openapi-to-bruno.js (1)
858-877:⚠️ Potential issue | 🟠 Major | ⚡ Quick winVariants should inherit base operation fields before override.
Line 865 and Line 876 currently resolve from the variant object only. Sparse variants will drop base fields (e.g.,
parameters,servers,security,requestBody) instead of inheriting and overriding selectively.Proposed minimal fix
- operations.forEach((operation) => { - const operationObjectCleaned = { ...operation }; - delete operationObjectCleaned['x-bruno-variants']; - const mergedParams = mergeParams(pathItemParams, operationObjectCleaned.parameters || []); + operations.forEach((operation) => { + const operationObjectCleaned = { ...operation }; + delete operationObjectCleaned['x-bruno-variants']; + + const effectiveOperation = operation === operationObject + ? operationObjectCleaned + : { ...operationObject, ...operationObjectCleaned }; + delete effectiveOperation['x-bruno-variants']; + + const mergedParams = mergeParams(pathItemParams, effectiveOperation.parameters || []); requests.push({ method: method, path: path.replace(/{([^}]+)}/g, ':$1'), // Replace placeholders enclosed in curly braces with colons originalPath: path, // Keep original path for grouping - operationObject: { ...operationObjectCleaned, parameters: mergedParams }, + operationObject: { ...effectiveOperation, parameters: mergedParams }, global: { server: '{{baseUrl}}', security: securityConfig }, - servers: operationObjectCleaned.servers || pathItemObject.servers || null + servers: effectiveOperation.servers || pathItemObject.servers || null }); });🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@packages/bruno-converters/src/openapi/openapi-to-bruno.js` around lines 858 - 877, The variant handling in the reduce callback currently uses the variant object alone, so sparse variants drop base operation fields; change the logic to merge each variant with its base operationObject before cleaning and processing (i.e., produce a mergedOperation = { ...operationObject, ...variant } or equivalent deep merge for arrays/objects), then delete x-bruno-variants from mergedOperation, compute mergedParams from pathItemParams and mergedOperation.parameters, and use mergedOperation.servers, mergedOperation.security, mergedOperation.requestBody when building the requests entry so variants inherit base fields and only override specified keys; update references operationObjectCleaned and mergedParams accordingly.packages/bruno-app/src/utils/exporters/openapi-spec.js (2)
314-320:⚠️ Potential issue | 🟠 Major | ⚡ Quick winInvalid media type key: trailing colon breaks OpenAPI consumers.
'multipart/form-data:'is not a valid MIME type. Remove the trailing colon so consumers can correctly parse the request body.🐛 Proposed fix
components.requestBodies[multipartFormComponentId] = { content: { - 'multipart/form-data:': { + 'multipart/form-data': { schema: { $ref: `#/components/schemas/${multipartFormComponentId}` }🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@packages/bruno-app/src/utils/exporters/openapi-spec.js` around lines 314 - 320, The requestBodies entry uses an invalid media type key 'multipart/form-data:' (trailing colon) which breaks OpenAPI consumers; update the components.requestBodies creation to use the correct MIME type 'multipart/form-data' for the content key where multipartFormComponentId is used (and search for any other occurrences of 'multipart/form-data:' in this module to replace them as well) so the schema $ref remains under a valid media type.
337-343:⚠️ Potential issue | 🟠 Major | ⚡ Quick winInvalid media type key: trailing colon breaks OpenAPI consumers.
'application/x-www-form-urlencoded:'has the same trailing colon issue. Remove it.🐛 Proposed fix
components.requestBodies[formUrlEncodedComponentId] = { content: { - 'application/x-www-form-urlencoded:': { + 'application/x-www-form-urlencoded': { schema: { $ref: `#/components/schemas/${formUrlEncodedComponentId}`🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@packages/bruno-app/src/utils/exporters/openapi-spec.js` around lines 337 - 343, The media type key for the form urlencoded request body is incorrect: in components.requestBodies the key is written as 'application/x-www-form-urlencoded:' (with a trailing colon) which breaks OpenAPI consumers; update the object under components.requestBodies[formUrlEncodedComponentId].content to use the correct media type 'application/x-www-form-urlencoded' (no trailing colon) wherever formUrlEncodedComponentId is used so the schema $ref remains under the valid media type key.
🧹 Nitpick comments (1)
packages/bruno-converters/tests/openapi/openapi-to-bruno/openapi-server-variables.spec.js (1)
345-456: ⚡ Quick winAdd a sparse-variant inheritance regression test.
Current coverage is good, but it doesn’t assert that a variant with only partial fields inherits base operation fields (especially
parametersandservers). Adding that test will lock down the intended contract.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@packages/bruno-converters/tests/openapi/openapi-to-bruno/openapi-server-variables.spec.js` around lines 345 - 456, Add a new test in the same spec file that calls openApiToBruno with an operation that defines servers and parameters on the base operation and a sparse x-bruno-variants entry that only supplies a summary (or one overridden parameter); assert the variant's generated request inherits the base operation's parameters (inspect request.request.params values) and baseUrl server (inspect request.request.vars.req[0].value or .name === 'baseUrl') so that partial variants merge fields rather than dropping them.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Outside diff comments:
In `@packages/bruno-app/src/utils/exporters/openapi-spec.js`:
- Around line 439-458: The OAuth2 mapping for the 'client_credentials' case is
wrong: change the flows key from password to clientCredentials and ensure scopes
is always present (use an empty object {} when scope.length === 0).
Specifically, update the switch case handling 'client_credentials' that sets
components.securitySchemes[componentId] so flows uses clientCredentials with
tokenUrl set to accessTokenUrl, and adjust the scopes construction so it yields
either { [scope]: '' } or {} (never omitted); leave the pathBody['security']
assignment as-is.
---
Duplicate comments:
In `@packages/bruno-app/src/utils/exporters/openapi-spec.js`:
- Around line 314-320: The requestBodies entry uses an invalid media type key
'multipart/form-data:' (trailing colon) which breaks OpenAPI consumers; update
the components.requestBodies creation to use the correct MIME type
'multipart/form-data' for the content key where multipartFormComponentId is used
(and search for any other occurrences of 'multipart/form-data:' in this module
to replace them as well) so the schema $ref remains under a valid media type.
- Around line 337-343: The media type key for the form urlencoded request body
is incorrect: in components.requestBodies the key is written as
'application/x-www-form-urlencoded:' (with a trailing colon) which breaks
OpenAPI consumers; update the object under
components.requestBodies[formUrlEncodedComponentId].content to use the correct
media type 'application/x-www-form-urlencoded' (no trailing colon) wherever
formUrlEncodedComponentId is used so the schema $ref remains under the valid
media type key.
In `@packages/bruno-converters/src/openapi/openapi-to-bruno.js`:
- Around line 858-877: The variant handling in the reduce callback currently
uses the variant object alone, so sparse variants drop base operation fields;
change the logic to merge each variant with its base operationObject before
cleaning and processing (i.e., produce a mergedOperation = { ...operationObject,
...variant } or equivalent deep merge for arrays/objects), then delete
x-bruno-variants from mergedOperation, compute mergedParams from pathItemParams
and mergedOperation.parameters, and use mergedOperation.servers,
mergedOperation.security, mergedOperation.requestBody when building the requests
entry so variants inherit base fields and only override specified keys; update
references operationObjectCleaned and mergedParams accordingly.
---
Nitpick comments:
In
`@packages/bruno-converters/tests/openapi/openapi-to-bruno/openapi-server-variables.spec.js`:
- Around line 345-456: Add a new test in the same spec file that calls
openApiToBruno with an operation that defines servers and parameters on the base
operation and a sparse x-bruno-variants entry that only supplies a summary (or
one overridden parameter); assert the variant's generated request inherits the
base operation's parameters (inspect request.request.params values) and baseUrl
server (inspect request.request.vars.req[0].value or .name === 'baseUrl') so
that partial variants merge fields rather than dropping them.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: ee6bf87d-e06d-44e3-9c39-5592f0757ec4
📒 Files selected for processing (4)
packages/bruno-app/src/utils/exporters/openapi-spec.jspackages/bruno-app/src/utils/exporters/openapi-spec.spec.jspackages/bruno-converters/src/openapi/openapi-to-bruno.jspackages/bruno-converters/tests/openapi/openapi-to-bruno/openapi-server-variables.spec.js
Description
Jira
Currently the OpenAPI spec doesn't allow duplicate request url + type and it only keeps one.
After this change it will create a new
x-bruno-variantsthat will be used to keep the duplicates instead of discard it.Screen.Recording.2026-05-24.at.2.18.37.PM.mov
Contribution Checklist:
Summary by CodeRabbit
New Features
Bug Fixes
Tests