Repository navigation
fix: preserve explode presence in parameter hashes - #704
pcbeingused333 wants to merge 2 commits into
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #704 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 315 315
Lines 39762 39759 -3
=========================================
- Hits 39762 39759 -3
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:
|
| low.HashString(h, "style", p.Style.Value) | ||
| } | ||
| low.HashBool(h, p.Explode.Value) | ||
| if p.Explode.ValueNode != nil { |
There was a problem hiding this comment.
[P2] Use the same presence check as NewParameter. I set Explode on a built low-level parameter to low.NodeReference[bool]{KeyNode: key, Value: true}. NewParameter(p).Render() wrote explode: true, but low.AreEqual returned true against the parameter with explode omitted. The base distinguished these values. NodeReference.IsEmpty() checks both node pointers, and the high model uses that method. Please use !p.Explode.IsEmpty() here and add a key-only regression alongside the parsed cases.
Use the same IsEmpty check as NewParameter so a key-only Explode reference is not treated as omitted.
|
The presence check in This comment was drafted with AI assistance. |
Parameter hashes currently treat an omitted
explodeand explicitexplode: falseas equal. For a query array parameter using the default form style, addingexplode: falsechanges serialization froma=1&a=2toa=1,2, but the equality shortcut prevents the diff engine from reporting it.Hash the explode value only when its YAML value node is present. The existing diff logic can then report the property addition or removal, preserving the repository's current non-breaking classification.
For example, compare
name: a,in: query,schema: {type: array}against the same parameter withexplode: falseadded. The expected result is oneexplodeproperty addition.Testing and validation
Added focused hash regressions for absent, false, and true values, plus diff regressions for adding and removing explicit false.
go test ./datamodel/low/v3/ ./what-changed/... -run 'Explode|Parameter' -count=1passes; with theparameter.gochange reverted,TestParameter_Hash_ExplodePresenceandTestCompareParameters_V3_ExplodePresencefail (CompareParametersreturns nil).go test ./... -count=1passes.This change was prepared with AI assistance (Codex).