From a82fc102b4c495b12440bb70f42a2c0d089f8b11 Mon Sep 17 00:00:00 2001 From: Hidetatz Yaginuma Date: Tue, 1 Oct 2024 11:12:31 +0900 Subject: [PATCH] sort inline properties recusively to prevente flaky struct field order --- parser.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/parser.go b/parser.go index ac23da2..c70b5d0 100644 --- a/parser.go +++ b/parser.go @@ -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 }