apigee-127 / swagger-node-runner

The heart of Swagger-Node
MIT License
102 stars 123 forks source link

swagger-node is selecting wrong path for the request #146

Closed nagireddy51 closed 5 years ago

nagireddy51 commented 5 years ago

Recently, we've upgraded swagger-express-mw and swagger-node-runner to 0.7.0. Looks like the upgraded version doesn't understand the difference btw /#uri-part#/{id} and /#uri-part#/docs.

And, started selecting /#uri-part#/{id} for requests sent for /#uri-part#/docs.

Post method is defined for /#uri-part#/docs. On receiving the request, it's selecting /#uri-part#/{id} and checking Post method on it.

Error: Path [/#uri-part#/{id}] defined in Swagger, but POST operation is not. at middleware (C:\Workbench\workspace#application-name#\node_modules\swagger-node-runner\lib\connect_middleware.js:31:21) at Layer.handle [as handle_request] (C:\Workbench\workspace#application-name#\node_modules\express\lib\router\layer.js:95:5) at trim_prefix (C:\Workbench\workspace#application-name#\node_modules\express\lib\router\index.js:317:13) at C:\Workbench\workspace#application-name#\node_modules\express\lib\router\index.js:284:7 at Function.process_params (C:\Workbench\workspace#application-name#\node_modules\express\lib\router\index.js:335:12) at next (C:\Workbench\workspace#application-name#\node_modules\express\lib\router\index.js:275:10) at Busboy.busboy.on (C:\Workbench\workspace#application-name#\node_modules\express-fileupload\lib\processMultipart.js:170:5) at Busboy.emit (events.js:203:15) at Busboy.EventEmitter.emit (domain.js:448:20) at Busboy.emit (C:\Workbench\workspace#application-name#\node_modules\busboy\lib\main.js:38:33) at C:\Workbench\workspace#application-name#\node_modules\busboy\lib\types\multipart.js:52:13 at appd_proxy (C:\Workbench\workspace#application-name#\node_modules\appdynamics\lib\core\proxy.js:420:22) at process._tickCallback (internal/process/next_tick.js:61:11)

nagireddy51 commented 5 years ago

uri-part# and #application-name# - Our uri and application-name are replaced with.

theganyo commented 5 years ago

I would try to reorder the declaration in your API doc. (See also: https://github.com/apigee-127/sway/issues/76)

nagireddy51 commented 5 years ago

I would try to reorder the declaration in your API doc. (See also: apigee-127/sway#76)

whitlockjc replied on 4th June 2018, https://github.com/apigee-127/sway/issues/76. I don't think that the fix is working.

I would try to reorder then and see. There should be a flexible solution. The reordering isn't the solution.

nagireddy51 commented 5 years ago

I would try to reorder the declaration in your API doc. (See also: apigee-127/sway#76)

whitlockjc replied on 4th June 2018, apigee-127/sway#76. I don't think that the fix is working.

I would try to reorder then and see. There should be a flexible solution. The reordering isn't the solution.

I can't reorder as well. I have Paths like /referral/{id}/notes, /referral/{id}/activities, /referral/activity/{activityId}, and etc., I guess, it doesn't work. I'll have to replace all the paths like /referral1/{id}/notes, /referral2/{id}/activities, /referral3/activity/{activityId}, etc,.

nagireddy51 commented 5 years ago

https://github.com/apigee-127/sway/commit/2ed7ed8f98227ec7a1bc3c5b56349654ef2bd33b#comments has the solution for the fix. swagger-node-runner should have sway-2.0.6 to have the issue fixed.