-
Notifications
You must be signed in to change notification settings - Fork 63
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Validation error when responding with cached content #91
Comments
What version of swagger-node-runner are you on? The newest versions (0.6.4+) no longer attempt to hijack the response pipe and instead just allow you to listen for errors. See this: https://github.com/theganyo/swagger-node-runner/releases/tag/v0.6.4 |
Ah, I was on 0.5x. Just updated to 0.6x and it seem that 0.6 introduced a few changes that breaks a few existing things. Working through them currently... |
Yup, following that 👍 |
Good and bad news. Good news is 0.6 upgrade went well with a few minor changes.
|
Hmm. Looks like I perhaps cleaned up too much during the upgrades. I'll have to look into that, but a quick fix should be for you to assign it in your fitting. Just something like this:
|
I think the whole https://github.com/apigee-127/volos/blob/master/swagger/lib/app-middleware.js file needs a review. Are there tests? req.swagger.path isn't defined too (I suspect it should be the api path). Anyway, I'll leave you to it for now. happy holidays and thanks for the help. |
I'm pretty sure you're correct. Unfortunately, I won't have time to get into that for a couple weeks, so if you're blocked, you may still need to use a bit of chewing gum to add that field back in for now. |
Any update on this? Thanks! |
@tanzim I'm very sorry, I've been otherwise occupied recently and I haven't had anyone else with these issues. Let's start over... are you using these modules? https://www.npmjs.com/package/volos-swagger-apply The reason I ask is that I'm fairly certain those are being successfully used as-is today. |
A follow up to #90
I may have spoken too soon. While the caching works as expected, it seems that it doesn't play quite well with swagger response validation.
It seems that cached response streamed to the http response [1] with the headers etc. set and when the validator's response end is called, data passed to res.end [2] is undefined. This leads response validation error and an attempt to send headers twice (since the cache already wrote to the response)
Without further debugging I can't say much at this point sadly. I'm on Node 4.2.1 by the way. Seeing that the cache encoder is using the stream module, this could be important.
[1] https://github.com/apigee-127/volos/blob/master/cache/common/lib/cache-encoder.js#L92
[2] https://github.com/apigee-127/swagger-tools/blob/master/middleware/swagger-validator.js#L176
The text was updated successfully, but these errors were encountered: