Skip to content

fix: parse OpenAPI response body JSON pointers#7906

Open
christian-gama wants to merge 1 commit intousebruno:mainfrom
christian-gama:bugfix/openapi-runtime-expression-json-pointer
Open

fix: parse OpenAPI response body JSON pointers#7906
christian-gama wants to merge 1 commit intousebruno:mainfrom
christian-gama:bugfix/openapi-runtime-expression-json-pointer

Conversation

@christian-gama
Copy link
Copy Markdown

@christian-gama christian-gama commented May 3, 2026

Description

Closes #7905.

Fixes OpenAPI link response body runtime expression conversion so JSON Pointer fragments are parsed by segment. This handles root pointers, array indexes, valid JavaScript identifiers, escaped ~1 / ~0 segments, and non-identifier property names with bracket notation.

Tests:

  • mise exec node@22.12.0 -- npm run lint -- packages/bruno-converters/src/openapi/openapi-to-bruno.js packages/bruno-converters/tests/openapi/openapi-to-bruno/openapi-links.spec.js
  • mise exec node@22.12.0 -- npm run test --workspace=packages/bruno-converters -- openapi-links.spec.js --runInBand
  • mise exec node@22.12.0 -- npm run build:bruno-common
  • mise exec node@22.12.0 -- npm run test --workspace=packages/bruno-converters -- --runInBand

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. N/A, converter logic only.
  • I have read the contribution guidelines.
  • Create an issue and link to the pull request.

Summary by CodeRabbit

  • Bug Fixes

    • Improved OpenAPI specification conversion for runtime expressions with complex JSON Pointer-style paths. Enhanced parsing to correctly handle nested paths, special character escaping, and various syntax variations found in response link definitions.
  • Tests

    • Added test coverage for OpenAPI response links conversion scenarios with multiple runtime expression formats and edge cases.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 3, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 3540704f-aa1b-4b49-a4a9-d9911f9f46ff

📥 Commits

Reviewing files that changed from the base of the PR and between 118ba80 and 54c63fb.

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

Walkthrough

Updated OpenAPI-to-Bruno converter to parse JSON Pointer–style runtime expressions ($response.body#/...) according to spec, handling root and empty pointers, escaping rules (~1, ~0), numeric indices, and invalid identifiers. Prior implementation used naive slash-to-dot replacement.

Changes

JSON Pointer Runtime Expression Parsing

Layer / File(s) Summary
Core Implementation
packages/bruno-converters/src/openapi/openapi-to-bruno.js
openAPIRuntimeExpressionToScript reworked to slice $response.body# prefix, normalize empty/root pointers, unescape ~1/ and ~0~, split into segments, and emit property access via dot notation (identifiers), bracket indexing (numeric), or bracketed string keys (non-identifiers).
Test Suite
packages/bruno-converters/tests/openapi/openapi-to-bruno/openapi-links.spec.js
Jest spec validates pointer parsing with hyphenated keys, escaped segments, array indices, and nested paths; asserts generated request.request.script.res matches expected Bruno script.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Suggested reviewers

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

Poem

Pointers once naïve now parse with care,
Tilde escapes and slashes in the air.
JSON spec unraveled, segment by segment true,
Brackets dance with dots in script anew. ✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed Title clearly describes the main fix: parsing OpenAPI response body JSON pointers, which is the core change in the PR.
Linked Issues check ✅ Passed Changes fully implement the requirement from #7905: JSON Pointer parsing with segment-by-segment conversion, handling nested paths, array indices, escaped segments (~1/~0), and non-identifier properties.
Out of Scope Changes check ✅ Passed All changes are scoped to implementing JSON Pointer parsing as specified in #7905; no extraneous modifications detected.
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

Tip

💬 Introducing Slack Agent: The best way for teams to turn conversations into code.

Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.

  • Generate code and open pull requests
  • Plan features and break down work
  • Investigate incidents and troubleshoot customer tickets together
  • Automate recurring tasks and respond to alerts with triggers
  • Summarize progress and report instantly

Built for teams:

  • Shared memory across your entire org—no repeating context
  • Per-thread sandboxes to safely plan and execute work
  • Governance built-in—scoped access, auditability, and budget controls

One agent for your entire SDLC. Right inside Slack.

👉 Get started


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
Review rate limit: 7/8 reviews remaining, refill in 7 minutes and 30 seconds.

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

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.

Fix OpenAPI response body runtime JSON Pointer parsing

1 participant