Skip to content
Merged
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 @@ -169,7 +169,7 @@ func (c *{{classname}}Controller) {{nickname}}(w http.ResponseWriter, r *http.Re
}
{{/isInteger}}
{{#isDateTime}}
{{paramName}}Param, err := time.Parse(time.RFC3339, {{#routers}}{{#mux}}params["{{baseName}}"]{{/mux}}{{#chi}}chi.URLParam(r, "{{baseName}}"){{/chi}}{{/routers}})
{{paramName}}Param, err := parseTime({{#routers}}{{#mux}}params["{{baseName}}"]{{/mux}}{{#chi}}chi.URLParam(r, "{{baseName}}"){{/chi}}{{/routers}})
if err != nil {
c.errorHandler(w, r, &ParsingError{Err: err}, nil)
return
Expand All @@ -180,6 +180,7 @@ func (c *{{classname}}Controller) {{nickname}}(w http.ResponseWriter, r *http.Re
{{^isDouble}}
{{^isLong}}
{{^isInteger}}
{{^isDateTime}}
{{^isEnumOrRef}}
{{paramName}}Param := {{#routers}}{{#mux}}params["{{baseName}}"]{{/mux}}{{#chi}}chi.URLParam(r, "{{baseName}}"){{/chi}}{{/routers}}
{{/isEnumOrRef}}
Expand All @@ -190,6 +191,7 @@ func (c *{{classname}}Controller) {{nickname}}(w http.ResponseWriter, r *http.Re
return
}
{{/isEnumOrRef}}
{{/isDateTime}}
{{/isInteger}}
{{/isLong}}
{{/isDouble}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -745,6 +745,26 @@ paths:
application/json:
schema:
$ref: '#/components/schemas/ApiResponse'
/pets/byTime/{createdTime}:
get:
tags:
- pet
summary: Get the pets by time
operationId: GetPetsByTime
parameters:
- in: path
name: createdTime
required: true
schema:
type: string
format: date-time
responses:
'200':
description: successful operation
content:
application/json:
schema:
$ref: '#/components/schemas/ApiResponse'
externalDocs:
description: Find out more about Swagger
url: 'http://swagger.io'
Expand Down
22 changes: 22 additions & 0 deletions samples/server/petstore/go-api-server/api/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -761,6 +761,28 @@ paths:
summary: Get the pets by only using boolean query parameters
tags:
- pet
/pets/byTime/{createdTime}:
get:
operationId: GetPetsByTime
parameters:
- explode: false
in: path
name: createdTime
required: true
schema:
format: date-time
type: string
style: simple
responses:
"200":
content:
application/json:
schema:
$ref: '#/components/schemas/ApiResponse'
description: successful operation
summary: Get the pets by time
tags:
- pet
components:
requestBodies:
UserArray:
Expand Down
2 changes: 2 additions & 0 deletions samples/server/petstore/go-api-server/go/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ type PetAPIRouter interface {
FindPetsByTags(http.ResponseWriter, *http.Request)
GetPetById(http.ResponseWriter, *http.Request)
GetPetImageById(http.ResponseWriter, *http.Request)
GetPetsByTime(http.ResponseWriter, *http.Request)
GetPetsUsingBooleanQueryParameters(http.ResponseWriter, *http.Request)
UpdatePet(http.ResponseWriter, *http.Request)
UpdatePetWithForm(http.ResponseWriter, *http.Request)
Expand Down Expand Up @@ -73,6 +74,7 @@ type PetAPIServicer interface {
FindPetsByTags(context.Context, []string, time.Time, time.Time) (ImplResponse, error)
GetPetById(context.Context, int64) (ImplResponse, error)
GetPetImageById(context.Context, int64) (ImplResponse, error)
GetPetsByTime(context.Context, time.Time) (ImplResponse, error)
GetPetsUsingBooleanQueryParameters(context.Context, bool, bool, bool) (ImplResponse, error)
UpdatePet(context.Context, Pet) (ImplResponse, error)
UpdatePetWithForm(context.Context, int64, string, string) (ImplResponse, error)
Expand Down
23 changes: 23 additions & 0 deletions samples/server/petstore/go-api-server/go/api_pet.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,11 @@ func (c *PetAPIController) Routes() Routes {
"/v2/pet/{petId}/uploadImage",
c.GetPetImageById,
},
"GetPetsByTime": Route{
strings.ToUpper("Get"),
"/v2/pets/byTime/{createdTime}",
c.GetPetsByTime,
},
"GetPetsUsingBooleanQueryParameters": Route{
strings.ToUpper("Get"),
"/v2/pets/boolean/parsing",
Expand Down Expand Up @@ -294,6 +299,24 @@ func (c *PetAPIController) GetPetImageById(w http.ResponseWriter, r *http.Reques
EncodeJSONResponse(result.Body, &result.Code, result.Headers, w)
}

// GetPetsByTime - Get the pets by time
func (c *PetAPIController) GetPetsByTime(w http.ResponseWriter, r *http.Request) {
params := mux.Vars(r)
createdTimeParam, err := parseTime(params["createdTime"])
if err != nil {
c.errorHandler(w, r, &ParsingError{Err: err}, nil)
return
}
result, err := c.service.GetPetsByTime(r.Context(), createdTimeParam)
// If an error occurred, encode the error with the status code
if err != nil {
c.errorHandler(w, r, err, &result)
return
}
// If no error, encode the body and the result code
EncodeJSONResponse(result.Body, &result.Code, result.Headers, w)
}

// GetPetsUsingBooleanQueryParameters - Get the pets by only using boolean query parameters
func (c *PetAPIController) GetPetsUsingBooleanQueryParameters(w http.ResponseWriter, r *http.Request) {
query := r.URL.Query()
Expand Down
11 changes: 11 additions & 0 deletions samples/server/petstore/go-api-server/go/api_pet_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,17 @@ func (s *PetAPIService) GetPetImageById(ctx context.Context, petId int64) (ImplR
return Response(http.StatusNotImplemented, nil), errors.New("GetPetImageById method not implemented")
}

// GetPetsByTime - Get the pets by time
func (s *PetAPIService) GetPetsByTime(ctx context.Context, createdTime time.Time) (ImplResponse, error) {
// TODO - update GetPetsByTime 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.

// TODO: Uncomment the next line to return response Response(200, ApiResponse{}) or use other options such as http.Ok ...
// return Response(200, ApiResponse{}), nil

return Response(http.StatusNotImplemented, nil), errors.New("GetPetsByTime method not implemented")
}

// GetPetsUsingBooleanQueryParameters - Get the pets by only using boolean query parameters
func (s *PetAPIService) GetPetsUsingBooleanQueryParameters(ctx context.Context, expr bool, grouping bool, inactive bool) (ImplResponse, error) {
// TODO - update GetPetsUsingBooleanQueryParameters with the required logic for this service method.
Expand Down
22 changes: 22 additions & 0 deletions samples/server/petstore/go-chi-server/api/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -761,6 +761,28 @@ paths:
summary: Get the pets by only using boolean query parameters
tags:
- pet
/pets/byTime/{createdTime}:
get:
operationId: GetPetsByTime
parameters:
- explode: false
in: path
name: createdTime
required: true
schema:
format: date-time
type: string
style: simple
responses:
"200":
content:
application/json:
schema:
$ref: '#/components/schemas/ApiResponse'
description: successful operation
summary: Get the pets by time
tags:
- pet
components:
requestBodies:
UserArray:
Expand Down
2 changes: 2 additions & 0 deletions samples/server/petstore/go-chi-server/go/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ type PetAPIRouter interface {
FindPetsByTags(http.ResponseWriter, *http.Request)
GetPetById(http.ResponseWriter, *http.Request)
GetPetImageById(http.ResponseWriter, *http.Request)
GetPetsByTime(http.ResponseWriter, *http.Request)
GetPetsUsingBooleanQueryParameters(http.ResponseWriter, *http.Request)
UpdatePet(http.ResponseWriter, *http.Request)
UpdatePetWithForm(http.ResponseWriter, *http.Request)
Expand Down Expand Up @@ -73,6 +74,7 @@ type PetAPIServicer interface {
FindPetsByTags(context.Context, []string, time.Time, time.Time) (ImplResponse, error)
GetPetById(context.Context, int64) (ImplResponse, error)
GetPetImageById(context.Context, int64) (ImplResponse, error)
GetPetsByTime(context.Context, time.Time) (ImplResponse, error)
GetPetsUsingBooleanQueryParameters(context.Context, bool, bool, bool) (ImplResponse, error)
UpdatePet(context.Context, Pet) (ImplResponse, error)
UpdatePetWithForm(context.Context, int64, string, string) (ImplResponse, error)
Expand Down
22 changes: 22 additions & 0 deletions samples/server/petstore/go-chi-server/go/api_pet.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,11 @@ func (c *PetAPIController) Routes() Routes {
"/v2/pet/{petId}/uploadImage",
c.GetPetImageById,
},
"GetPetsByTime": Route{
strings.ToUpper("Get"),
"/v2/pets/byTime/{createdTime}",
c.GetPetsByTime,
},
"GetPetsUsingBooleanQueryParameters": Route{
strings.ToUpper("Get"),
"/v2/pets/boolean/parsing",
Expand Down Expand Up @@ -290,6 +295,23 @@ func (c *PetAPIController) GetPetImageById(w http.ResponseWriter, r *http.Reques
EncodeJSONResponse(result.Body, &result.Code, result.Headers, w)
}

// GetPetsByTime - Get the pets by time
func (c *PetAPIController) GetPetsByTime(w http.ResponseWriter, r *http.Request) {
createdTimeParam, err := parseTime(chi.URLParam(r, "createdTime"))
if err != nil {
c.errorHandler(w, r, &ParsingError{Err: err}, nil)
return
}
result, err := c.service.GetPetsByTime(r.Context(), createdTimeParam)
// If an error occurred, encode the error with the status code
if err != nil {
c.errorHandler(w, r, err, &result)
return
}
// If no error, encode the body and the result code
EncodeJSONResponse(result.Body, &result.Code, result.Headers, w)
}

// GetPetsUsingBooleanQueryParameters - Get the pets by only using boolean query parameters
func (c *PetAPIController) GetPetsUsingBooleanQueryParameters(w http.ResponseWriter, r *http.Request) {
query := r.URL.Query()
Expand Down
11 changes: 11 additions & 0 deletions samples/server/petstore/go-chi-server/go/api_pet_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,17 @@ func (s *PetAPIService) GetPetImageById(ctx context.Context, petId int64) (ImplR
return Response(http.StatusNotImplemented, nil), errors.New("GetPetImageById method not implemented")
}

// GetPetsByTime - Get the pets by time
func (s *PetAPIService) GetPetsByTime(ctx context.Context, createdTime time.Time) (ImplResponse, error) {
// TODO - update GetPetsByTime 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.

// TODO: Uncomment the next line to return response Response(200, ApiResponse{}) or use other options such as http.Ok ...
// return Response(200, ApiResponse{}), nil

return Response(http.StatusNotImplemented, nil), errors.New("GetPetsByTime method not implemented")
}

// GetPetsUsingBooleanQueryParameters - Get the pets by only using boolean query parameters
func (s *PetAPIService) GetPetsUsingBooleanQueryParameters(ctx context.Context, expr bool, grouping bool, inactive bool) (ImplResponse, error) {
// TODO - update GetPetsUsingBooleanQueryParameters with the required logic for this service method.
Expand Down