diff --git a/lib/swagger.js b/lib/swagger.js index 7b5644c..f570500 100644 --- a/lib/swagger.js +++ b/lib/swagger.js @@ -28,8 +28,17 @@ function Swagger(loopbackApplication, swaggerApp, opts) { basePath: loopbackApplication.get('restApiRoot') || '/api', resourcePath: 'resources', // Default consumes/produces - consumes: ['application/json', 'application/x-www-form-urlencoded'], - produces: ['application/json'], + consumes: [ + 'application/json', + 'application/x-www-form-urlencoded', + 'application/xml', 'text/xml' + ], + produces: [ + 'application/json', + 'application/xml', 'text/xml', + // JSONP content types + 'application/javascript', 'text/javascript' + ], version: getVersion() }); diff --git a/test/swagger.test.js b/test/swagger.test.js index b07f0bb..c6f0987 100644 --- a/test/swagger.test.js +++ b/test/swagger.test.js @@ -104,6 +104,33 @@ describe('swagger definition', function() { done(); }); }); + + it('includes `consumes`', function(done) { + var app = mountSwagger(); + getAPIDeclaration(app, 'products').end(function(err, res) { + if (err) return done(err); + expect(res.body.consumes).to.have.members([ + 'application/json', + 'application/x-www-form-urlencoded', + 'application/xml', 'text/xml' + ]); + done(); + }); + }); + + it('includes `produces`', function(done) { + var app = mountSwagger(); + getAPIDeclaration(app, 'products').end(function(err, res) { + if (err) return done(err); + expect(res.body.produces).to.have.members([ + 'application/json', + 'application/xml', 'text/xml', + // JSONP content types + 'application/javascript', 'text/javascript' + ]); + done(); + }); + }); }); describe('Cross-origin resource sharing', function() {