Skip to content

Commit

Permalink
fix(o2k): param-explode default true if form style (#186)
Browse files Browse the repository at this point in the history
  • Loading branch information
Tieske committed Jul 12, 2024
1 parent b151569 commit 95d22e8
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@
"body_schema": "{}",
"parameter_schema": [
{
"explode": false,
"explode": true,
"in": "query",
"name": "queryid",
"required": true,
Expand All @@ -191,7 +191,7 @@
"style": "simple"
},
{
"explode": false,
"explode": true,
"in": "cookie",
"name": "cookieid",
"required": true,
Expand Down
18 changes: 10 additions & 8 deletions openapi2kong/validator.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,18 @@ func generateParameterSchema(operation *openapi3.Operation, insoCompat bool) []m
for _, parameterRef := range parameters {
paramValue := parameterRef.Value

var explode bool
if paramValue.Explode == nil {
explode = false
} else {
explode = *paramValue.Explode
}

if paramValue != nil {
style := getDefaultParamStyle(paramValue.Style, paramValue.In)

var explode bool
if paramValue.Explode == nil {
explode = (style == "form") // default to true for form style, false for all others
} else {
explode = *paramValue.Explode
}

paramConf := make(map[string]interface{})
paramConf["style"] = style
paramConf["explode"] = explode
paramConf["in"] = paramValue.In
if paramValue.In == "path" {
Expand All @@ -65,7 +68,6 @@ func generateParameterSchema(operation *openapi3.Operation, insoCompat bool) []m
paramConf["name"] = paramValue.Name
}
paramConf["required"] = paramValue.Required
paramConf["style"] = getDefaultParamStyle(paramValue.Style, paramValue.In)

schema := extractSchema(paramValue.Schema)
if schema != "" {
Expand Down

0 comments on commit 95d22e8

Please sign in to comment.