Skip to content

Commit

Permalink
sort inline properties recusively to prevente flaky struct field order
Browse files Browse the repository at this point in the history
  • Loading branch information
hidetatz committed Oct 1, 2024
1 parent 454a9a6 commit 2f6d6c3
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,15 @@ func sortProperties(props []*Property) []*Property {
for _, n := range names {
sorted = append(sorted, pMap[n])
}

// In case the top level property contains another property internally,
// sort them recursively.
for _, p := range sorted {
if p.InlineProperties != nil {
p.InlineProperties = sortProperties(p.InlineProperties)
}
}

return sorted
}

Expand Down

0 comments on commit 2f6d6c3

Please sign in to comment.