Skip to content

Commit

Permalink
Fix problems with inlined simple type element
Browse files Browse the repository at this point in the history
```
	assert.go:24: got type GetInfo struct {
	XMLName	xml.Name	`xml:"http://www.mnb.hu/webservices/ GetInfo"`

	Id	struct {
	}	`xml:"Id,omitempty"`
} want type GetInfo struct {
	XMLName	xml.Name	`xml:"http://www.mnb.hu/webservices/ GetInfo"`

	Id	string	`xml:"Id,omitempty"`
}
```
  • Loading branch information
realmfoo committed Sep 27, 2017
1 parent 1d06367 commit 21027f4
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
14 changes: 10 additions & 4 deletions types_tmpl.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,17 @@ package gowsdl
var typesTmpl = `
{{define "SimpleType"}}
{{$type := replaceReservedWords .Name | makePublic}}
{{if .Doc}} {{.Doc | comment}} {{end}}
type {{$type}} {{toGoType .Restriction.Base}}
{{if .Restriction.Enumeration}}
const (
{{with .Restriction}}
{{range .Enumeration}}
{{if .Doc}} {{.Doc | comment}} {{end}}
{{$type}}{{$value := replaceReservedWords .Value}}{{$value | makePublic}} {{$type}} = "{{goString .Value}}" {{end}}
{{end}}
)
{{end}}
{{end}}
{{define "ComplexContent"}}
Expand Down Expand Up @@ -65,11 +68,14 @@ var typesTmpl = `
{{removeNS .Ref | replaceReservedWords | makePublic}} {{if eq .MaxOccurs "unbounded"}}[]{{end}}{{.Ref | toGoType}} ` + "`" + `xml:"{{.Ref | removeNS}},omitempty"` + "`" + `
{{else}}
{{if not .Type}}
{{template "ComplexTypeInline" .}}
{{else}}
{{if .Doc}}
{{.Doc | comment}} {{"\n"}}
{{if .SimpleType}}
{{if .Doc}} {{.Doc | comment}} {{end}}
{{ .Name | makeFieldPublic}} {{toGoType .SimpleType.Restriction.Base}} ` + "`" + `xml:"{{.Name}},omitempty"` + "`" + `
{{else}}
{{template "ComplexTypeInline" .}}
{{end}}
{{else}}
{{if .Doc}}{{.Doc | comment}} {{end}}
{{replaceReservedWords .Name | makeFieldPublic}} {{if eq .MaxOccurs "unbounded"}}[]{{end}}{{.Type | toGoType}} ` + "`" + `xml:"{{.Name}},omitempty"` + "`" + ` {{end}}
{{end}}
{{end}}
Expand Down
1 change: 1 addition & 0 deletions xsd.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ type XSDAttribute struct {
// and information about the values of attributes or text-only elements.
type XSDSimpleType struct {
Name string `xml:"name,attr"`
Doc string `xml:"annotation>documentation"`
Restriction XSDRestriction `xml:"restriction"`
}

Expand Down

0 comments on commit 21027f4

Please sign in to comment.