Extend `consumes` and `produces` metadata
- Include XML content-types for both input and output - Include JSONP (javascript) content-types for output
This commit is contained in:
parent
4d0e711087
commit
622f6176f3
|
@ -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()
|
||||
});
|
||||
|
||||
|
|
|
@ -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() {
|
||||
|
|
Loading…
Reference in New Issue