Skip to content

fix(high): keep document order of $ref'd path items and callbacks - #739

Open
pcbeingused333 wants to merge 1 commit into
pb33f:mainfrom
pcbeingused333:fix/composed-path-order
Open

pcbeingused333 wants to merge 1 commit into
pb33f:mainfrom
pcbeingused333:fix/composed-path-order

Conversation

@pcbeingused333

Copy link
Copy Markdown
Contributor

Fixes #733

Root cause: Paths and Callback order their entries by ValueNode.Line when rendering. For a $ref'd item the low-level value node comes from the referenced document, so its line number is compared against lines of the root document. In the issue's example, /b and /a are moved ahead of /c.

Fix: order by the line of the key, which is always in the document that declares the map. This covers MarshalYAML and the inline variant for both Paths and Callback. Callbacks have the same code and the same problem. Entries added in code still go to the bottom.

Tests: TestBundleDocumentComposed_PreservesRootOrderOfReferencedItems checks the order of paths and callback expressions (normal and inline rendering) and of the composed bundle. It fails without the change. go test ./... passes.

This change was prepared with the help of an AI coding assistant.

Paths and Callback sorted their entries by the line of the value node. For a
$ref'd item that is a line in the referenced file, so bundled and rendered
output moved those entries around. Sort by the line of the key instead.
@codecov

codecov Bot commented Nov 27, 2026

Copy link
Copy Markdown

Codecov Report

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

Additional details and impacted files
@@            Coverage Diff            @@
##              main      #739   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files          316       316           
  Lines        40239     40231    -8     
=========================================
- Hits         40239     40231    -8     
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.

BundleDocumentComposed moves $ref'd path items ahead of inline ones

1 participant