Skip to content

Commit

Permalink
openapi3filter: some syntax tweaks (getkin#933)
Browse files Browse the repository at this point in the history
Signed-off-by: Pierre Fenoll <[email protected]>
  • Loading branch information
fenollp authored Apr 6, 2024
1 parent 5a2e949 commit 5a6afbe
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions openapi3filter/req_resp_decoder.go
Original file line number Diff line number Diff line change
Expand Up @@ -987,7 +987,7 @@ func buildResObj(params map[string]interface{}, parentKeys []string, key string,
if err != nil {
return nil, &ParseError{path: pathFromKeys(mapKeys), Kind: KindInvalidFormat, Reason: fmt.Sprintf("could not convert value map to array: %v", err)}
}
resultArr := make([]interface{}, len(arr))
resultArr := make([]interface{} /*not 0,*/, len(arr))
for i := range arr {
r, err := buildResObj(params, mapKeys, strconv.Itoa(i), schema.Value.Items)
if err != nil {
Expand Down Expand Up @@ -1096,9 +1096,9 @@ func handlePropParseError(path []string, err error) error {
}

func pathFromKeys(kk []string) []interface{} {
path := make([]interface{}, len(kk))
for i, v := range kk {
path[i] = v
path := make([]interface{}, 0, len(kk))
for _, v := range kk {
path = append(path, v)
}
return path
}
Expand Down Expand Up @@ -1135,8 +1135,7 @@ func parsePrimitive(raw string, schema *openapi3.SchemaRef) (v interface{}, err
return nil, nil
}
for _, typ := range schema.Value.Type.Slice() {
v, err = parsePrimitiveCase(raw, schema, typ)
if err == nil {
if v, err = parsePrimitiveCase(raw, schema, typ); err == nil {
return
}
}
Expand Down

0 comments on commit 5a6afbe

Please sign in to comment.