Skip to content

Commit

Permalink
bugfix: avoid non-deterministic output for extensions
Browse files Browse the repository at this point in the history
  • Loading branch information
alexzielenski committed Apr 16, 2024
1 parent dc4e619 commit 2b4e2b0
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion pkg/generators/openapi.go
Original file line number Diff line number Diff line change
Expand Up @@ -644,7 +644,15 @@ func (g openAPITypeWriter) emitExtensions(extensions []extension, unions []union
}

if len(otherExtensions) > 0 {
for k, v := range otherExtensions {
// Sort extension keys to generate deterministic output
keys := []string{}
for k := range otherExtensions {
keys = append(keys, k)
}
sort.Strings(keys)

for _, k := range keys {
v := otherExtensions[k]
g.Do("$.key$: $.value$,\n", map[string]interface{}{
"key": fmt.Sprintf("%#v", k),
"value": fmt.Sprintf("%#v", v),
Expand Down

0 comments on commit 2b4e2b0

Please sign in to comment.