From 0aa476a6824611542e7fa8a1f477688ee73b6864 Mon Sep 17 00:00:00 2001 From: Raymond Feng Date: Sun, 3 Aug 2014 21:48:16 -0700 Subject: [PATCH] Set up default consumes/produces media types See: https://github.com/strongloop/loopback/issues/432 https://github.com/wordnik/swagger-js/issues/107 --- lib/class-helper.js | 2 ++ lib/swagger.js | 5 +++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/class-helper.js b/lib/class-helper.js index de3a0a7..333b5ea 100644 --- a/lib/class-helper.js +++ b/lib/class-helper.js @@ -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, {}) }; }, diff --git a/lib/swagger.js b/lib/swagger.js index da4102c..d517303 100644 --- a/lib/swagger.js +++ b/lib/swagger.js @@ -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() });