Skip to content

Commit

Permalink
fix(generator): enum value should sort
Browse files Browse the repository at this point in the history
  • Loading branch information
morlay committed Apr 23, 2020
1 parent 9be4c2d commit 0b94823
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions openapi/generator/definition_scanner.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,13 @@ func (scanner *DefinitionScanner) Def(typeName *types.TypeName) *oas.Schema {
if enumOptions == nil {
panic(fmt.Errorf("missing enum option but annotated by openapi:enum"))
}

sort.Slice(enumOptions, func(i, j int) bool {
return enumOptions[i].Value < enumOptions[j].Value
})

s := oas.String()

for _, e := range enumOptions {
s.Enum = append(s.Enum, e.Value)
}
Expand Down

0 comments on commit 0b94823

Please sign in to comment.