Repository navigation
fix(index): recognise operation parameter $ref that is not the first key - #660
Open
navaneethan-ac9 wants to merge 1 commit into
Open
navaneethan-ac9 wants to merge 1 commit into
navaneethan-ac9 wants to merge 1 commit into
Conversation
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 Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #660 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 309 309
Lines 39213 39213
=========================================
Hits 39213 39213
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #659.
scanOperationParamsonly treated a parameter as a reference when$refwas the first mapping key (param.Content[0]). With OpenAPI 3.1 siblingdescription/summary, a key such asdescriptioncan come first, so the parameter was treated as inline and reported "has nonamevalue", and the reference was missing fromGetOperationParameterReferences().This uses the existing
utils.GetRefValueNode, which finds$refat any position (top level only, so an inline parameter withschema: {$ref: ...}is still treated as inline).Tests
TestSpecIndex_GetAllParametersFromOperations_RefWithSiblingBeforeIt, covering a path-level and an operation-level parameter withdescriptionbefore$ref. It fails without the change and passes with it.go test ./...passes exceptjson.FuzzAppendJSONString/seed#5, which fails the same way onmainwithout this change (seen with Go 1.27.2).operation-parameterserrors on our 3.1 specs; all other results are unchanged.