fix: preserve authored $ref+sibling syntax on render (issue #575)#576
Merged
Conversation
When the sibling-ref transformer rewrites a `$ref` with sibling fields into a synthetic `allOf`, the model still rendered that `allOf` back out, changing the authored syntax. Add `renderTransformedRefWithSiblings` to collapse the synthetic two-element `allOf` back into the original `$ref`+sibling shape on `MarshalYAML`, reusing the low-level `TransformedRef` node for key ordering and merging in mutated sibling values. Only the transformer-created `allOf` is collapsed; authored `allOf` blocks (or outer schema mutations) keep their explicit `allOf` so no changes are hidden. Add unit coverage for the new render path and helpers, an issue-575 regression spec, and update document render tests to assert byte-exact round-tripping.
This comment has been minimized.
This comment has been minimized.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #576 +/- ##
==========================================
- Coverage 99.72% 99.69% -0.03%
==========================================
Files 280 280
Lines 33575 33666 +91
==========================================
+ Hits 33483 33564 +81
- Misses 55 64 +9
- Partials 37 38 +1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
ensure 3.0 and 3.1+ behaviors are considered properly.
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.
When the sibling-ref transformer rewrites a
$refwith sibling fields into a syntheticallOf, the model still rendered thatallOfback out, changing the authored syntax. AddrenderTransformedRefWithSiblingsto collapse the synthetic two-elementallOfback into the original$ref+sibling shape onMarshalYAML, reusing the low-levelTransformedRefnode for key ordering and merging in mutated sibling values.Only the transformer-created
allOfis collapsed; authoredallOfblocks (or outer schema mutations) keep their explicitallOfso no changes are hidden. Add unit coverage for the new render path and helpers, an issue-575 regression spec, and update document render tests to assert byte-exact round-tripping.