From 494d625732e6f2827a4877c6a50285f7dfba8cc3 Mon Sep 17 00:00:00 2001 From: Kyle Ellrott Date: Tue, 21 Dec 2021 13:58:26 -0800 Subject: [PATCH 1/2] Fixing go-server get param typecasting if variable enum of string --- .../src/main/resources/go-server/controller-api.mustache | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/openapi-generator/src/main/resources/go-server/controller-api.mustache b/modules/openapi-generator/src/main/resources/go-server/controller-api.mustache index dfc0fd049a28..a4612a3cd80a 100644 --- a/modules/openapi-generator/src/main/resources/go-server/controller-api.mustache +++ b/modules/openapi-generator/src/main/resources/go-server/controller-api.mustache @@ -133,7 +133,7 @@ func (c *{{classname}}Controller) {{nickname}}(w http.ResponseWriter, r *http.Re {{^isLong}} {{^isInteger}} {{^isBoolean}} - {{paramName}}Param := {{#isArray}}strings.Split({{/isArray}}query.Get("{{baseName}}"){{#isArray}}, ","){{/isArray}} + {{paramName}}Param := {{^isString}}{{dataType}}( {{/isString}}{{#isArray}}strings.Split({{/isArray}}query.Get("{{baseName}}"){{#isArray}}, ","){{/isArray}}{{^isString}} ){{/isString}} {{/isBoolean}} {{/isInteger}} {{/isLong}} From 161ee332ddcdb50c83b588292f3127e68fc2c8d5 Mon Sep 17 00:00:00 2001 From: Kyle Ellrott Date: Tue, 21 Dec 2021 14:37:19 -0800 Subject: [PATCH 2/2] Adding generated files --- samples/server/petstore/go-api-server/go/api_pet.go | 4 ++-- samples/server/petstore/go-chi-server/go/api_pet.go | 4 ++-- samples/server/petstore/go-server-required/go/api_pet.go | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/samples/server/petstore/go-api-server/go/api_pet.go b/samples/server/petstore/go-api-server/go/api_pet.go index 537cdb586954..4a58e972ba21 100644 --- a/samples/server/petstore/go-api-server/go/api_pet.go +++ b/samples/server/petstore/go-api-server/go/api_pet.go @@ -149,7 +149,7 @@ func (c *PetApiController) DeletePet(w http.ResponseWriter, r *http.Request) { // FindPetsByStatus - Finds Pets by status func (c *PetApiController) FindPetsByStatus(w http.ResponseWriter, r *http.Request) { query := r.URL.Query() - statusParam := strings.Split(query.Get("status"), ",") + statusParam := []string( strings.Split(query.Get("status"), ",") ) result, err := c.service.FindPetsByStatus(r.Context(), statusParam) // If an error occurred, encode the error with the status code if err != nil { @@ -165,7 +165,7 @@ func (c *PetApiController) FindPetsByStatus(w http.ResponseWriter, r *http.Reque // Deprecated func (c *PetApiController) FindPetsByTags(w http.ResponseWriter, r *http.Request) { query := r.URL.Query() - tagsParam := strings.Split(query.Get("tags"), ",") + tagsParam := []string( strings.Split(query.Get("tags"), ",") ) result, err := c.service.FindPetsByTags(r.Context(), tagsParam) // If an error occurred, encode the error with the status code if err != nil { diff --git a/samples/server/petstore/go-chi-server/go/api_pet.go b/samples/server/petstore/go-chi-server/go/api_pet.go index 5fc093d2ef9c..e9236f956cfb 100644 --- a/samples/server/petstore/go-chi-server/go/api_pet.go +++ b/samples/server/petstore/go-chi-server/go/api_pet.go @@ -148,7 +148,7 @@ func (c *PetApiController) DeletePet(w http.ResponseWriter, r *http.Request) { // FindPetsByStatus - Finds Pets by status func (c *PetApiController) FindPetsByStatus(w http.ResponseWriter, r *http.Request) { query := r.URL.Query() - statusParam := strings.Split(query.Get("status"), ",") + statusParam := []string( strings.Split(query.Get("status"), ",") ) result, err := c.service.FindPetsByStatus(r.Context(), statusParam) // If an error occurred, encode the error with the status code if err != nil { @@ -164,7 +164,7 @@ func (c *PetApiController) FindPetsByStatus(w http.ResponseWriter, r *http.Reque // Deprecated func (c *PetApiController) FindPetsByTags(w http.ResponseWriter, r *http.Request) { query := r.URL.Query() - tagsParam := strings.Split(query.Get("tags"), ",") + tagsParam := []string( strings.Split(query.Get("tags"), ",") ) result, err := c.service.FindPetsByTags(r.Context(), tagsParam) // If an error occurred, encode the error with the status code if err != nil { diff --git a/samples/server/petstore/go-server-required/go/api_pet.go b/samples/server/petstore/go-server-required/go/api_pet.go index 5fc093d2ef9c..e9236f956cfb 100644 --- a/samples/server/petstore/go-server-required/go/api_pet.go +++ b/samples/server/petstore/go-server-required/go/api_pet.go @@ -148,7 +148,7 @@ func (c *PetApiController) DeletePet(w http.ResponseWriter, r *http.Request) { // FindPetsByStatus - Finds Pets by status func (c *PetApiController) FindPetsByStatus(w http.ResponseWriter, r *http.Request) { query := r.URL.Query() - statusParam := strings.Split(query.Get("status"), ",") + statusParam := []string( strings.Split(query.Get("status"), ",") ) result, err := c.service.FindPetsByStatus(r.Context(), statusParam) // If an error occurred, encode the error with the status code if err != nil { @@ -164,7 +164,7 @@ func (c *PetApiController) FindPetsByStatus(w http.ResponseWriter, r *http.Reque // Deprecated func (c *PetApiController) FindPetsByTags(w http.ResponseWriter, r *http.Request) { query := r.URL.Query() - tagsParam := strings.Split(query.Get("tags"), ",") + tagsParam := []string( strings.Split(query.Get("tags"), ",") ) result, err := c.service.FindPetsByTags(r.Context(), tagsParam) // If an error occurred, encode the error with the status code if err != nil {