Skip to content

Commit

Permalink
Merge pull request hooklift#143 from amuttsch/feature/improved-type-h…
Browse files Browse the repository at this point in the history
…andling

Handle default type in attribute and handle lists in simple types in
  • Loading branch information
c4milo authored May 30, 2019
2 parents 9dc92ee + 257a49c commit ca42ca0
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions types_tmpl.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,11 @@ var typesTmpl = `
{{define "Attributes"}}
{{range .}}
{{if .Doc}} {{.Doc | comment}} {{end}}
{{ .Name | makeFieldPublic}} {{toGoType .Type}} ` + "`" + `xml:"{{.Name}},attr,omitempty"` + "`" + `
{{ if ne .Type "" }}
{{ .Name | makeFieldPublic}} {{toGoType .Type}} ` + "`" + `xml:"{{.Name}},attr,omitempty"` + "`" + `
{{ else }}
{{ .Name | makeFieldPublic}} string ` + "`" + `xml:"{{.Name}},attr,omitempty"` + "`" + `
{{ end }}
{{end}}
{{end}}
Expand Down Expand Up @@ -76,7 +80,11 @@ var typesTmpl = `
{{if not .Type}}
{{if .SimpleType}}
{{if .Doc}} {{.Doc | comment}} {{end}}
{{ .Name | makeFieldPublic}} {{toGoType .SimpleType.Restriction.Base}} ` + "`" + `xml:"{{.Name}},omitempty"` + "`" + `
{{if ne .SimpleType.List.ItemType ""}}
{{ .Name | makeFieldPublic}} []{{toGoType .SimpleType.List.ItemType}} ` + "`" + `xml:"{{.Name}},omitempty"` + "`" + `
{{else}}
{{ .Name | makeFieldPublic}} {{toGoType .SimpleType.Restriction.Base}} ` + "`" + `xml:"{{.Name}},omitempty"` + "`" + `
{{end}}
{{else}}
{{template "ComplexTypeInline" .}}
{{end}}
Expand Down

0 comments on commit ca42ca0

Please sign in to comment.