Skip to content

fix(converters): Make OpenAPI→Bruno conversion use correct default parameter serialization methods - #7783

Merged
arpit-bruno merged 3 commits into
usebruno:fix/openapi-parameters-default-serialization-methods-internalfrom
alexanderroidl:fix/openapi-parameters-default-serialization-methods
Sep 28, 2026
Merged

arpit-bruno merged 3 commits into
usebruno:fix/openapi-parameters-default-serialization-methods-internalfrom
alexanderroidl:fix/openapi-parameters-default-serialization-methods

Conversation

@alexanderroidl

@alexanderroidl alexanderroidl commented Apr 16, 2026 •

Copy link
Copy Markdown
Contributor

Description

The OpenAPI specification v3 states certain methods for how parameter values should be serialized. As of now Bruno aims to support only primitive and array values, while ignoring style and explode instructions. Therefore I was looking at the standard serialization method for each type of parameter in their documentation on parameter serialization.

The aim of this PR is to fix the default serialization methods for several scenarios/parameter types, as seen below:

Location OAS default Value source Expected Actual
path style: simple
explode: false
→ comma-join
param.example: [3,4,5] "3,4,5" "3,4,5" ✅
param.examples[0].value: [10,20,30] "10,20,30" "10,20,30" ✅
schema.default: ["admin","user"] "admin,user" '["admin","user"]' ❌
schema.example: [7,8,9] "7,8,9" "7,8,9" ✅
schema.examples: [[1,2,3]] "1,2,3" "[]" ❌
items.enum + schema.default: ["a","b"] "a,b" '["a","b"]' ❌
header style: simple
explode: false
→ comma-join
param.example: [1,2,3] "1,2,3" "1,2,3" ✅
param.examples[0].value: ["a","b","c"] "a,b,c" "a,b,c" ✅
schema.default: ["read","write"] "read,write" '["read","write"]' ❌
schema.example: [4,5,6] "4,5,6" "4,5,6" ✅
schema.examples: [["x","y","z"]] "x,y,z" "[]" ❌
query style: form
explode: true
→ one entry per item
param.example: [3,4,5] 3 entries: ["3","4","5"] 1 entry: "3,4,5" ❌
param.examples[0].value: ["foo","bar","baz"] 3 entries: ["foo","bar","baz"] 1 entry: "foo,bar,baz" ❌
schema.default: ["active","pending"] 2 entries: ["active","pending"] 1 entry: '["active","pending"]' ❌
schema.example: ["red","green","blue"] 3 entries: ["red","green","blue"] 1 entry: "red,green,blue" ❌
schema.examples: [["foo","bar","baz"]] 3 entries: ["foo","bar","baz"] 1 entry: "[]" ❌

This can be validated by running the updated tests of this branch on the current main branch:

git checkout main
git checkout fix/openapi-parameters-default-serialization-methods -- packages/bruno-converters/tests/openapi/openapi-to-bruno/openapi-path-parameters.spec.js
npm run test --workspace=packages/bruno-converters

Contribution Checklist:

  • I've used AI significantly to create this pull request
  • The pull request only addresses one issue or adds one feature.
  • The pull request does not introduce any breaking changes
  • I have added screenshots or gifs to help explain the change if applicable.
  • I have read the contribution guidelines.
  • Create an issue and link to the pull request.

Summary by CodeRabbit

  • Bug Fixes
    • Fixed array parameter serialization in OpenAPI conversions to properly handle different parameter locations (query, path, header)
    • Improved example and default value processing for enhanced conversion accuracy
    • Enhanced parameter entry generation for better compatibility with OpenAPI specifications

Copilot AI review requested due to automatic review settings April 16, 2026 17:20
@coderabbitai

coderabbitai Bot commented Apr 16, 2026 •

Copy link
Copy Markdown
Contributor

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

🗂️ Base branches to auto review (2)
  • main
  • release/*

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository: usebruno/bruno/.coderabbit.yaml

Review profile: CHILL

Plan: Advanced

Run ID: b0a69dad-96a3-49df-abe9-4e2d7607d043

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Walkthrough

This PR refactors OpenAPI parameter value conversion by introducing a helper function paramEntriesFromValue that handles serialization differently based on parameter location. Arrays are expanded into multiple entries for query/cookie parameters, while path/header parameters receive single comma-joined entries. The logic now prioritizes example/default sources in a defined order and removes prior JSON.stringify handling for array defaults.

Changes

Cohort / File(s) Summary
Core Implementation
packages/bruno-converters/src/openapi/openapi-to-bruno.js
Added paramEntriesFromValue helper to apply location-aware serialization for array and non-array parameter values. Updated getParameterEntries to use this helper, prioritizing param.example, param.examples, schema.default, schema.example, and schema.examples. Adjusted array fallback to return empty string instead of '[]'.
Test Coverage
packages/bruno-converters/tests/openapi/openapi-to-bruno/openapi-path-parameters.spec.js
Added comprehensive test suite array param serialization — OAS defaults per location with 508 new lines covering serialization behavior for path, header, query, and cookie parameter locations across multiple example/default sources.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Suggested reviewers

  • lohit-bruno
  • naman-bruno
  • bijin-bruno
  • helloanoop
🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly describes the main change: fixing OpenAPI→Bruno conversion to use correct default parameter serialization methods, which aligns with the PR's core objective of respecting OpenAPI v3 serialization rules.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

📦 Arrays now dance to location's tune,
Query expands, path joins in sync,
Helper functions refactor soon,
Parameters flow without a kink. ✨

Comment @coderabbitai help to get the list of available commands.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Updates the OpenAPI → Bruno converter to align default array parameter serialization with OpenAPI v3 defaults per parameter location (comma-joined for path/header, exploded into multiple entries for query), and adds regression tests to validate these behaviors.

Changes:

  • Adjusted parameter value extraction to emit multiple Bruno param entries for array values in query (OAS default explode behavior).
  • Updated handling of array defaults/examples to avoid JSON-stringifying arrays for path/header parameters.
  • Added a comprehensive test suite covering array serialization defaults across path, header, query, and unmapped cookie.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
packages/bruno-converters/src/openapi/openapi-to-bruno.js Updates parameter entry generation to follow OAS default serialization rules for arrays by location.
packages/bruno-converters/tests/openapi/openapi-to-bruno/openapi-path-parameters.spec.js Adds coverage for default array serialization across parameter locations.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +34 to +35
const paramEntriesFromValue = (val, paramIn) => {
const explodeByDefault = paramIn === 'query' || paramIn === 'cookie';

Copilot AI Apr 16, 2026

Copy link

Choose a reason for hiding this comment

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

paramEntriesFromValue treats only param.in === 'query' as explode-by-default. However this converter also supports the non-standard in: 'querystring' (see later mapping in transformOpenapiRequestItem), so array values for querystring params will currently be serialized as a single comma-joined entry instead of one entry per item. Consider treating 'querystring' the same as 'query' in the explode default logic (and ideally add a small test for an array querystring param to lock this in).

Suggested change
const paramEntriesFromValue = (val, paramIn) => {
const explodeByDefault = paramIn === 'query' || paramIn === 'cookie';
// Bruno also supports non-standard `querystring` params, which should behave like `query`.
const paramEntriesFromValue = (val, paramIn) => {
const explodeByDefault = paramIn === 'query' || paramIn === 'querystring' || paramIn === 'cookie';

Copilot uses AI. Check for mistakes.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
packages/bruno-converters/src/openapi/openapi-to-bruno.js (1)

75-80: ⚠️ Potential issue | 🟠 Major

Preserve explicit empty array defaults.

Line 78 uses a truthy check, so schema.default: [] is treated as “no default” and falls back to enum-derived entries. That changes intended behavior for valid specs.

Suggested fix
-    if (arrayDefault) {
+    if (arrayDefault !== null) {
       return paramEntriesFromValue(arrayDefault, param.in);
     }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/bruno-converters/src/openapi/openapi-to-bruno.js` around lines 75 -
80, The code treats an explicit empty array default (schema.default = []) as
falsy and skips it; change the conditional so empty arrays are preserved: keep
the existing assignment to arrayDefault (const arrayDefault = schema.default !==
undefined && Array.isArray(schema.default) ? schema.default : null) but replace
the truthy check if (arrayDefault) with an explicit null-check (if (arrayDefault
!== null)) or test Array.isArray(schema.default) before calling
paramEntriesFromValue(arrayDefault, param.in) so paramEntriesFromValue is
invoked for [] as well; reference symbols: arrayDefault, schema.default,
paramEntriesFromValue, param.in.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In
`@packages/bruno-converters/tests/openapi/openapi-to-bruno/openapi-path-parameters.spec.js`:
- Around line 705-732: Add a new test case in the same spec that calls
openApiToBruno with a path parameter whose schema has type: 'array', items.enum:
['a','b','c'] and default: [] to ensure an explicit empty default does not fall
back to enum values; locate the pattern around the existing test that finds the
parameter via result.items.find(i => i.name === 'Get by
types').request.params.find(p => p.name === 'types') and assert that for
default: [] the resulting typesParam.value is '' (empty string) and
typesParam.enabled is false.

---

Outside diff comments:
In `@packages/bruno-converters/src/openapi/openapi-to-bruno.js`:
- Around line 75-80: The code treats an explicit empty array default
(schema.default = []) as falsy and skips it; change the conditional so empty
arrays are preserved: keep the existing assignment to arrayDefault (const
arrayDefault = schema.default !== undefined && Array.isArray(schema.default) ?
schema.default : null) but replace the truthy check if (arrayDefault) with an
explicit null-check (if (arrayDefault !== null)) or test
Array.isArray(schema.default) before calling paramEntriesFromValue(arrayDefault,
param.in) so paramEntriesFromValue is invoked for [] as well; reference symbols:
arrayDefault, schema.default, paramEntriesFromValue, param.in.
🪄 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: 64590c63-5a6e-450d-9716-7aaa4e9b159d

📥 Commits

Reviewing files that changed from the base of the PR and between c6281d3 and 8ae071d.

📒 Files selected for processing (2)
  • packages/bruno-converters/src/openapi/openapi-to-bruno.js
  • packages/bruno-converters/tests/openapi/openapi-to-bruno/openapi-path-parameters.spec.js

Comment on lines +705 to +732
it('items.enum default array', () => {
const spec = {
openapi: '3.0.0',
info: { title: 'API', version: '1.0.0' },
servers: [{ url: 'https://api.example.com' }],
paths: {
'/items/{types}': {
get: {
summary: 'Get by types',
operationId: 'getByTypes',
parameters: [
{
name: 'types',
in: 'path',
required: true,
schema: { type: 'array', items: { type: 'string', enum: ['a', 'b', 'c'] }, default: ['a', 'b'] }
}
],
responses: { 200: { description: 'OK' } }
}
}
}
};
const result = openApiToBruno(spec);
const typesParam = result.items.find((i) => i.name === 'Get by types').request.params.find((p) => p.name === 'types');
expect(typesParam.value).toBe('a,b');
expect(typesParam.enabled).toBe(true);
});

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Add an empty-array default regression case.

Please add a case where schema.default is [] (with items.enum present) to ensure explicit empty defaults do not fall back to enum values.

As per coding guidelines: Cover both the "happy path" and the realistically problematic paths.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@packages/bruno-converters/tests/openapi/openapi-to-bruno/openapi-path-parameters.spec.js`
around lines 705 - 732, Add a new test case in the same spec that calls
openApiToBruno with a path parameter whose schema has type: 'array', items.enum:
['a','b','c'] and default: [] to ensure an explicit empty default does not fall
back to enum values; locate the pattern around the existing test that finds the
parameter via result.items.find(i => i.name === 'Get by
types').request.params.find(p => p.name === 'types') and assert that for
default: [] the resulting typesParam.value is '' (empty string) and
typesParam.enabled is false.

@arpit-bruno
arpit-bruno changed the base branch from main to fix/openapi-parameters-default-serialization-methods-internal September 28, 2026 07:39
…ternal' into fix/openapi-parameters-default-serialization-methods
@arpit-bruno
arpit-bruno merged commit c14584c into usebruno:fix/openapi-parameters-default-serialization-methods-internal Sep 28, 2026
2 checks passed
@arpit-bruno arpit-bruno added the adopted-by-maintainers PR needs additional work and is now being worked on by the maintainers label Sep 28, 2026
arpit-bruno added a commit that referenced this pull request Oct 19, 2026
… serialization (#9400)

* fix(converters): Make OpenAPI→Bruno conversion use correct default parameter serialization methods (#7783)

* chore: remove merge-related comments

* fix: make openapi to bruno conversion use correct default serialization methods for parameters

---------

Co-authored-by: Arpit <[email protected]>

* fix:OpenAPI to Bruno conversion missing standard parameter serialization (#9391)

* fix: comments addressed

* fix: comments addressed

* fix: comments addressed

* fix: comments addressed

* fix: comments addressed

---------

Co-authored-by: Alexander Roidl <[email protected]>
Co-authored-by: Arpit <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

adopted-by-maintainers PR needs additional work and is now being worked on by the maintainers size/XL

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants