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

[BUG][Go-server] attempt to fix the controller-api mustache template for a nullable bodyParam #20478

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -624,7 +624,7 @@ func (c *{{classname}}Controller) {{nickname}}(w http.ResponseWriter, r *http.Re
{{/isArray}}
{{/isBodyParam}}
{{/allParams}}
result, err := c.service.{{nickname}}(r.Context(){{#allParams}}, {{paramName}}Param{{/allParams}})
result, err := c.service.{{nickname}}(r.Context(){{#allParams}}, {{#isNullable}}{{#isBodyParam}}&{{/isBodyParam}}{{/isNullable}}{{paramName}}Param{{/allParams}})
// If an error occurred, encode the error with the status code
if err != nil {
c.errorHandler(w, r, err, &result)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -582,6 +582,24 @@ paths:
$ref: '#/components/schemas/User'
description: Created user object
required: true
put:
tags:
- user
summary: Create user
description: This can only be done by the logged in user.
operationId: createUserNullable
responses:
default:
description: successful operation
security:
- api_key: []
requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/UserNullable'
description: Created user object, with a nullable bodyParam
required: true
/user/createWithArray:
post:
tags:
Expand Down Expand Up @@ -1052,6 +1070,66 @@ components:
name: User
required:
- deepSliceModel
UserNullable:
title: a User
description: A User who is purchasing from the pet store
type: object
nullable: true
properties:
id:
type: integer
format: int64
username:
type: string
firstName:
type: string
lastName:
type: string
email:
type: string
password:
type: string
phone:
type: string
nullable: true
userStatus:
type: integer
format: int32
description: User Status
deepSliceModel:
nullable: true
type: array
description: An array 1-deep.
items:
type: array
description: An array 2-deep.
items:
type: array
description: An array 3-deep.
items:
$ref: '#/components/schemas/Tag'
deepSliceMap:
type: array
description: An array 1-deep.
items:
type: array
description: An array 2-deep.
items:
title: an Object
type: object
description: An array 3-deep.
properties:
tag:
$ref: '#/components/schemas/Tag'
Pet:
type: array
description: An array of pet.
items:
$ref: '#/components/schemas/Pet'
xml:
name: User
required:
- deepSliceModel
Tag:
title: Pet Tag
description: A tag for a pet
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,6 @@ go/model_special_info.go
go/model_species.go
go/model_tag.go
go/model_user.go
go/model_user_nullable.go
go/routers.go
main.go
223 changes: 223 additions & 0 deletions samples/server/petstore/go-api-server/api/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -605,6 +605,24 @@ paths:
summary: Create user
tags:
- user
put:
description: This can only be done by the logged in user.
operationId: createUserNullable
requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/UserNullable'
description: "Created user object, with a nullable bodyParam"
required: true
responses:
default:
description: successful operation
security:
- api_key: []
summary: Create user
tags:
- user
/user/createWithArray:
post:
description: ""
Expand Down Expand Up @@ -1240,6 +1258,211 @@ components:
type: object
xml:
name: User
UserNullable:
description: A User who is purchasing from the pet store
example:
firstName: firstName
lastName: lastName
password: password
userStatus: 6
phone: phone
deepSliceModel:
- - - name: name
id: 1
- name: name
id: 1
- - name: name
id: 1
- name: name
id: 1
- - - name: name
id: 1
- name: name
id: 1
- - name: name
id: 1
- name: name
id: 1
id: 0
deepSliceMap:
- - tag:
name: name
id: 1
Pet:
- photoUrls:
- photoUrls
- photoUrls
name: doggie
id: 0
category:
name: name
id: 6
tags:
- name: name
id: 1
- name: name
id: 1
status: available
- photoUrls:
- photoUrls
- photoUrls
name: doggie
id: 0
category:
name: name
id: 6
tags:
- name: name
id: 1
- name: name
id: 1
status: available
- tag:
name: name
id: 1
Pet:
- photoUrls:
- photoUrls
- photoUrls
name: doggie
id: 0
category:
name: name
id: 6
tags:
- name: name
id: 1
- name: name
id: 1
status: available
- photoUrls:
- photoUrls
- photoUrls
name: doggie
id: 0
category:
name: name
id: 6
tags:
- name: name
id: 1
- name: name
id: 1
status: available
- - tag:
name: name
id: 1
Pet:
- photoUrls:
- photoUrls
- photoUrls
name: doggie
id: 0
category:
name: name
id: 6
tags:
- name: name
id: 1
- name: name
id: 1
status: available
- photoUrls:
- photoUrls
- photoUrls
name: doggie
id: 0
category:
name: name
id: 6
tags:
- name: name
id: 1
- name: name
id: 1
status: available
- tag:
name: name
id: 1
Pet:
- photoUrls:
- photoUrls
- photoUrls
name: doggie
id: 0
category:
name: name
id: 6
tags:
- name: name
id: 1
- name: name
id: 1
status: available
- photoUrls:
- photoUrls
- photoUrls
name: doggie
id: 0
category:
name: name
id: 6
tags:
- name: name
id: 1
- name: name
id: 1
status: available
email: email
username: username
nullable: true
properties:
id:
format: int64
type: integer
username:
type: string
firstName:
type: string
lastName:
type: string
email:
type: string
password:
type: string
phone:
nullable: true
type: string
userStatus:
description: User Status
format: int32
type: integer
deepSliceModel:
description: An array 1-deep.
items:
description: An array 2-deep.
items:
description: An array 3-deep.
items:
$ref: '#/components/schemas/Tag'
type: array
type: array
nullable: true
type: array
deepSliceMap:
description: An array 1-deep.
items:
description: An array 2-deep.
items:
$ref: '#/components/schemas/an_Object'
type: array
type: array
required:
- deepSliceModel
title: a User
type: object
xml:
name: User
Tag:
description: A tag for a pet
example:
Expand Down
2 changes: 2 additions & 0 deletions 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.

Loading
Loading