swagger-api / swagger-node

Swagger module for node.js
http://swagger.io
Apache License 2.0
3.97k stars 585 forks source link

swagger-node-restify and application/json-patch+patch #247

Open jmorey opened 9 years ago

jmorey commented 9 years ago

I have recently started using swagger-node-testify and am having a problem with supporting PATCH. Things work fine when I have the PATCH consume application/json but every call fails with a schema validation of the body when I change it to consume application/json-patch+json. I am pretty sure I am sending a valid PATCH body. Is this a problem with swagger-node-testify?

Thanks.

theganyo commented 9 years ago

@whitlockjc is there potentially an issue in swagger-tools causing this?

moldi commented 8 years ago

swagger-tools is using the default bodyParser.json() which only handles application/json.

In order to support additional content types, go to your app.js and add the following:

// at the top
var bodyParser = require('body-parser');

// before swaggerExpress.register(app);
app.use(bodyParser.json({ type: ['application/json', 'application/json-patch+json'] }));

see https://github.com/apigee-127/swagger-tools/issues/244 for related discussion

whitlockjc commented 8 years ago

@moldi nailed it.