apigee-127 / swagger-node-runner

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

response validator attempt to validate non swagger operations #56

Closed niallmccullagh closed 7 years ago

niallmccullagh commented 8 years ago

I've a error handler set up

swaggerExpress.runner.on('responseValidationError', function(validationResponse, request, response) { ... }

and I'm also serving up the swagger-ui using static serve.

However the hookResponseForValidation fails with

TypeError: Cannot read property 'validateResponse' of undefined api_1 | at ServerResponse.hookEnd (/app/node_modules/swagger-node-runner/lib/connect_middleware.js:163:63)

as operation is undefined on context.request.swagger.operation.validateResponse

I'll submit a pull request shortly but the gist of the change is to filter out based on

if(context.request.swagger.operation == undefined){ debug('not a swagger operation, will not validate response'); }

321ckatz123 commented 7 years ago

@theganyo do you have a timeframe for this to get pushed to NPM? I am also running into it. It's not deal breaking, but it is quite annoying (as I'm loading swagger-ui as well).

revnode commented 7 years ago

Yup, same here. Please push to NPM. Thanks!

theganyo commented 7 years ago

You got it: swagger-node-runner@0.7.2