Set up default consumes/produces media types

See:

https://github.com/strongloop/loopback/issues/432
https://github.com/wordnik/swagger-js/issues/107
This commit is contained in:
Raymond Feng 2014-08-03 21:48:16 -07:00
parent 885ae9e71d
commit 0aa476a682
2 changed files with 5 additions and 2 deletions

View File

@ -28,6 +28,8 @@ var classHelper = module.exports = {
basePath: opts.basePath,
resourcePath: urlJoin('/', opts.resourcePath),
apis: [],
consumes: aClass.http.consumes || opts.consumes,
produces: aClass.http.produces || opts.produces,
models: modelHelper.generateModelDefinition(aClass.ctor, {})
};
},

View File

@ -7,12 +7,10 @@ module.exports = Swagger;
/**
* Module dependencies.
*/
var debug = require('debug')('loopback:explorer:swagger');
var path = require('path');
var urlJoin = require('./url-join');
var _defaults = require('lodash.defaults');
var classHelper = require('./class-helper');
var modelHelper = require('./model-helper');
var routeHelper = require('./route-helper');
/**
@ -28,6 +26,9 @@ function Swagger(loopbackApplication, swaggerApp, opts) {
swaggerVersion: '1.2',
basePath: loopbackApplication.get('restApiRoot') || '/api',
resourcePath: 'resources',
// Default consumes/produces to application/json
consumes: ['application/json'],
produces: ['application/json'],
version: getVersion()
});