From b7f31ddda4d52f450748349404016f5041f5495f Mon Sep 17 00:00:00 2001 From: Ween Jiann <16207788+lwj5@users.noreply.github.com> Date: Wed, 13 Dec 2023 22:17:15 +0800 Subject: [PATCH] Regenerate (#17389) --- .../resources/3_0/go-server/petstore.yaml | 18 ++++++++++++++ .../petstore/go-api-server/api/openapi.yaml | 24 +++++++++++++++++++ .../server/petstore/go-api-server/go/api.go | 2 +- .../petstore/go-api-server/go/api_pet.go | 12 +++++++++- .../go-api-server/go/api_pet_service.go | 2 +- .../petstore/go-chi-server/api/openapi.yaml | 24 +++++++++++++++++++ .../server/petstore/go-chi-server/go/api.go | 2 +- .../petstore/go-chi-server/go/api_pet.go | 11 ++++++++- .../go-chi-server/go/api_pet_service.go | 2 +- 9 files changed, 91 insertions(+), 6 deletions(-) diff --git a/modules/openapi-generator/src/test/resources/3_0/go-server/petstore.yaml b/modules/openapi-generator/src/test/resources/3_0/go-server/petstore.yaml index 90dca1b2166f..0bd685cdebda 100644 --- a/modules/openapi-generator/src/test/resources/3_0/go-server/petstore.yaml +++ b/modules/openapi-generator/src/test/resources/3_0/go-server/petstore.yaml @@ -82,6 +82,24 @@ paths: description: Multiple status values can be provided with comma separated strings operationId: findPetsByStatus parameters: + - name: inlineEnumPath + in: path + description: Entity type + schema: + type: string + enum: + - "OPTION_1" + - "OPTION_2" + - "OPTION_3" + - name: inlineEnum + in: query + description: Entity type + schema: + type: string + enum: + - "OPTION_1" + - "OPTION_2" + - "OPTION_3" - name: status in: query description: Status values that need to be considered for filter diff --git a/samples/server/petstore/go-api-server/api/openapi.yaml b/samples/server/petstore/go-api-server/api/openapi.yaml index 3afede1048dc..cb090444eb23 100644 --- a/samples/server/petstore/go-api-server/api/openapi.yaml +++ b/samples/server/petstore/go-api-server/api/openapi.yaml @@ -81,6 +81,30 @@ paths: description: Multiple status values can be provided with comma separated strings operationId: findPetsByStatus parameters: + - description: Entity type + explode: false + in: path + name: inlineEnumPath + required: false + schema: + enum: + - OPTION_1 + - OPTION_2 + - OPTION_3 + type: string + style: simple + - description: Entity type + explode: true + in: query + name: inlineEnum + required: false + schema: + enum: + - OPTION_1 + - OPTION_2 + - OPTION_3 + type: string + style: form - deprecated: true description: Status values that need to be considered for filter explode: false diff --git a/samples/server/petstore/go-api-server/go/api.go b/samples/server/petstore/go-api-server/go/api.go index 2dab3b169782..5f20c59393fa 100644 --- a/samples/server/petstore/go-api-server/go/api.go +++ b/samples/server/petstore/go-api-server/go/api.go @@ -69,7 +69,7 @@ type PetAPIServicer interface { AddPet(context.Context, Pet) (ImplResponse, error) DeletePet(context.Context, int64, string) (ImplResponse, error) FilterPetsByCategory(context.Context, Gender, Species, []Species) (ImplResponse, error) - FindPetsByStatus(context.Context, []string) (ImplResponse, error) + FindPetsByStatus(context.Context, []string, string, string) (ImplResponse, error) // Deprecated FindPetsByTags(context.Context, []string, time.Time, time.Time) (ImplResponse, error) GetPetById(context.Context, int64) (ImplResponse, error) 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 68780fcff4bc..a25dc2236b1c 100644 --- a/samples/server/petstore/go-api-server/go/api_pet.go +++ b/samples/server/petstore/go-api-server/go/api_pet.go @@ -210,12 +210,22 @@ func (c *PetAPIController) FilterPetsByCategory(w http.ResponseWriter, r *http.R // FindPetsByStatus - Finds Pets by status func (c *PetAPIController) FindPetsByStatus(w http.ResponseWriter, r *http.Request) { + params := mux.Vars(r) query := r.URL.Query() var statusParam []string if query.Has("status") { statusParam = strings.Split(query.Get("status"), ",") } - result, err := c.service.FindPetsByStatus(r.Context(), statusParam) + inlineEnumPathParam := params["inlineEnumPath"] + if inlineEnumPathParam == "" { + c.errorHandler(w, r, &RequiredError{"inlineEnumPath"}, nil) + return + } + var inlineEnumParam string + if query.Has("inlineEnum") { + inlineEnumParam = query.Get("inlineEnum") + } + result, err := c.service.FindPetsByStatus(r.Context(), statusParam, inlineEnumPathParam, inlineEnumParam) // If an error occurred, encode the error with the status code if err != nil { c.errorHandler(w, r, err, &result) diff --git a/samples/server/petstore/go-api-server/go/api_pet_service.go b/samples/server/petstore/go-api-server/go/api_pet_service.go index a63455b2ba4c..a2399cce2108 100644 --- a/samples/server/petstore/go-api-server/go/api_pet_service.go +++ b/samples/server/petstore/go-api-server/go/api_pet_service.go @@ -68,7 +68,7 @@ func (s *PetAPIService) FilterPetsByCategory(ctx context.Context, gender Gender, } // FindPetsByStatus - Finds Pets by status -func (s *PetAPIService) FindPetsByStatus(ctx context.Context, status []string) (ImplResponse, error) { +func (s *PetAPIService) FindPetsByStatus(ctx context.Context, status []string, inlineEnumPath string, inlineEnum string) (ImplResponse, error) { // TODO - update FindPetsByStatus with the required logic for this service method. // Add api_pet_service.go to the .openapi-generator-ignore to avoid overwriting this service implementation when updating open api generation. diff --git a/samples/server/petstore/go-chi-server/api/openapi.yaml b/samples/server/petstore/go-chi-server/api/openapi.yaml index 3afede1048dc..cb090444eb23 100644 --- a/samples/server/petstore/go-chi-server/api/openapi.yaml +++ b/samples/server/petstore/go-chi-server/api/openapi.yaml @@ -81,6 +81,30 @@ paths: description: Multiple status values can be provided with comma separated strings operationId: findPetsByStatus parameters: + - description: Entity type + explode: false + in: path + name: inlineEnumPath + required: false + schema: + enum: + - OPTION_1 + - OPTION_2 + - OPTION_3 + type: string + style: simple + - description: Entity type + explode: true + in: query + name: inlineEnum + required: false + schema: + enum: + - OPTION_1 + - OPTION_2 + - OPTION_3 + type: string + style: form - deprecated: true description: Status values that need to be considered for filter explode: false diff --git a/samples/server/petstore/go-chi-server/go/api.go b/samples/server/petstore/go-chi-server/go/api.go index 2dab3b169782..5f20c59393fa 100644 --- a/samples/server/petstore/go-chi-server/go/api.go +++ b/samples/server/petstore/go-chi-server/go/api.go @@ -69,7 +69,7 @@ type PetAPIServicer interface { AddPet(context.Context, Pet) (ImplResponse, error) DeletePet(context.Context, int64, string) (ImplResponse, error) FilterPetsByCategory(context.Context, Gender, Species, []Species) (ImplResponse, error) - FindPetsByStatus(context.Context, []string) (ImplResponse, error) + FindPetsByStatus(context.Context, []string, string, string) (ImplResponse, error) // Deprecated FindPetsByTags(context.Context, []string, time.Time, time.Time) (ImplResponse, error) GetPetById(context.Context, int64) (ImplResponse, error) 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 68d5bbcd057e..0d24fea34f36 100644 --- a/samples/server/petstore/go-chi-server/go/api_pet.go +++ b/samples/server/petstore/go-chi-server/go/api_pet.go @@ -213,7 +213,16 @@ func (c *PetAPIController) FindPetsByStatus(w http.ResponseWriter, r *http.Reque if query.Has("status") { statusParam = strings.Split(query.Get("status"), ",") } - result, err := c.service.FindPetsByStatus(r.Context(), statusParam) + inlineEnumPathParam := chi.URLParam(r, "inlineEnumPath") + if inlineEnumPathParam == "" { + c.errorHandler(w, r, &RequiredError{"inlineEnumPath"}, nil) + return + } + var inlineEnumParam string + if query.Has("inlineEnum") { + inlineEnumParam = query.Get("inlineEnum") + } + result, err := c.service.FindPetsByStatus(r.Context(), statusParam, inlineEnumPathParam, inlineEnumParam) // If an error occurred, encode the error with the status code if err != nil { c.errorHandler(w, r, err, &result) diff --git a/samples/server/petstore/go-chi-server/go/api_pet_service.go b/samples/server/petstore/go-chi-server/go/api_pet_service.go index a63455b2ba4c..a2399cce2108 100644 --- a/samples/server/petstore/go-chi-server/go/api_pet_service.go +++ b/samples/server/petstore/go-chi-server/go/api_pet_service.go @@ -68,7 +68,7 @@ func (s *PetAPIService) FilterPetsByCategory(ctx context.Context, gender Gender, } // FindPetsByStatus - Finds Pets by status -func (s *PetAPIService) FindPetsByStatus(ctx context.Context, status []string) (ImplResponse, error) { +func (s *PetAPIService) FindPetsByStatus(ctx context.Context, status []string, inlineEnumPath string, inlineEnum string) (ImplResponse, error) { // TODO - update FindPetsByStatus with the required logic for this service method. // Add api_pet_service.go to the .openapi-generator-ignore to avoid overwriting this service implementation when updating open api generation.