Skip to content

Commit

Permalink
add list of enums
Browse files Browse the repository at this point in the history
  • Loading branch information
nicovogelaar committed Jan 3, 2019
1 parent c033f5f commit 354c321
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 1 deletion.
2 changes: 1 addition & 1 deletion codegen/templates/data.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions codegen/templates/models.gotpl
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,12 @@ import (
{{- end }}
)

var All{{.GoType}} = []{{.GoType}}{
{{- range $value := .Values}}
{{$enum.GoType}}{{ .Name|toCamel }},
{{- end }}
}

func (e {{.GoType}}) IsValid() bool {
switch e {
case {{ range $index, $element := .Values}}{{if $index}},{{end}}{{ $enum.GoType }}{{ $element.Name|toCamel }}{{end}}:
Expand Down
11 changes: 11 additions & 0 deletions example/starwars/models_gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 354c321

Please sign in to comment.