civisanalytics / swagger-diff

Utility for comparing two Swagger specifications.
BSD 3-Clause "New" or "Revised" License
264 stars 32 forks source link

Running Swagger-Diff on local files #64

Closed swiftzor closed 5 years ago

swiftzor commented 5 years ago

Hi, is it possible to run swagger-diff with local files instead of passing in a url? I'm assuming that under the hood it is doing a GET to retrieve the data. Basically I have a script to reduce the swagger files down to just the paths we care about for our application, but when I pass my JSON files in I get an error that says they are unable to be parsed, and that it expects an end of stream or document separator.

This is the error:

SyntaxError: Error parsing "c:/Users/dolezalc/Desktop/Chloe/QA/old.json" end of the stream or a document separator is expected at line 1, column 4: ��{ ^ at Function.ono [as syntax] (C:\Users\dolezalc\AppData\Roaming\npm-cache_npx\56432\node_modules\swagger-diff\node_modules\ono\lib\index.js:61:20) at parse (C:\Users\dolezalc\AppData\Roaming\npm-cache_npx\56432\node_modules\swagger-diff\node_modules\json-schema-ref-parser\lib\parse.js:47:17) at C:\Users\dolezalc\AppData\Roaming\npm-cache_npx\56432\node_modules\swagger-diff\node_modules\json-schema-ref-parser\lib\read.js:70:23

YAMLException: end of the stream or a document separator is expected at line 1, column 4: ��{ ^ at generateError (C:\Users\dolezalc\AppData\Roaming\npm-cache_npx\56432\node_modules\swagger-diff\node_modules\js-yaml\lib\js-yaml\loader.js:165:10) at throwError (C:\Users\dolezalc\AppData\Roaming\npm-cache_npx\56432\node_modules\swagger-diff\node_modules\js-yaml\lib\js-yaml\loader.js:171:9) at readDocument (C:\Users\dolezalc\AppData\Roaming\npm-cache_npx\56432\node_modules\swagger-diff\node_modules\js-yaml\lib\js-yaml\loader.js:1512:5) at loadDocuments (C:\Users\dolezalc\AppData\Roaming\npm-cache_npx\56432\node_modules\swagger-diff\node_modules\js-yaml\lib\js-yaml\loader.js:1548:5) at load (C:\Users\dolezalc\AppData\Roaming\npm-cache_npx\56432\node_modules\swagger-diff\node_modules\js-yaml\lib\js-yaml\loader.js:1569:19) at Object.safeLoad (C:\Users\dolezalc\AppData\Roaming\npm-cache_npx\56432\node_modules\swagger-diff\node_modules\js-yaml\lib\js-yaml\loader.js:1591:10) at Object.yamlParse [as parse] (C:\Users\dolezalc\AppData\Roaming\npm-cache_npx\56432\node_modules\swagger-diff\node_modules\json-schema-ref-parser\lib\yaml.js:20:19) at parse (C:\Users\dolezalc\AppData\Roaming\npm-cache_npx\56432\node_modules\swagger-diff\node_modules\json-schema-ref-parser\lib\parse.js:26:21) at C:\Users\dolezalc\AppData\Roaming\npm-cache_npx\56432\node_modules\swagger-diff\node_modules\json-schema-ref-parser\lib\read.js:70:23

swiftzor commented 5 years ago

Nevermind, I was encoding it in ascii instead of utf8. my bad