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 and exclusiveMaximum should be numbers instead of booleans #1162

Closed
zobzn opened this issue Feb 1, 2021 · 5 comments
Closed

Comments

@zobzn
Copy link
Contributor

zobzn commented Feb 1, 2021

I'm submitting a...


[ ] Regression 
[x] Bug report
[ ] Feature request
[ ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead post your question on Stack Overflow.

Current behavior

exclusiveMinimum and exclusiveMaximum declared as booleans

Expected behavior

exclusiveMinimum and exclusiveMaximum declared as numbers

Minimal reproduction of the problem with instructions

What is the motivation / use case for changing the behavior?

according to json-schema.org exclusiveMinimum and exclusiveMaximum are numbers

If x is the value being validated, the following must hold true:
x ≥ minimum
x > exclusiveMinimum
x ≤ maximum
x < exclusiveMaximum

Environment


Nest version: X.Y.Z

 
For Tooling issues:
- Node version: XX  
- Platform:  

Others:

@kamilmysliwiec
Copy link
Member

Would you like to create a PR for this issue?

@zobzn
Copy link
Contributor Author

zobzn commented Feb 1, 2021

@kamilmysliwiec
when I started work on a PR (#1167), I thought I was fixing a bug
but then I found out that it's not that simple
according to https://phil.tech/2019/update-openapi-json-schema/ there was a "breaking change" in the json-schema spec

# draft 5
minimum: 10
exclusiveMinimum: true

# draft 2019-09
exclusiveMinimum: 10

so maybe it's not a bugfix but a new feature (and probably with a breaking change)

and now we have different options what to do:

  • set type for exclusiveMinimum/exclusiveMaximum as number
  • set type for exclusiveMinimum/exclusiveMaximum as boolean | number and do nothing after
  • set type for exclusiveMinimum/exclusiveMaximum as boolean | number and automatically convert/rewrite somewhere a combination of minimum: number + exclusiveMinimum: boolean to a new exclusiveMinimum: number (and the same for max)
  • maybe other suggestions?

(and unfortunately I'm not sure that I will have time to complete this)

@kamilmysliwiec
Copy link
Member

We can just accept union type as a temporary solution (boolean | number). This should be fairly easy to fix

@kamilmysliwiec
Copy link
Member

#1167 (comment)

@anotheri
Copy link

after #2994 this seems still an open issue, isn't it? are there any plans to get it fixed? or any workarounds on how to make it work with latest JSON Schema?

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

No branches or pull requests

3 participants