question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Schema validator chokes on numbers in scientific notation

See original GitHub issue

Repro:

$ autorest --input-file=https://tripletex.no/v2/swagger.json

Error:

AutoRest code generation utility [version: 2.0.4280; node: v10.4.0]
(C) 2018 Microsoft Corporation.
https://aka.ms/autorest

There is a new version of AutoRest available (2.0.4283).
 > You can install the newer version with with npm install -g autorest@latest

   Loading AutoRest core      '/Users/rigibson/.autorest/@microsoft.azure_autorest-core@2.0.4283/node_modules/@microsoft.azure/autorest-core/dist' (2.0.4283)
ERROR: Schema violation: Expected type number but found type string
    - https://tripletex.no/v2/swagger.json:1:242238 ($.definitions.TravelExpense.properties.attachmentCount.maximum)
FATAL: swagger-document/individual/schema-validator - FAILED
FATAL: Error: [OperationAbortedException] Error occurred. Exiting.
Process() cancelled due to exception : [OperationAbortedException] Error occurred. Exiting.

Culprit appears to be this “maximum” property:

"attachmentCount": {
  "type": "integer",
  "format": "int32",
  "readOnly": true,
  "minimum": 0.0,
  "maximum": 2.147483647E9
},

Related to Azure/autorest.typescript#311

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:9 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
fearthecowboycommented, Apr 15, 2020

OH FOR &%@(…

My whole life, I thought exclusiveMinimum was a number … well, that tells you how many people use it, because the powershell generator and the whole V3 modeler aren’t using it right.

At the end of the day, this is so typical of JSON Schema – use two properties, when one would have done.

0reactions
josh-oakescommented, Apr 15, 2020

Ah ok, I got that working. It looks like exclusiveMinimum takes a boolean value along with your minimum, this is what worked for me…

"RunningSpeedMultiplier": {
        "format": "double",
        "minimum": 0.00,
        "exclusiveMinimum": true,
        "type": "number"
}

Thanks for the help!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Schema validation error when using scientific notation e.g."8.0 ...
Schema validation error when using scientific notation e.g."8.0E-4" in a schema element defined as "xsd:decimal" .
Read more >
How to Create a 13F XML Information Table using Excel 2010 ...
This reference guide is intended to help filers prepare their Form 13F Information table in order to submit it electronically via EDGAR.
Read more >
Number constraints in JSON Schema Validation
I am working of JSON Schema Validation. I wanted to know if it is possible to impose number constraints, and if it is...
Read more >
JSON and JSON Schema for XML Developers - xFront
A JSON instance contains a single JSON value. A JSON value may be either an object, array, number, string, true, false, or null:...
Read more >
eCPR XML Guidelines
3.2 How to Validate an XML file against the eCPR schema file using XML Notepad. ... Awarding Body ID, Project Number, and Contract...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found