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

exclusiveMinimum/exclusiveMaximum OAS v3 is not validated correctly #36

Closed
roalonso opened this issue Aug 5, 2022 · 3 comments
Closed
Labels
question Further information is requested

Comments

@roalonso
Copy link

roalonso commented Aug 5, 2022

What happened?

When using exclusiveMinimum and exclusiveMaximum properties with OAS v3, the validator marks its usage as an error, saying its value should be a boolean. However, since OAS v3 this field now holds the actual (exclusive) minimum/maximum value, and is no longer a boolean.

What should have happened instead?

An integer or float should be accepted as the value for exclusiveMinimum/exclusiveMaximum. A boolean should no longer be accepted when using OAS v3.x.x.

Minimal reproducible OpenAPI snippet

openapi: 3.0.2
info: 
  title: title
  version: 1.0.0
  description: description
  license: 
    name: A license
    url: https://a.license.org
servers: 
  - url: https://a.server.org
paths: 
  /newPath:
    get: 
      operationId: newPathGet
      parameters:
        - in: query
          name: positiveValue
          required: true
          schema:
            type: number
            format: float
            exclusiveMinimum: 0.0
      summary: A test path.
      responses: 
        204:
          description: Successful
        422:
          description: Unprocessable

Screenshots

Screen Shot 2022-08-05 at 15 37 55

Additional context

Using OAS 3.0.2.

@tatomyr
Copy link
Contributor

tatomyr commented Aug 9, 2022

Hi @roalonso,

According to the spec of v.3.0.2 it uses JSON Schema Draft-00 and it doesn't define exlusiveMinimum/exclusiveMaximum at all unless I'm missing something. Could you specify how did you find it should be a number?

@tatomyr tatomyr added the question Further information is requested label Aug 15, 2022
@jeremyfiel
Copy link

jeremyfiel commented Aug 16, 2022

OpenAPI 3.1.x is fully aligned with JSON Schema draft 2020-12 and has changed the behavior of exclusiveMinimum and exclusiveMaximum keywords.

https://www.openapis.org/blog/2021/02/16/migrating-from-openapi-3-0-to-3-1-0

You are using 3.0.2 and it's base schema is aligned with JSON Schema draft 04 where these two keywords accepted a boolean value, not a number.

https://github.com/OAI/OpenAPI-Specification/blob/main/schemas/v3.0/schema.json#L349
https://github.com/OAI/OpenAPI-Specification/blob/main/schemas/v3.0/schema.json#L356

@roalonso
Copy link
Author

I see, the extension is behaving as expected then.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants