IBM / openapi-validator

Configurable and extensible validator/linter for OpenAPI documents
Apache License 2.0
472 stars 87 forks source link

Unexpected token u in JSON at position 0 #270

Closed rolivares closed 2 weeks ago

rolivares commented 3 years ago

this error is shown on console when I upgrade to v0.40 and execute the linter, is not currently appearing on 0.39

maybe related about 'response-error-response-schema' that appearing on revision too, using the same definition

SyntaxError: Unexpected token u in JSON at position 0 at JSON.parse (<anonymous>) at Object.json-schema-validation (eval at exports.evaluateExport (C:\GIT\MTT\bono\back\node_modules\@stoplight\spectral\dist\rulesets\evaluators.js:89:80), <anonymous>:12:27) at Object.exports.lintNode (C:\GIT\MTT\bono\back\node_modules\@stoplight\spectral\dist\runner\lintNode.js:30:33) at callback (C:\GIT\MTT\bono\back\node_modules\@stoplight\spectral\dist\runner\runner.js:38:32) at JSONPath._handleCallback (C:\GIT\MTT\bono\back\node_modules\jsonpath-plus\dist\index-umd.js:626:7) at JSONPath._trace (C:\GIT\MTT\bono\back\node_modules\jsonpath-plus\dist\index-umd.js:658:12) at JSONPath._trace (C:\GIT\MTT\bono\back\node_modules\jsonpath-plus\dist\index-umd.js:733:19) at JSONPath.evaluate (C:\GIT\MTT\bono\back\node_modules\jsonpath-plus\dist\index-umd.js:566:23) at new JSONPath (C:\GIT\MTT\bono\back\node_modules\jsonpath-plus\dist\index-umd.js:498:22) at Object.JSONPath (C:\GIT\MTT\bono\back\node_modules\jsonpath-plus\dist\index-umd.js:452:16)

alecor191 commented 3 years ago

I'm getting the same error using the following command:

lint-openapi -v -j -p --debug 'D:\temp\my-openapi-spec.json'

Output:

[Warning] Skipping non-existent file: D:\temp\my-openapi-spec.json
SyntaxError: Unexpected token u in JSON at position 0
    at JSON.parse (<anonymous>)
    at Object.json-schema-validation (eval at exports.evaluateExport (C:\Users\aleco\AppData\Roaming\npm\node_modules\ibm-openapi-validator\node_modules\@stoplight\spectral\dist\rulesets\evaluators.js:89:80), <anonymous>:12:27)
    at Object.exports.lintNode (C:\Users\aleco\AppData\Roaming\npm\node_modules\ibm-openapi-validator\node_modules\@stoplight\spectral\dist\runner\lintNode.js:30:33)
    at callback (C:\Users\aleco\AppData\Roaming\npm\node_modules\ibm-openapi-validator\node_modules\@stoplight\spectral\dist\runner\runner.js:38:32)
    at JSONPath._handleCallback (C:\Users\aleco\AppData\Roaming\npm\node_modules\ibm-openapi-validator\node_modules\jsonpath-plus\dist\index-umd.js:626:7)
    at JSONPath._trace (C:\Users\aleco\AppData\Roaming\npm\node_modules\ibm-openapi-validator\node_modules\jsonpath-plus\dist\index-umd.js:658:12)
    at JSONPath._trace (C:\Users\aleco\AppData\Roaming\npm\node_modules\ibm-openapi-validator\node_modules\jsonpath-plus\dist\index-umd.js:733:19)
    at JSONPath.evaluate (C:\Users\aleco\AppData\Roaming\npm\node_modules\ibm-openapi-validator\node_modules\jsonpath-plus\dist\index-umd.js:566:23)
    at new JSONPath (C:\Users\aleco\AppData\Roaming\npm\node_modules\ibm-openapi-validator\node_modules\jsonpath-plus\dist\index-umd.js:498:22)
    at Object.JSONPath (C:\Users\aleco\AppData\Roaming\npm\node_modules\ibm-openapi-validator\node_modules\jsonpath-plus\dist\index-umd.js:452:16)
{
  "version": "0.40.1",
  "warnings": [
    {
      "path": [],
      "message": "OpenAPI `servers` must be present and non-empty array.",
      "rule": "oas3-api-servers",
      "line": 0
    },
    {
      "path": [],
      "message": "OpenAPI object should have non-empty `tags` array.",
      "rule": "openapi-tags",
      "line": 0
    },
...

Worth mentioning:

Environment info

dpopp07 commented 1 year ago

This seems to be a Windows-specific issue with the tool. Is this still happening on the latest version?

@rolivares @alecor191

dpopp07 commented 2 weeks ago

Closing due to inactivity