Skip to content

Commit

Permalink
Support group-as/@in-xml on assemblies
Browse files Browse the repository at this point in the history
  • Loading branch information
isimluk committed Sep 21, 2020
1 parent 879b7e9 commit 2f83b20
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
15 changes: 15 additions & 0 deletions metaschema/parser/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,20 @@ func (a *Assembly) IndexBy() string {
return strcase.ToCamel(a.Def.JsonKey.FlagName)
}

func (a *Assembly) XmlGroupping() string {
if a.GroupAs == nil {
return ""
}
if a.GroupAs.InXml == "UNGROUPED" || a.GroupAs.InXml == "" {
return ""
}
if a.GroupAs.InXml == "GROUPED" {
return a.GroupAs.Name + ">"
}
panic("Not implemented group-as/@in-xml=" + a.GroupAs.InXml)
return ""
}

type Field struct {
Required string `xml:"required,attr"`

Expand Down Expand Up @@ -418,6 +432,7 @@ type Choice struct {
type GroupAs struct {
Name string `xml:"name,attr"`
InJson string `xml:"in-json,attr"`
InXml string `xml:"in-xml,attr"`
}

func (ga *GroupAs) SingletonOrArray() bool {
Expand Down
2 changes: 1 addition & 1 deletion metaschema/templates/generated_models.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ type {{.GoTypeName}} struct {

{{- range .Model.Assembly}}
// {{ .GoComment }}
{{.GoName}} {{.GoMemLayout}}{{.GoTypeNameMultiplexed}} `xml:"{{.XmlName}},omitempty" json:"{{.JsonName}},omitempty"`
{{.GoName}} {{.GoMemLayout}}{{.GoTypeNameMultiplexed}} `xml:"{{.XmlGroupping}}{{.XmlName}},omitempty" json:"{{.JsonName}},omitempty"`
{{- end}}

{{- range .Model.Choice}}
Expand Down
2 changes: 1 addition & 1 deletion metaschema/templates/pkged.go

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

0 comments on commit 2f83b20

Please sign in to comment.