github.com/go-swagger/go-swagger@v0.31.0/generator/templates/serializers/aliasedserializer.gotmpl (about)

     1  {{ define "aliasedSerializer" }}
     2  // UnmarshalJSON sets a {{ pascalize .Name }} value from JSON input
     3  func ({{.ReceiverName}} *{{ pascalize .Name }}) UnmarshalJSON(b []byte) error {
     4    return ((*{{ .AliasedType }})({{ .ReceiverName}})).UnmarshalJSON(b)
     5  }
     6  
     7  // MarshalJSON retrieves a {{ pascalize .Name }} value as JSON output
     8  func ({{.ReceiverName}} {{ pascalize .Name }}) MarshalJSON() ([]byte, error) {
     9    return ({{ .AliasedType }}({{ .ReceiverName}})).MarshalJSON()
    10  }
    11  {{- end }}