-
Notifications
You must be signed in to change notification settings - Fork 372
Open
Description
Summary
In my json schema I specify the field's type as number. E.g.:
"longitude": {
"custom_label": "Coordinates Longitude",
"description": "The geographical coordinates longitude that represent the center point.",
"type": "number"
}
Then my generated code doesn't validate that the provided value for a number is not null. It handles the required check correctly though. The generated code is:
func (j *MyObjectName) UnmarshalJSON(value []byte) error {
var raw map[string]interface{}
if err := json.Unmarshal(value, &raw); err != nil {
return err
}
if _, ok := raw["latitude"]; raw != nil && !ok {
return fmt.Errorf("field latitude in MyObjectName: required")
}
....
I tried doing stuff like specifying "not": { "type": "null" }
but in vain.
Expected
I would expected that there is a check like
latitude ok := raw["latitude"]
if raw != nil && !ok {
return fmt.Errorf("field latitude in MyObjectName: required")
}
// not null check
if latitude != nil {
return fmt.Errorf("field latitude in MyObjectName should not be null")
}
Metadata
Metadata
Assignees
Labels
No labels