Node server stub generated from Swagger 2.0 specification starts up fine, but throws an error on sending the request.
Here is the error log:
Error: Cannot resolve the configured swagger-router handler: Transactions_GET-transaction
at swaggerRouter (C:\nodejs-server-server\node_modules\swagger-tools\middleware\swagger-router.js:414:18)
at call (C:\nodejs-server-server\node_modules\connect\index.js:239:7)
at next (C:\nodejs-server-server\node_modules\connect\index.js:183:5)
at C:\nodejs-server-server\node_modules\swagger-tools\middleware\swagger-validator.js:352:30
at C:\nodejs-server-server\node_modules\async\lib\async.js:52:16
at C:\nodejs-server-server\node_modules\async\lib\async.js:361:13
at C:\nodejs-server-server\node_modules\async\lib\async.js:52:16
at async.forEachOf.async.eachOf (C:\nodejs-server-server\node_modules\async\lib\async.js:236:30)
at _asyncMap (C:\nodejs-server-server\node_modules\async\lib\async.js:355:9)
at Object.map (C:\nodejs-server-server\node_modules\async\lib\async.js:337:20)
https://app.swaggerhub.com/apis/RitwikChatterjee/transactions/1.0.1
Used editor.swagger.io and www.swaggerhub.com to download the generated server stub
None
Looks like a dependency is broken. Not sure what though.
On Further investigation
Thanks to Natalie, she pointed me to this link https://github.com/apigee-127/swagger-tools/issues/321
However, here is what I found when I looked at the generated code:
x-swagger-router-controller tag was not in my original definition, when codegen generated the code, it auto incorporated the same at the method level in the generated swagger.yaml file (/api/swagger.yaml). <x-swagger-router-controller>_<operationId> which was not available.Manual workaround
I could fix the issue manually by updating the operationId in the generated swagger.yaml file to the function-name created by codegen.
Is this a bug?
Using lower camel case for operation IDs fixed it for me.
Most helpful comment
Using lower camel case for operation IDs fixed it for me.