Skip to content

Commit

Permalink
moar
Browse files Browse the repository at this point in the history
Signed-off-by: Pierre Fenoll <[email protected]>
  • Loading branch information
fenollp committed Sep 19, 2022
1 parent ac0a293 commit 12b9026
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
9 changes: 8 additions & 1 deletion openapi3/media_type.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"errors"
"fmt"
"sort"

"github.com/go-openapi/jsonpointer"

Expand Down Expand Up @@ -93,7 +94,13 @@ func (mediaType *MediaType) Validate(ctx context.Context) error {
return err
}
} else if examples := mediaType.Examples; examples != nil {
for k, v := range examples {
names := make([]string, 0, len(examples))
for name := range examples {
names = append(names, name)
}
sort.Strings(names)
for _, k := range names {
v := examples[k]
if err := v.Validate(ctx); err != nil {
return fmt.Errorf("%s: %w", k, err)
}
Expand Down
9 changes: 8 additions & 1 deletion openapi3/parameter.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"errors"
"fmt"
"sort"
"strconv"

"github.com/go-openapi/jsonpointer"
Expand Down Expand Up @@ -325,7 +326,13 @@ func (parameter *Parameter) Validate(ctx context.Context) error {
return err
}
} else if examples := parameter.Examples; examples != nil {
for k, v := range examples {
names := make([]string, 0, len(examples))
for name := range examples {
names = append(names, name)
}
sort.Strings(names)
for _, k := range names {
v := examples[k]
if err := v.Validate(ctx); err != nil {
return fmt.Errorf("%s: %w", k, err)
}
Expand Down

0 comments on commit 12b9026

Please sign in to comment.