Skip to content

Commit

Permalink
Parse integer array query parameters. Fix typos (OpenAPITools#11105)
Browse files Browse the repository at this point in the history
  • Loading branch information
aliakseiz authored Jan 4, 2022
1 parent 161de2c commit 9c3d4ef
Show file tree
Hide file tree
Showing 22 changed files with 56 additions and 33 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ type {{classname}}Router interface { {{#operations}}{{#operation}}

// {{classname}}Servicer defines the api actions for the {{classname}} service
// This interface intended to stay up to date with the openapi yaml used to generate it,
// while the service implementation can ignored with the .openapi-generator-ignore file
// while the service implementation can be ignored with the .openapi-generator-ignore file
// and updated with the logic required for the API.
type {{classname}}Servicer interface { {{#operations}}{{#operation}}
{{#isDeprecated}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ func New{{classname}}Controller(s {{classname}}Servicer, opts ...{{classname}}Op
return controller
}

// Routes returns all of the api route for the {{classname}}Controller
// Routes returns all the api routes for the {{classname}}Controller
func (c *{{classname}}Controller) Routes() Routes {
return Routes{ {{#operations}}{{#operation}}
{
Expand Down Expand Up @@ -130,10 +130,33 @@ func (c *{{classname}}Controller) {{nickname}}(w http.ResponseWriter, r *http.Re
return
}
{{/isBoolean}}
{{#isArray}}
{{#items.isLong}}
{{paramName}}Param, err := parseInt64ArrayParameter(query.Get("{{baseName}}"), ",", {{required}})
if err != nil {
c.errorHandler(w, r, &ParsingError{Err: err}, nil)
return
}
{{/items.isLong}}
{{#items.isInteger}}
{{paramName}}Param, err := parseInt32ArrayParameter(query.Get("{{baseName}}"), ",", {{required}})
if err != nil {
c.errorHandler(w, r, &ParsingError{Err: err}, nil)
return
}
{{/items.isInteger}}
{{^items.isLong}}
{{^items.isInteger}}
{{paramName}}Param := strings.Split(query.Get("{{baseName}}"), ",")
{{/items.isInteger}}
{{/items.isLong}}
{{/isArray}}
{{^isLong}}
{{^isInteger}}
{{^isBoolean}}
{{paramName}}Param := {{#isArray}}strings.Split({{/isArray}}query.Get("{{baseName}}"){{#isArray}}, ","){{/isArray}}
{{^isArray}}
{{paramName}}Param := query.Get("{{baseName}}")
{{/isArray}}
{{/isBoolean}}
{{/isInteger}}
{{/isLong}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,13 @@ func IsZeroValue(val interface{}) bool {
return val == nil || reflect.DeepEqual(val, reflect.Zero(reflect.TypeOf(val)).Interface())
}

// AssertInterfaceRequired recursively checks each struct in a slice against the callback.
// AssertRecurseInterfaceRequired recursively checks each struct in a slice against the callback.
// This method traverse nested slices in a preorder fashion.
func AssertRecurseInterfaceRequired(obj interface{}, callback func(interface{}) error) error {
return AssertRecurseValueRequired(reflect.ValueOf(obj), callback)
}

// AssertNestedValueRequired checks each struct in the nested slice against the callback.
// AssertRecurseValueRequired checks each struct in the nested slice against the callback.
// This method traverse nested slices in a preorder fashion.
func AssertRecurseValueRequired(value reflect.Value, callback func(interface{}) error) error {
switch value.Kind() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{{>partial_header}}
package {{packageName}}

//Implementation response defines an error code with the associated body
// ImplResponse response defines an error code with the associated body
type ImplResponse struct {
Code int
{{#addResponseHeaders}}
Expand Down
6 changes: 3 additions & 3 deletions samples/server/petstore/go-api-server/go/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ type UserApiRouter interface {

// PetApiServicer defines the api actions for the PetApi service
// This interface intended to stay up to date with the openapi yaml used to generate it,
// while the service implementation can ignored with the .openapi-generator-ignore file
// while the service implementation can be ignored with the .openapi-generator-ignore file
// and updated with the logic required for the API.
type PetApiServicer interface {
AddPet(context.Context, Pet) (ImplResponse, error)
Expand All @@ -74,7 +74,7 @@ type PetApiServicer interface {

// StoreApiServicer defines the api actions for the StoreApi service
// This interface intended to stay up to date with the openapi yaml used to generate it,
// while the service implementation can ignored with the .openapi-generator-ignore file
// while the service implementation can be ignored with the .openapi-generator-ignore file
// and updated with the logic required for the API.
type StoreApiServicer interface {
DeleteOrder(context.Context, string) (ImplResponse, error)
Expand All @@ -86,7 +86,7 @@ type StoreApiServicer interface {

// UserApiServicer defines the api actions for the UserApi service
// This interface intended to stay up to date with the openapi yaml used to generate it,
// while the service implementation can ignored with the .openapi-generator-ignore file
// while the service implementation can be ignored with the .openapi-generator-ignore file
// and updated with the logic required for the API.
type UserApiServicer interface {
CreateUser(context.Context, User) (ImplResponse, error)
Expand Down
2 changes: 1 addition & 1 deletion samples/server/petstore/go-api-server/go/api_pet.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ func NewPetApiController(s PetApiServicer, opts ...PetApiOption) Router {
return controller
}

// Routes returns all of the api route for the PetApiController
// Routes returns all the api routes for the PetApiController
func (c *PetApiController) Routes() Routes {
return Routes{
{
Expand Down
2 changes: 1 addition & 1 deletion samples/server/petstore/go-api-server/go/api_store.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ func NewStoreApiController(s StoreApiServicer, opts ...StoreApiOption) Router {
return controller
}

// Routes returns all of the api route for the StoreApiController
// Routes returns all the api routes for the StoreApiController
func (c *StoreApiController) Routes() Routes {
return Routes{
{
Expand Down
2 changes: 1 addition & 1 deletion samples/server/petstore/go-api-server/go/api_user.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ func NewUserApiController(s UserApiServicer, opts ...UserApiOption) Router {
return controller
}

// Routes returns all of the api route for the UserApiController
// Routes returns all the api routes for the UserApiController
func (c *UserApiController) Routes() Routes {
return Routes{
{
Expand Down
4 changes: 2 additions & 2 deletions samples/server/petstore/go-api-server/go/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,13 @@ func IsZeroValue(val interface{}) bool {
return val == nil || reflect.DeepEqual(val, reflect.Zero(reflect.TypeOf(val)).Interface())
}

// AssertInterfaceRequired recursively checks each struct in a slice against the callback.
// AssertRecurseInterfaceRequired recursively checks each struct in a slice against the callback.
// This method traverse nested slices in a preorder fashion.
func AssertRecurseInterfaceRequired(obj interface{}, callback func(interface{}) error) error {
return AssertRecurseValueRequired(reflect.ValueOf(obj), callback)
}

// AssertNestedValueRequired checks each struct in the nested slice against the callback.
// AssertRecurseValueRequired checks each struct in the nested slice against the callback.
// This method traverse nested slices in a preorder fashion.
func AssertRecurseValueRequired(value reflect.Value, callback func(interface{}) error) error {
switch value.Kind() {
Expand Down
2 changes: 1 addition & 1 deletion samples/server/petstore/go-api-server/go/impl.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

package petstoreserver

//Implementation response defines an error code with the associated body
// ImplResponse response defines an error code with the associated body
type ImplResponse struct {
Code int
Headers map[string][]string
Expand Down
6 changes: 3 additions & 3 deletions samples/server/petstore/go-chi-server/go/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ type UserApiRouter interface {

// PetApiServicer defines the api actions for the PetApi service
// This interface intended to stay up to date with the openapi yaml used to generate it,
// while the service implementation can ignored with the .openapi-generator-ignore file
// while the service implementation can be ignored with the .openapi-generator-ignore file
// and updated with the logic required for the API.
type PetApiServicer interface {
AddPet(context.Context, Pet) (ImplResponse, error)
Expand All @@ -74,7 +74,7 @@ type PetApiServicer interface {

// StoreApiServicer defines the api actions for the StoreApi service
// This interface intended to stay up to date with the openapi yaml used to generate it,
// while the service implementation can ignored with the .openapi-generator-ignore file
// while the service implementation can be ignored with the .openapi-generator-ignore file
// and updated with the logic required for the API.
type StoreApiServicer interface {
DeleteOrder(context.Context, string) (ImplResponse, error)
Expand All @@ -86,7 +86,7 @@ type StoreApiServicer interface {

// UserApiServicer defines the api actions for the UserApi service
// This interface intended to stay up to date with the openapi yaml used to generate it,
// while the service implementation can ignored with the .openapi-generator-ignore file
// while the service implementation can be ignored with the .openapi-generator-ignore file
// and updated with the logic required for the API.
type UserApiServicer interface {
CreateUser(context.Context, User) (ImplResponse, error)
Expand Down
2 changes: 1 addition & 1 deletion samples/server/petstore/go-chi-server/go/api_pet.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ func NewPetApiController(s PetApiServicer, opts ...PetApiOption) Router {
return controller
}

// Routes returns all of the api route for the PetApiController
// Routes returns all the api routes for the PetApiController
func (c *PetApiController) Routes() Routes {
return Routes{
{
Expand Down
2 changes: 1 addition & 1 deletion samples/server/petstore/go-chi-server/go/api_store.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ func NewStoreApiController(s StoreApiServicer, opts ...StoreApiOption) Router {
return controller
}

// Routes returns all of the api route for the StoreApiController
// Routes returns all the api routes for the StoreApiController
func (c *StoreApiController) Routes() Routes {
return Routes{
{
Expand Down
2 changes: 1 addition & 1 deletion samples/server/petstore/go-chi-server/go/api_user.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ func NewUserApiController(s UserApiServicer, opts ...UserApiOption) Router {
return controller
}

// Routes returns all of the api route for the UserApiController
// Routes returns all the api routes for the UserApiController
func (c *UserApiController) Routes() Routes {
return Routes{
{
Expand Down
4 changes: 2 additions & 2 deletions samples/server/petstore/go-chi-server/go/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,13 @@ func IsZeroValue(val interface{}) bool {
return val == nil || reflect.DeepEqual(val, reflect.Zero(reflect.TypeOf(val)).Interface())
}

// AssertInterfaceRequired recursively checks each struct in a slice against the callback.
// AssertRecurseInterfaceRequired recursively checks each struct in a slice against the callback.
// This method traverse nested slices in a preorder fashion.
func AssertRecurseInterfaceRequired(obj interface{}, callback func(interface{}) error) error {
return AssertRecurseValueRequired(reflect.ValueOf(obj), callback)
}

// AssertNestedValueRequired checks each struct in the nested slice against the callback.
// AssertRecurseValueRequired checks each struct in the nested slice against the callback.
// This method traverse nested slices in a preorder fashion.
func AssertRecurseValueRequired(value reflect.Value, callback func(interface{}) error) error {
switch value.Kind() {
Expand Down
2 changes: 1 addition & 1 deletion samples/server/petstore/go-chi-server/go/impl.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

package petstoreserver

//Implementation response defines an error code with the associated body
// ImplResponse response defines an error code with the associated body
type ImplResponse struct {
Code int
Headers map[string][]string
Expand Down
6 changes: 3 additions & 3 deletions samples/server/petstore/go-server-required/go/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ type UserApiRouter interface {

// PetApiServicer defines the api actions for the PetApi service
// This interface intended to stay up to date with the openapi yaml used to generate it,
// while the service implementation can ignored with the .openapi-generator-ignore file
// while the service implementation can be ignored with the .openapi-generator-ignore file
// and updated with the logic required for the API.
type PetApiServicer interface {
AddPet(context.Context, Pet) (ImplResponse, error)
Expand All @@ -74,7 +74,7 @@ type PetApiServicer interface {

// StoreApiServicer defines the api actions for the StoreApi service
// This interface intended to stay up to date with the openapi yaml used to generate it,
// while the service implementation can ignored with the .openapi-generator-ignore file
// while the service implementation can be ignored with the .openapi-generator-ignore file
// and updated with the logic required for the API.
type StoreApiServicer interface {
DeleteOrder(context.Context, string) (ImplResponse, error)
Expand All @@ -86,7 +86,7 @@ type StoreApiServicer interface {

// UserApiServicer defines the api actions for the UserApi service
// This interface intended to stay up to date with the openapi yaml used to generate it,
// while the service implementation can ignored with the .openapi-generator-ignore file
// while the service implementation can be ignored with the .openapi-generator-ignore file
// and updated with the logic required for the API.
type UserApiServicer interface {
CreateUser(context.Context, User) (ImplResponse, error)
Expand Down
2 changes: 1 addition & 1 deletion samples/server/petstore/go-server-required/go/api_pet.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ func NewPetApiController(s PetApiServicer, opts ...PetApiOption) Router {
return controller
}

// Routes returns all of the api route for the PetApiController
// Routes returns all the api routes for the PetApiController
func (c *PetApiController) Routes() Routes {
return Routes{
{
Expand Down
2 changes: 1 addition & 1 deletion samples/server/petstore/go-server-required/go/api_store.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ func NewStoreApiController(s StoreApiServicer, opts ...StoreApiOption) Router {
return controller
}

// Routes returns all of the api route for the StoreApiController
// Routes returns all the api routes for the StoreApiController
func (c *StoreApiController) Routes() Routes {
return Routes{
{
Expand Down
2 changes: 1 addition & 1 deletion samples/server/petstore/go-server-required/go/api_user.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ func NewUserApiController(s UserApiServicer, opts ...UserApiOption) Router {
return controller
}

// Routes returns all of the api route for the UserApiController
// Routes returns all the api routes for the UserApiController
func (c *UserApiController) Routes() Routes {
return Routes{
{
Expand Down
4 changes: 2 additions & 2 deletions samples/server/petstore/go-server-required/go/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,13 @@ func IsZeroValue(val interface{}) bool {
return val == nil || reflect.DeepEqual(val, reflect.Zero(reflect.TypeOf(val)).Interface())
}

// AssertInterfaceRequired recursively checks each struct in a slice against the callback.
// AssertRecurseInterfaceRequired recursively checks each struct in a slice against the callback.
// This method traverse nested slices in a preorder fashion.
func AssertRecurseInterfaceRequired(obj interface{}, callback func(interface{}) error) error {
return AssertRecurseValueRequired(reflect.ValueOf(obj), callback)
}

// AssertNestedValueRequired checks each struct in the nested slice against the callback.
// AssertRecurseValueRequired checks each struct in the nested slice against the callback.
// This method traverse nested slices in a preorder fashion.
func AssertRecurseValueRequired(value reflect.Value, callback func(interface{}) error) error {
switch value.Kind() {
Expand Down
2 changes: 1 addition & 1 deletion samples/server/petstore/go-server-required/go/impl.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

package petstoreserver

//Implementation response defines an error code with the associated body
// ImplResponse response defines an error code with the associated body
type ImplResponse struct {
Code int
Headers map[string][]string
Expand Down

0 comments on commit 9c3d4ef

Please sign in to comment.