api-spec-converter icon indicating copy to clipboard operation
api-spec-converter copied to clipboard

Promise error thrown on conversion to some formats

Open kofalt opened this issue 3 years ago • 0 comments

Hi there - very neat project! Trying this out with a fairly large OpenAPI 3.0.2 spec file.

Works great converting down to v2, throws a promise error trying for v1. Easy way to reproduce:

# On Ubuntu 21.04
sudo apt update && sudo apt upgrade -y && sudo apt install -y nodejs npm && sudo reboot now
sudo npm install -g api-spec-converter

# Example file
wget https://gist.githubusercontent.com/kofalt/dd01bf2888a018c29241d0c8ac9791d4/raw/fe6ced0ff25f3c075802dc0b740a93438a46fde0/v3.json

# Works fine
api-spec-converter --from=openapi_3 --to=swagger_2 v3.json > v2.json

# Does not work
api-spec-converter --from=openapi_3 --to=swagger_1 v3.json > v1.json

# Also tried converting 2 -> 1, similar error
api-spec-converter --from=swagger_2 --to=swagger_1 v2.json > v1.json

Here's the stack trace:

Fatal Error: Unable to convert from openapi_3 to swagger_1
    at /usr/local/lib/node_modules/api-spec-converter/lib/base_format.js:168:13
    at tryCatcher (/usr/local/lib/node_modules/api-spec-converter/node_modules/bluebird/js/release/util.js:16:23)
    at Function.Promise.attempt.Promise.try (/usr/local/lib/node_modules/api-spec-converter/node_modules/bluebird/js/release/method.js:39:29)
    at module.exports.BaseFormat.convertTo (/usr/local/lib/node_modules/api-spec-converter/lib/base_format.js:162:21)
    at /usr/local/lib/node_modules/api-spec-converter/index.js:36:32
    at tryCatcher (/usr/local/lib/node_modules/api-spec-converter/node_modules/bluebird/js/release/util.js:16:23)
    at Promise._settlePromiseFromHandler (/usr/local/lib/node_modules/api-spec-converter/node_modules/bluebird/js/release/promise.js:547:31)
    at Promise._settlePromise (/usr/local/lib/node_modules/api-spec-converter/node_modules/bluebird/js/release/promise.js:604:18)
    at Promise._settlePromise0 (/usr/local/lib/node_modules/api-spec-converter/node_modules/bluebird/js/release/promise.js:649:10)
    at Promise._settlePromises (/usr/local/lib/node_modules/api-spec-converter/node_modules/bluebird/js/release/promise.js:729:18)
    at _drainQueueStep (/usr/local/lib/node_modules/api-spec-converter/node_modules/bluebird/js/release/async.js:93:12)
    at _drainQueue (/usr/local/lib/node_modules/api-spec-converter/node_modules/bluebird/js/release/async.js:86:9)
    at Async._drainQueues (/usr/local/lib/node_modules/api-spec-converter/node_modules/bluebird/js/release/async.js:102:5)
    at Immediate.Async.drainQueues [as _onImmediate] (/usr/local/lib/node_modules/api-spec-converter/node_modules/bluebird/js/release/async.js:15:14)
    at processImmediate (internal/timers.js:461:21)

Might be there's a more important error being missed due to the async call? Not sure.

kofalt avatar Jul 14 '21 17:07 kofalt