Skip to content

Commit

Permalink
Merge pull request #334 from tdakkota/fix/string-quoting
Browse files Browse the repository at this point in the history
fix(gen): parameter name quoting
  • Loading branch information
ernado authored May 12, 2022
2 parents f58827b + 555840b commit 5e9bfed
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,58 @@
"version": "v0.1.0"
},
"paths": {
"/healthz": {
"/healthz/{`param3}/{\"param4}": {
"get": {
"operationId": "probeLiveness",
"description": "Liveness probe for kubernetes",
"parameters": [
{
"name": "`param1",
"in": "query",
"style": "form",
"schema": {
"type": "integer"
}
},
{
"name": "\"param2",
"in": "query",
"style": "form",
"schema": {
"type": "integer"
}
},
{
"name": "`param3",
"required": true,
"in": "path",
"schema": {
"type": "string"
}
},
{
"name": "\"param4",
"required": true,
"in": "path",
"schema": {
"type": "string"
}
},
{
"name": "`param5",
"in": "header",
"schema": {
"type": "string"
}
},
{
"name": "\"param6",
"in": "header",
"schema": {
"type": "string"
}
}
],
"responses": {
"200": {
"description": "User info",
Expand All @@ -17,7 +65,7 @@
"schema": {
"type": "object",
"required": [
"object with `additionalProperties: { type: object, properties: ... }`",
"object with `additionalProperties: { type: object, properties: ... }`"
],
"properties": {
"object with `additionalProperties: { type: object, properties: ... }`": {
Expand All @@ -33,6 +81,12 @@
}
}
}
},
"`param1": {
"type": "integer"
},
"\"param2": {
"type": "integer"
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions gen/_template/param_dec.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ func decode{{ $op.Name }}Params(args [{{ $op.PathParamsCount }}]string, r *http.
{{- end }}
// Decode {{ $loc }}.
{{- if $p.Spec.In.Query }}{{/* Switch location */}}
{
{
cfg := uri.QueryParameterDecodingConfig{
Name: "{{ $p.Spec.Name }}",
Name: {{ quote $p.Spec.Name }},
Style: uri.QueryStyle{{ capitalize $p.Spec.Style.String }},
Explode: {{ if $p.Spec.Explode }}true{{ else }}false{{ end }},
{{- if isObjectParam $p }}
Expand Down
2 changes: 1 addition & 1 deletion gen/_template/param_enc.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ q := uri.NewQueryEncoder()
{
// Encode {{ quote $param.Spec.Name }} parameter.
cfg := uri.QueryParameterEncodingConfig{
Name: "{{ $param.Spec.Name }}",
Name: {{ quote $param.Spec.Name }},
Style: uri.QueryStyle{{ capitalize $param.Spec.Style.String }},
Explode: {{ if $param.Spec.Explode }}true{{ else }}false{{ end }},
}
Expand Down

0 comments on commit 5e9bfed

Please sign in to comment.