Skip to content

Commit

Permalink
Fixes issue #4
Browse files Browse the repository at this point in the history
  • Loading branch information
Kujtim committed Jan 16, 2018
1 parent a2437e7 commit 69ae4c3
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
6 changes: 3 additions & 3 deletions generator/generate_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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),
}))
}
Expand Down
3 changes: 3 additions & 0 deletions generator/generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
3 changes: 3 additions & 0 deletions parser/parse.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 ""
Expand Down

0 comments on commit 69ae4c3

Please sign in to comment.