Skip to content

fix(index): recognise operation parameter $ref that is not the first key - #660

Open
navaneethan-ac9 wants to merge 1 commit into
pb33f:mainfrom
navaneethan-ac9:fix/param-ref-not-first-key
Open

navaneethan-ac9 wants to merge 1 commit into
pb33f:mainfrom
navaneethan-ac9:fix/param-ref-not-first-key

Conversation

@navaneethan-ac9

Copy link
Copy Markdown

Fixes #659.

scanOperationParams only treated a parameter as a reference when $ref was the first mapping key (param.Content[0]). With OpenAPI 3.1 sibling description/summary, a key such as description can come first, so the parameter was treated as inline and reported "has no name value", and the reference was missing from GetOperationParameterReferences().

This uses the existing utils.GetRefValueNode, which finds $ref at any position (top level only, so an inline parameter with schema: {$ref: ...} is still treated as inline).

Tests

  • Added TestSpecIndex_GetAllParametersFromOperations_RefWithSiblingBeforeIt, covering a path-level and an operation-level parameter with description before $ref. It fails without the change and passes with it.
  • go test ./... passes except json.FuzzAppendJSONString/seed#5, which fails the same way on main without this change (seen with Go 1.27.2).
  • Checked downstream: vacuum v0.33.0 built against this branch no longer reports the false operation-parameters errors on our 3.1 specs; all other results are unchanged.

OpenAPI 3.1 allows summary and description next to $ref, and YAML key
order has no meaning. scanOperationParams only checked Content[0], so a
parameter with a sibling before $ref was treated as inline and reported
"has no `name` value". Use utils.GetRefValueNode to find $ref anywhere.

Fixes pb33f#659
@codecov

codecov Bot commented Oct 13, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (c4c4be7) to head (bc14a9b).

Additional details and impacted files
@@            Coverage Diff            @@
##              main      #660   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files          309       309           
  Lines        39213     39213           
=========================================
  Hits         39213     39213           
Flag Coverage Δ
unittests 100.00% <100.00%> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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.

Operation parameter $ref is not recognised when a sibling key comes before it

1 participant