Skip to content

Commit 21027f4

Browse files
committed
Fix problems with inlined simple type element
``` 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"` } ```
1 parent 1d06367 commit 21027f4

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

types_tmpl.go

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,17 @@ package gowsdl
77
var typesTmpl = `
88
{{define "SimpleType"}}
99
{{$type := replaceReservedWords .Name | makePublic}}
10+
{{if .Doc}} {{.Doc | comment}} {{end}}
1011
type {{$type}} {{toGoType .Restriction.Base}}
12+
{{if .Restriction.Enumeration}}
1113
const (
1214
{{with .Restriction}}
1315
{{range .Enumeration}}
1416
{{if .Doc}} {{.Doc | comment}} {{end}}
1517
{{$type}}{{$value := replaceReservedWords .Value}}{{$value | makePublic}} {{$type}} = "{{goString .Value}}" {{end}}
1618
{{end}}
1719
)
20+
{{end}}
1821
{{end}}
1922
2023
{{define "ComplexContent"}}
@@ -65,11 +68,14 @@ var typesTmpl = `
6568
{{removeNS .Ref | replaceReservedWords | makePublic}} {{if eq .MaxOccurs "unbounded"}}[]{{end}}{{.Ref | toGoType}} ` + "`" + `xml:"{{.Ref | removeNS}},omitempty"` + "`" + `
6669
{{else}}
6770
{{if not .Type}}
68-
{{template "ComplexTypeInline" .}}
69-
{{else}}
70-
{{if .Doc}}
71-
{{.Doc | comment}} {{"\n"}}
71+
{{if .SimpleType}}
72+
{{if .Doc}} {{.Doc | comment}} {{end}}
73+
{{ .Name | makeFieldPublic}} {{toGoType .SimpleType.Restriction.Base}} ` + "`" + `xml:"{{.Name}},omitempty"` + "`" + `
74+
{{else}}
75+
{{template "ComplexTypeInline" .}}
7276
{{end}}
77+
{{else}}
78+
{{if .Doc}}{{.Doc | comment}} {{end}}
7379
{{replaceReservedWords .Name | makeFieldPublic}} {{if eq .MaxOccurs "unbounded"}}[]{{end}}{{.Type | toGoType}} ` + "`" + `xml:"{{.Name}},omitempty"` + "`" + ` {{end}}
7480
{{end}}
7581
{{end}}

xsd.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ type XSDAttribute struct {
110110
// and information about the values of attributes or text-only elements.
111111
type XSDSimpleType struct {
112112
Name string `xml:"name,attr"`
113+
Doc string `xml:"annotation>documentation"`
113114
Restriction XSDRestriction `xml:"restriction"`
114115
}
115116

0 commit comments

Comments
 (0)