github.com/thetreep/go-swagger@v0.0.0-20240223100711-35af64f14f01/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 }}