-
Notifications
You must be signed in to change notification settings - Fork 63
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
v3.0: exclusiveMaximum
must be a boolean
#83
Comments
CC @OrIOg |
Ok, I found the PR that describes the reason: And this looks a bit strange to me, since my link to the spec is taken from the swagger.io website:
The document (3) clearly says that the property MUST be boolean: However the one referred in the PR says it must be a number: Presuming that the one in the PR is newer, it's still questionable how to deal with the complains in Swagger validator (see the screenshot) |
Here is another link to the documentation that describes It's based on OpenAPI 3.0 and as per my understanding it should not be breaking changes in 3.1 as well. |
Holy Moly, they really changed it without any backward compatibility: |
Looks like the change is coming from different versions of JSON Schema. OpenAPI is not redefining them, but using them directly from JSON Schema.
Latest spec OpenAPI 3.1.0 uses JSON Schema Specification Draft 2020-12 (the number version) So, my best guess is we should stick to Take in mind (last time I checked) Swagger Editor (from swagger.io) was still supporting spec. v2. and not yet 3.x |
Yeah, I see. And there also a lot of comments/jsdoc in the code that refer to What do you think? Also, which tool would you recommend to validate |
Indeed, we can enforce 3.1.0 but also thinking about relaxing the type for What do you think it would be more useful? |
A good list of validators and compatibility is maintained here: https://openapi.tools/#data-validators Take a look also to this one: https://github.com/seriousme/openapi-schema-validator |
Well, I believe that ideally, in a case like this, the type should depend on the version literal and be generic. For example, consider this: type OpenApiVersion = `3.${number}.${number}`;
export interface OpenAPIObject<V extends OpenApiVersion> {
openapi: V;
// ...
}
export interface SchemaObject<V extends OpenApiVersion> {
// ...
exclusiveMaximum?: V extends `3.1.${number}` ? number : boolean;
} It requires at least Typescript 4.1 to support type literals. I will think more on other ways too. |
For my case, I need to provide users of my library with a tool that generates the specification of their API, that could be used for the following cases:
I'm not sure at the moment which OpenAPI versions are currently supported by Webstorm and Postman, but Swagger still only supports 3.0. |
I should have checked it in depth before reporting the issue & the PR. It is my bad, sorry. I'll try testing @RobinTail 's PR on my side, even with the breaking changes it might be the way to do it correctly. There might be a way by extending said schema and changing definition, but pros & cons are to be established |
Lines 306 and 308 have been changed in this commit:
e7a0851
These changes have been released in version 3.0.0.
However, according to this spec,
exclusiveMaximum
must be boolean:https://datatracker.ietf.org/doc/html/draft-wright-json-schema-validation-00#section-5.3
More than that, the Swagger validator complains about numeric value as well:
![image](https://user-images.githubusercontent.com/13189514/184887724-3ac66ff2-49ad-4ec2-b82a-67f44347c898.png)
I think that the mentioned commit should be reverted.
Otherwise, could you please clarify what was the reason for that change?
The text was updated successfully, but these errors were encountered: