github.com/ffalor/go-swagger@v0.0.0-20231011000038-9f25265ac351/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 }}