Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiple types for a property in Swagger 2 are not handled correctly. #55

Closed
mastermatt opened this issue Jun 17, 2020 · 2 comments
Closed
Assignees
Labels
bug Something isn't working next release

Comments

@mastermatt
Copy link
Contributor

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`
}
@js2me js2me self-assigned this Jun 17, 2020
@js2me js2me added bug Something isn't working next release labels Jun 17, 2020
@js2me
Copy link
Member

js2me commented Jun 17, 2020

Hello @mastermatt, thanks for catch this bug :)
I'll try to fix that today (GMT+3)

@js2me js2me mentioned this issue Jun 17, 2020
@js2me
Copy link
Member

js2me commented Jun 17, 2020

It should be fixed in 1.8.4

@js2me js2me closed this as completed Jun 17, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working next release
Projects
None yet
Development

No branches or pull requests

2 participants