belgif / openapi-problem

OpenAPI data types for problem messages
Apache License 2.0
10 stars 5 forks source link

exclusiveMaximum conflicts between openapi3 and json schema #11

Closed cyberjasse closed 1 year ago

cyberjasse commented 1 year ago

Hello. I found an issue in the openAPI3 version of the Problem object : https://github.com/belgif/openapi-problem/blob/master/src/main/openapi/problem/v1/problem-v1.yaml The property exclusiveMaximum has a boolean as value and it looks like this come from the swagger openAPI 3 documentation ( https://swagger.io/docs/specification/data-models/keywords/ ) but this same documentation says that "These keywords have the same meaning as in JSON Schema" and the exclusiveMaximum must have an integer as value in JSON Schema ( https://opis.io/json-schema/2.x/ ) . Moreover, when using the new version of swagger editor (https://editor-next.swagger.io/) , it detects an error in the Problem object about that property and the message tells "exclusiveMaximum' value must be a number" . So who is right , the swagger documentation or the JSON Schema and swagger editor ?

pvdbosch commented 1 year ago

Hi @cyberjasse ,

The definition of exclusiveMaximum has changed between recent versions of the specifications:

OpenAPI 3.0 is aligned with JSON Schema Specification Wright Draft 00 which defines:

The value of "exclusiveMaximum" MUST be a boolean, representing whether the limit in "maximum" is exclusive or not. An undefined value is the same as false.

OpenAPI 3.1 is based on JSON Schema Specification Draft 2020-12 which defines:

The value of "exclusiveMaximum" MUST be a number, representing an exclusive upper limit for a numeric instance.

The problem-v1.yaml schema is OpenAPI 3.0, so it should be boolean there. The latest preview version of Swagger editor doesn't seem to handle this correctly. The stable one ( https://editor.swagger.io/ ) seems to be OK.

OpenAPI 3.1 isn't recommended yet by the guide as its support by tooling is not yet sufficient.

edit: fixed links to correct JSON schema versions