You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The schema.Type field currently only supports a single type currently, but should also support an array of types if many are provided.
I'd be open to implementing this myself, but wanted feedback before opening a PR.
Since this would be a breaking change, should I do it as a new field/struct tag?
How should it be implemented? I could add a new type:
type SchemaType struct {
Type string
Types []string
}
Or the existing value could be changed from string to []string, and in the singular case, it would just be a list with a single element. When rendering to JSON it could render it conditionally to a single string or a list, based on how many entries there are.
The text was updated successfully, but these errors were encountered:
This is a really tricky one to implement in a strictly typed language like Go. A possible solution as you suggest would be to create a new type like type Type []string and provide a set of methods around it for serialization to and from a single string or array, depending on the number of entries...
@samlown Maybe this use off "null" in a sum-type scenario is common enough that it can be a flag on the Reflector that works with the "nullable" field tag. When both are enabled it would serialize the type: "string" as type: ["string", "null"]
Types are not only singular, but can be an array of valid types: https://json-schema.org/understanding-json-schema/reference/type
The
schema.Type
field currently only supports a single type currently, but should also support an array of types if many are provided.I'd be open to implementing this myself, but wanted feedback before opening a PR.
Or the existing value could be changed from
string
to[]string
, and in the singular case, it would just be a list with a single element. When rendering to JSON it could render it conditionally to a single string or a list, based on how many entries there are.The text was updated successfully, but these errors were encountered: