Closed andrewemeryanz closed 4 years ago
The json tags on public type structs and type structs used for json validation are inconsistent.
If the PostRequest type is modified in simple.sysl to:
PostRequest
simple.sysl
!type PostRequest: Bt <: bool?: @json_tag = "Bt" Dt <: datetime: @json_tag = "Dt" St <: string: @json_tag = "St" Lower <: string: @json_tag = "lower" Upper <: string: @json_tag = "UPPER"
Then the following is generated:
// PostRequest ... type PostRequest struct { Bt *bool `json:"Bt,omitempty"` Dt convert.JSONTime `json:"Dt"` St string `json:"St"` Lower string `json:"lower"` Upper string `json:"upper"` // incorrect, should be `json:"UPPER,omitempty"` } func (t *PostRequest) UnmarshalJSON(data []byte) error { inner := struct { Bt *bool `json:"Bt,omitempty"` Dt *convert.JSONTime `json:"Dt,omitempty"` St *string `json:"St,omitempty"` Lower *string `json:"Lower,omitempty"` // incorrect, should be `json:"lower,omitempty"` Upper *string `json:"Upper,omitempty"` // incorrect, should be `json:"UPPER,omitempty"` } ... }
The json tags on public type structs and type structs used for json validation are inconsistent.
If the
PostRequest
type is modified insimple.sysl
to:Then the following is generated: