Closed
Description
The Swagger 2.0 spec didn't explicitly call out how mixed types are handled, like OpenAPI 3.0 does with oneOf
.
Instead it falls back to JSON Schema Draft 4, which states:
https://tools.ietf.org/html/draft-fge-json-schema-validation-00#section-5.5.2
5.5.2.1. Valid values
The value of this keyword MUST be either a string or an array. If it
is an array, elements of the array MUST be strings and MUST be
unique.
String values MUST be one of the seven primitive types defined by the
core specification.
However, currently a swagger.json like like the following.
...
"properties": {
"product_id": {
"type": ["integer", "string"]
}
}
...
produces a type like the following
export type SomeRequest = {
product_id: integerString; // Should be `number | string`
}