Skip to content

fix: openapi content level example#7091

Merged
sid-bruno merged 2 commits intousebruno:mainfrom
pooja-bruno:fix/openapi-import-content-level-examples
Feb 10, 2026
Merged

fix: openapi content level example#7091
sid-bruno merged 2 commits intousebruno:mainfrom
pooja-bruno:fix/openapi-import-content-level-examples

Conversation

@pooja-bruno
Copy link
Copy Markdown
Collaborator

@pooja-bruno pooja-bruno commented Feb 10, 2026

Description

JIRA

Fix openapi content level example

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

  • New Features

    • Request bodies now derive examples from content-level examples when schema-level examples are absent, improving generated request payloads across JSON, XML, text, form, multipart, SPARQL and other media types.
  • Tests

    • Expanded test coverage validating example priority rules and content-level example handling across many media types and request body formats.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Feb 10, 2026

Walkthrough

Adds extraction of content-level examples for OpenAPI requestBody content and merges them into body schemas when schema-level examples are absent, enabling Bruno request bodies to be populated from content.example / content.examples across multiple media types.

Changes

Cohort / File(s) Summary
Converter logic
packages/bruno-converters/src/openapi/openapi-to-bruno.js
Add getContentLevelExample helper; when processing requestBody.content, derive an example from bodyContent.example or bodyContent.examples and merge into bodySchema.example if missing. Applied in two requestBody processing locations.
Tests
packages/bruno-converters/tests/openapi/openapi-body.spec.js
Add extensive tests covering priority rules (schema example > content example > content examples) and content-level example behavior across many media types (JSON, XML, text, form, multipart, SPARQL, etc.).

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested labels

size/M

Suggested reviewers

  • helloanoop
  • bijin-bruno
  • lohit-bruno
  • naman-bruno

Poem

Content hidden in the body now sings aloud,
Examples lifted from content, once shy in the crowd.
Bruno receives a fuller, clearer view,
Schemas brighter with examples true —
Conversion humming, small joy made proud.

🚥 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 accurately describes the main change: fixing OpenAPI content-level example handling in the bruno converter.
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 docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

No actionable comments were generated in the recent review. 🎉

🧹 Recent nitpick comments
packages/bruno-converters/tests/openapi/openapi-to-bruno/openapi-body.spec.js (2)

913-994: Good coverage of the priority logic.

The three scenarios (singular wins, plural fallback, schema overrides both) are solid and directly validate the feature's core behavior.

One small observation: combining all three scenarios in a single it block means a failure in the first assertion masks the remaining two. Consider splitting into separate it blocks for more granular failure diagnostics — but this is a minor readability preference, not a blocker.


1096-1130: Repeated parsing of the same spec across 6 tests.

openApiToBruno(spec) is invoked identically in each it block. Consider computing once via beforeAll and storing the result, which keeps the tests fast and avoids redundant work.

♻️ Suggested refactor
 describe('content-level example values for each body type', () => {
   const spec = `...`;
+  let result;
+
+  beforeAll(() => {
+    result = openApiToBruno(spec);
+  });
 
   it('should import content-level example for JSON body', () => {
-    const result = openApiToBruno(spec);
     const body = JSON.parse(result.items.find((i) => i.name === 'JSON body').request.body.json);
     expect(body.name).toBe('json example');
   });
 
   // ... same pattern for remaining 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

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

@pull-request-size pull-request-size bot added size/L and removed size/M labels Feb 10, 2026
@sid-bruno sid-bruno merged commit 9127be8 into usebruno:main Feb 10, 2026
10 of 14 checks passed
bijin-bruno pushed a commit that referenced this pull request Feb 13, 2026
* fix: openapi content level example

* add: unit tests
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants