Skip to content

Commit

Permalink
feat: make request param sorted for swagger.
Browse files Browse the repository at this point in the history
  • Loading branch information
xufeixiang committed Sep 23, 2024
1 parent 652c23e commit d8ee435
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions pkg/engine/swagger/api_operation.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"github.com/getkin/kin-openapi/openapi3"
"github.com/wundergraph/wundergraph/pkg/apihandler"
"github.com/wundergraph/wundergraph/pkg/wgpb"
"golang.org/x/exp/maps"
"golang.org/x/exp/slices"
"strings"
)
Expand Down Expand Up @@ -93,11 +94,13 @@ func (s *document) makeApiOperationParameters(requestSchemaRef *openapi3.SchemaR
return
}

result = make(openapi3.Parameters, 0)
for name, schemaRef := range requestSchemaRef.Value.Properties {
param := openapi3.NewQueryParameter(name)
param.Schema = schemaRef
param.Required = slices.Contains(requestSchemaRef.Value.Required, name)
keys := maps.Keys(requestSchemaRef.Value.Properties)
slices.Sort(keys)
result = make(openapi3.Parameters, 0, len(keys))
for _, key := range keys {
param := openapi3.NewQueryParameter(key)
param.Schema = requestSchemaRef.Value.Properties[key]
param.Required = slices.Contains(requestSchemaRef.Value.Required, key)
result = append(result, &openapi3.ParameterRef{Value: param})
}
return
Expand Down

0 comments on commit d8ee435

Please sign in to comment.