swagger-tools
swagger-tools copied to clipboard
curl -d '{}' /your/swagger/url/here causes a crash
I discovered this error and a co-worker did the sleuthing to track down the exact problem. It turns out that curl will default to application/x-www-form-urlencoded
when you don't specify a content type. And that can cause a process to crash due to an unhandled exception (at least for us) deep in the bowels of things completely outside of our code.
What happens is that the url encoded data gets choked on right here: https://github.com/apigee-127/swagger-tools/blob/master/middleware/swagger-metadata.js#L206
He changed that "%s" to "%j" and no more problems.
I've made a PR for these changes: https://github.com/apigee-127/swagger-tools/pull/505
While driving this morning I realized that this issue is a little vague. The URL needs to be one that accepts POSTs because otherwise the debug message is circumvented, no further processing (and failing) takes place. It may also need to be running in debug mode (haven't verified yet).
Thanks, I'll give it a peek.