Skip to content

feat(expander): add ExpandParameterWithOptions and ExpandResponseWithOptions#292

Merged
fredbi merged 1 commit into
go-openapi:masterfrom
fredbi:feat/expand-parameter-response-with-options
Jul 20, 2026
Merged

feat(expander): add ExpandParameterWithOptions and ExpandResponseWithOptions#292
fredbi merged 1 commit into
go-openapi:masterfrom
fredbi:feat/expand-parameter-response-with-options

Conversation

@fredbi

@fredbi fredbi commented Jul 20, 2026

Copy link
Copy Markdown
Member

ExpandParameter/ExpandParameterWithRoot and ExpandResponse/ExpandResponseWithRoot expand a parameter or response but take no ExpandOptions, so they always use the package default (unsandboxed) document loader — the same gap that motivated ExpandSchemaWithOptions. go-openapi/validate expands every parameter and response $ref of a spec through these functions, so a $ref from an untrusted source could not be confined there.

Add ExpandParameterWithOptions(parameter, root, cache, opts) and ExpandResponseWithOptions(response, root, cache, opts): the option-aware forms. When root is non-nil, refs resolve against the in-memory root (base derived from root); otherwise they resolve relative to opts.RelativeBase. In particular opts.PathLoaderWithOptions / PathLoader inject a confined loader. The four existing functions are reimplemented in terms of the new ones, so their behavior is unchanged.

Change type

Please select: 🆕 New feature or enhancement|🔧 Bug fix'|📃 Documentation update

Short description

Fixes

Full description

Checklist

  • I have signed all my commits with my name and email (see DCO. This does not require a PGP-signed commit
  • I have rebased and squashed my work, so only one commit remains
  • I have added tests to cover my changes.
  • I have properly enriched go doc comments in code.
  • I have properly documented any breaking change.

…Options

ExpandParameter/ExpandParameterWithRoot and ExpandResponse/ExpandResponseWithRoot
expand a parameter or response but take no ExpandOptions, so they always use the
package default (unsandboxed) document loader — the same gap that motivated
ExpandSchemaWithOptions. go-openapi/validate expands every parameter and response
$ref of a spec through these functions, so a $ref from an untrusted source could
not be confined there.

Add ExpandParameterWithOptions(parameter, root, cache, opts) and
ExpandResponseWithOptions(response, root, cache, opts): the option-aware forms.
When root is non-nil, refs resolve against the in-memory root (base derived from
root); otherwise they resolve relative to opts.RelativeBase. In particular
opts.PathLoaderWithOptions / PathLoader inject a confined loader. The four
existing functions are reimplemented in terms of the new ones, so their behavior
is unchanged.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Signed-off-by: Frederic BIDON <fredbi@yahoo.com>
@fredbi
fredbi merged commit e682f66 into go-openapi:master Jul 20, 2026
19 checks passed
@fredbi
fredbi deleted the feat/expand-parameter-response-with-options branch July 20, 2026 19:48
@codecov

codecov Bot commented Jul 20, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 68.43%. Comparing base (9bfe732) to head (b13c708).
⚠️ Report is 1 commits behind head on master.
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #292      +/-   ##
==========================================
- Coverage   68.49%   68.43%   -0.07%     
==========================================
  Files          30       30              
  Lines        2438     2433       -5     
==========================================
- Hits         1670     1665       -5     
  Misses        599      599              
  Partials      169      169              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant