-
-
Notifications
You must be signed in to change notification settings - Fork 1k
Closed
Labels
Description
When using the "strict" server types for a simple object definition like:
TestCase:
type: object
properties:
hello:
type: string
It renders to something like:
type TestCase struct {
Hello *string `json:"hello,omitempty"`
}
This construction does not naturally let you determine if the field hello was included in a payload or if it was explicitly set to null.
The current best work around I can see for dealing with this is to set x-go-type to a json.RawMessage and define my own wrapper struct containing an Optional[string] as described here:
https://stackoverflow.com/questions/36601367/json-field-set-to-null-vs-field-not-there
Would it be reasonable to add a configurable alternative to generate something like this automatically so that both null and absent can be detected in a strict server?