diff --git a/generator/generate_service.go b/generator/generate_service.go index ec4aa75..39a268b 100644 --- a/generator/generate_service.go +++ b/generator/generate_service.go @@ -637,7 +637,7 @@ func (g *generateServiceEndpoints) generateEndpointsClientMethods() { tp := p.Type ts := strings.Split(tp, ".") if len(ts) == 1 { - if tp[:1] == strings.ToUpper(tp[:1]) && tp[0] != '[' && tp[0] != '*' { + if tp[:1] == strings.ToUpper(tp[:1]) && tp[0] != '[' && tp[0] != '*' { // If the type of the parameter is not `something.MyType` and it starts with an uppercase // than the type was defined inside the service package. tp = "service." + tp @@ -707,7 +707,7 @@ func (g *generateServiceEndpoints) generateMethodEndpoint() (err error) { tp := p.Type ts := strings.Split(tp, ".") if len(ts) == 1 { - if tp[:1] == strings.ToUpper(tp[:1]) && tp[0] != '[' && tp[0] != '*' { + if tp[:1] == strings.ToUpper(tp[:1]) && tp[0] != '[' && tp[0] != '*' { // If the type of the parameter is not `something.MyType` and it starts with an uppercase // than the type was defined inside the service package. tp = "service." + tp @@ -720,7 +720,7 @@ func (g *generateServiceEndpoints) generateMethodEndpoint() (err error) { "json": utils.ToLowerSnakeCase(utils.ToCamelCase(p.Name)), })) } else { - reqFields = append(reqFields, jen.Id(utils.ToCamelCase(p.Name)).Id(tp).Tag(map[string]string{ + reqFields = append(reqFields, jen.Id(utils.ToCamelCase(p.Name)).Id(strings.Replace(tp, "...", "[]", 1)).Tag(map[string]string{ "json": utils.ToLowerSnakeCase(p.Name), })) } diff --git a/generator/generator.go b/generator/generator.go index db9b2c6..bdfb6ec 100644 --- a/generator/generator.go +++ b/generator/generator.go @@ -97,6 +97,9 @@ func (b *BaseGenerator) GenerateNameBySample(sample string, exclude []parser.Nam // EnsureThatWeUseQualifierIfNeeded is used to see if we need to import a path of a given type. func (b *BaseGenerator) EnsureThatWeUseQualifierIfNeeded(tp string, imp []parser.NamedTypeValue) string { + if bytes.HasPrefix([]byte(tp), []byte("...")) { + return "" + } if t := strings.Split(tp, "."); len(t) > 0 { s := t[0] for _, v := range imp { diff --git a/parser/parse.go b/parser/parse.go index 668ba8d..d5631b7 100644 --- a/parser/parse.go +++ b/parser/parse.go @@ -230,6 +230,9 @@ func (fp *FileParser) getTypeFromExp(e ast.Expr) string { tp = "map[" + key + "]" + value case *ast.InterfaceType: tp = "interface{}" + case *ast.Ellipsis: + t := fp.getTypeFromExp(k.Elt) + tp = "..." + t default: logrus.Info("Type Expresion not supported") return ""