mirror of
https://github.com/OpenAPITools/openapi-generator.git
synced 2025-05-12 12:40:53 +00:00
Parse integer array query parameters. Fix typos (#11105)
This commit is contained in:
parent
161de2cfdf
commit
9c3d4ef2a6
@ -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}}
|
||||
|
@ -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}}
|
||||
{
|
||||
@ -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}}
|
||||
|
@ -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() {
|
||||
|
@ -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}}
|
||||
|
@ -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)
|
||||
@ -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)
|
||||
@ -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)
|
||||
|
@ -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{
|
||||
{
|
||||
|
@ -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{
|
||||
{
|
||||
|
@ -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{
|
||||
{
|
||||
|
@ -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() {
|
||||
|
@ -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
|
||||
|
@ -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)
|
||||
@ -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)
|
||||
@ -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)
|
||||
|
@ -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{
|
||||
{
|
||||
|
@ -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{
|
||||
{
|
||||
|
@ -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{
|
||||
{
|
||||
|
@ -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() {
|
||||
|
@ -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
|
||||
|
@ -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)
|
||||
@ -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)
|
||||
@ -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)
|
||||
|
@ -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{
|
||||
{
|
||||
|
@ -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{
|
||||
{
|
||||
|
@ -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{
|
||||
{
|
||||
|
@ -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() {
|
||||
|
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user