Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

openapi3filter: some syntax tweaks #933

Merged
merged 1 commit into from
Apr 6, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading