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

Does not recognise numbers above 1e20: value must be a number #5249

Open
RobinTail opened this issue Oct 26, 2024 · 3 comments
Open

Does not recognise numbers above 1e20: value must be a number #5249

RobinTail opened this issue Oct 26, 2024 · 3 comments

Comments

@RobinTail
Copy link

RobinTail commented Oct 26, 2024

Q&A (please complete the following information)

  • OS: macOS
  • Browser: chrome
  • Version: 130
  • Method of installation: none, online
  • Swagger-Editor version: next, https://editor-next.swagger.io/
  • Swagger/OpenAPI version: 3.1

Content & configuration

Minimum reproduction:

openapi: 3.1.0
info:
  title: Example API
  version: 20.14.3
paths:
  /v1/serialize:
    get:
      operationId: GetV1Serialize
      responses:
        "200":
          description: GET /v1/serialize Positive response
          content:
            application/json:
              schema:
                type: object
                properties:
                  prop:
                    type: number
                    format: double
                    minimum: 1.1e3
                    maximum: 1e21

Describe the bug you're encountering

It says " maximum' value must be a number ", but it is a number.

Expected behavior

I expect it to handle the range of numbers supported by JS Number, which is:

# -Number.MAX_VALUE
-1.7976931348623157e+308
# Number.MAX_VALUE
1.7976931348623157e+308

but it's failing already on 1e21.

Screenshots

editor-next editor
image image
fails on 1e21, regardless of OAS version does not fail even with 1e100500

Additional context or thoughts

  • There is no such issue in https://editor.swagger.io/ (seems to be happening only in "next" editor)
  • and it does not depend on openapi version (setting 3.0 in next editor does not fix it),
  • 1e20, works fine.
@RobinTail
Copy link
Author

RobinTail commented Oct 26, 2024

Worth to note that 1e20 seems to be the last level in JavaScript before switching to exponential notation

$ 1e20
100000000000000000000
$ 1e21
1e+21

@ponelat
Copy link
Member

ponelat commented Nov 1, 2024

Thanks @RobinTail, we can take a look. I'd be curious what sized number you needed to discover this issue :)

@RobinTail
Copy link
Author

RobinTail commented Nov 1, 2024

Thank you @ponelat
Let's say I need to describe API endpoint that accepts a float number. And I'd like to inform the consumers via the OpenAPI documentation what that number could be, therefore I'm using minimum/maximum properties for that purpose. Since the API runs in Node.js and operated by JavaScript engine, the largest safe number is Number.MAX_VALUE which is 1.7976931348623157e+308, and the minimum one would be -1.7976931348623157e+308 accordingly.

And all that did work fine before I switched to the next editor (for OAS 3.1)

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

No branches or pull requests

2 participants