Skip to content

Commit 5a6afbe

Browse files
authored
openapi3filter: some syntax tweaks (#933)
Signed-off-by: Pierre Fenoll <[email protected]>
1 parent 5a2e949 commit 5a6afbe

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

openapi3filter/req_resp_decoder.go

+5-6
Original file line numberDiff line numberDiff line change
@@ -987,7 +987,7 @@ func buildResObj(params map[string]interface{}, parentKeys []string, key string,
987987
if err != nil {
988988
return nil, &ParseError{path: pathFromKeys(mapKeys), Kind: KindInvalidFormat, Reason: fmt.Sprintf("could not convert value map to array: %v", err)}
989989
}
990-
resultArr := make([]interface{}, len(arr))
990+
resultArr := make([]interface{} /*not 0,*/, len(arr))
991991
for i := range arr {
992992
r, err := buildResObj(params, mapKeys, strconv.Itoa(i), schema.Value.Items)
993993
if err != nil {
@@ -1096,9 +1096,9 @@ func handlePropParseError(path []string, err error) error {
10961096
}
10971097

10981098
func pathFromKeys(kk []string) []interface{} {
1099-
path := make([]interface{}, len(kk))
1100-
for i, v := range kk {
1101-
path[i] = v
1099+
path := make([]interface{}, 0, len(kk))
1100+
for _, v := range kk {
1101+
path = append(path, v)
11021102
}
11031103
return path
11041104
}
@@ -1135,8 +1135,7 @@ func parsePrimitive(raw string, schema *openapi3.SchemaRef) (v interface{}, err
11351135
return nil, nil
11361136
}
11371137
for _, typ := range schema.Value.Type.Slice() {
1138-
v, err = parsePrimitiveCase(raw, schema, typ)
1139-
if err == nil {
1138+
if v, err = parsePrimitiveCase(raw, schema, typ); err == nil {
11401139
return
11411140
}
11421141
}

0 commit comments

Comments
 (0)