Skip to content

Commit

Permalink
[go-server] Fix: missing quotes for string default value (#18546)
Browse files Browse the repository at this point in the history
* Update controller mustache

* Add tests to openapi doc

* Regen
  • Loading branch information
lwj5 authored May 6, 2024
1 parent b1fac19 commit cefbf62
Show file tree
Hide file tree
Showing 14 changed files with 188 additions and 43 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -520,7 +520,7 @@ func (c *{{classname}}Controller) {{nickname}}(w http.ResponseWriter, r *http.Re
{{/required}}
{{^required}}
{{#defaultValue}}
param := {{^isString}}{{dataType}}({{/isString}}{{defaultValue}}{{^isString}}){{/isString}}
param := {{^isString}}{{dataType}}({{/isString}}"{{defaultValue}}"{{^isString}}){{/isString}}
{{paramName}}Param = {{#isNullable}}&{{/isNullable}}param
{{/defaultValue}}
{{/required}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,21 @@ paths:
- "OPTION_1"
- "OPTION_2"
- "OPTION_3"
- name: defaultInt
in: query
schema:
default: 1
type: integer
- name: defaultNum
in: query
schema:
default: 1.5
type: number
- name: defaultStr
in: query
schema:
default: default
type: string
- name: status
in: query
description: Status values that need to be considered for filter
Expand Down Expand Up @@ -616,9 +631,9 @@ paths:
required: true
schema:
type: string
- name: boolean_test
- name: remember_me
in: query
description: The password for login in clear text
description: Remember Me
schema:
type: boolean
responses:
Expand Down Expand Up @@ -731,9 +746,9 @@ paths:
required: true
schema:
type: string
- name: boolean_test # to ensure boolean query parameter won't cause compilation errors
- name: confirmation # to ensure boolean query parameter won't cause compilation errors
in: query
description: boolean query parameter
description: Confirm the deletion
schema:
type: boolean
responses:
Expand Down
32 changes: 28 additions & 4 deletions samples/server/petstore/go-api-server/api/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,30 @@ paths:
- OPTION_3
type: string
style: form
- explode: true
in: query
name: defaultInt
required: false
schema:
default: 1
type: integer
style: form
- explode: true
in: query
name: defaultNum
required: false
schema:
default: 1.5
type: number
style: form
- explode: true
in: query
name: defaultStr
required: false
schema:
default: default
type: string
style: form
- deprecated: true
description: Status values that need to be considered for filter
explode: false
Expand Down Expand Up @@ -631,10 +655,10 @@ paths:
schema:
type: string
style: form
- description: The password for login in clear text
- description: Remember Me
explode: true
in: query
name: boolean_test
name: remember_me
required: false
schema:
type: boolean
Expand Down Expand Up @@ -702,10 +726,10 @@ paths:
schema:
type: string
style: simple
- description: boolean query parameter
- description: Confirm the deletion
explode: true
in: query
name: boolean_test
name: confirmation
required: false
schema:
type: boolean
Expand Down
2 changes: 1 addition & 1 deletion samples/server/petstore/go-api-server/go/api.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

43 changes: 42 additions & 1 deletion samples/server/petstore/go-api-server/go/api_pet.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 10 additions & 10 deletions samples/server/petstore/go-api-server/go/api_user.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions samples/server/petstore/go-api-server/go/api_user_service.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

32 changes: 28 additions & 4 deletions samples/server/petstore/go-chi-server/api/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,30 @@ paths:
- OPTION_3
type: string
style: form
- explode: true
in: query
name: defaultInt
required: false
schema:
default: 1
type: integer
style: form
- explode: true
in: query
name: defaultNum
required: false
schema:
default: 1.5
type: number
style: form
- explode: true
in: query
name: defaultStr
required: false
schema:
default: default
type: string
style: form
- deprecated: true
description: Status values that need to be considered for filter
explode: false
Expand Down Expand Up @@ -631,10 +655,10 @@ paths:
schema:
type: string
style: form
- description: The password for login in clear text
- description: Remember Me
explode: true
in: query
name: boolean_test
name: remember_me
required: false
schema:
type: boolean
Expand Down Expand Up @@ -702,10 +726,10 @@ paths:
schema:
type: string
style: simple
- description: boolean query parameter
- description: Confirm the deletion
explode: true
in: query
name: boolean_test
name: confirmation
required: false
schema:
type: boolean
Expand Down
2 changes: 1 addition & 1 deletion samples/server/petstore/go-chi-server/go/api.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

43 changes: 42 additions & 1 deletion samples/server/petstore/go-chi-server/go/api_pet.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit cefbf62

Please sign in to comment.