IBM/openapi-validator

Error parsing JSON specification with scientific numbers in it

Closed this issue · 2 comments

We are evaluating using this tool for linting our OpenAPI specification but it seems to have issues parsing scientific numbers. The following error appears when a scientific number is encountered in the schema:

[Error] Invalid input file: openapi.json. See below for details.
Syntax error: expecting number near er": 1e1
}

This is probably more of an edge case issue but affects our usage of "multipleOf" in our specification where we are currently using small decimal numbers as a way to identify the scale of a number. This is being transformed to scientific notation by the tools we use to merge our specification which is then causing us issues with using the linting tool.

Version:
0.34.1

Reproduction steps:

  1. Install openapi-validator.
  2. Create openapi.json with the following:
{
  "number": 1e1
}
  1. Run lint-openapi openapi.json from the command line.

The same issue does not occur when changing the file extension to .yaml.

Seems to be caused by a dependency not supporting scientific numbers when parsing JSON: https://github.com/IBM/openapi-validator/blob/master/src/cli-validator/runValidator.js#L210

PR to resolve in dependency: jackyjieliu/json-dup-key-validator#6

Creating this issue to inform and in case additional work becomes needed in this repository.

Appologies if this issue does not belong here. Please feel welcome to close if this is the case.

@raing3 Thanks for opening the issue. Once the PR is released in the dependency, we will update that dependency's version. I'm fine with leaving this issue open for awareness in the meantime

Closing as issue has been fixed in dependency.