Move `convertText` to `typeConverter`
Create a new module `lib/type-converter.js`. Move `routeHelper.convertText` to this new module.
This commit is contained in:
parent
856d34b9d4
commit
42dedfcacc
|
@ -4,7 +4,7 @@
|
|||
* Module dependencies.
|
||||
*/
|
||||
var modelHelper = require('./model-helper');
|
||||
var routeHelper = require('./route-helper');
|
||||
var typeConverter = require('./type-converter');
|
||||
var urlJoin = require('./url-join');
|
||||
|
||||
/**
|
||||
|
@ -47,7 +47,7 @@ var classHelper = module.exports = {
|
|||
|
||||
return {
|
||||
path: aClass.http.path,
|
||||
description: routeHelper.convertText(description)
|
||||
description: typeConverter.convertText(description)
|
||||
};
|
||||
}
|
||||
};
|
||||
|
|
|
@ -8,6 +8,7 @@ var debug = require('debug')('loopback:explorer:routeHelpers');
|
|||
var _cloneDeep = require('lodash.clonedeep');
|
||||
var translateDataTypeKeys = require('./translate-data-type-keys');
|
||||
var modelHelper = require('./model-helper');
|
||||
var typeConverter = require('./type-converter');
|
||||
|
||||
/**
|
||||
* Export the routeHelper singleton.
|
||||
|
@ -142,8 +143,8 @@ var routeHelper = module.exports = {
|
|||
parameters: accepts,
|
||||
// TODO(schoon) - We don't have descriptions for this yet.
|
||||
responseMessages: [],
|
||||
summary: routeHelper.convertText(route.description),
|
||||
notes: routeHelper.convertText(route.notes),
|
||||
summary: typeConverter.convertText(route.description),
|
||||
notes: typeConverter.convertText(route.notes),
|
||||
deprecated: route.deprecated
|
||||
})]
|
||||
};
|
||||
|
@ -200,7 +201,7 @@ var routeHelper = module.exports = {
|
|||
var out = {
|
||||
paramType: paramType || type,
|
||||
name: name,
|
||||
description: routeHelper.convertText(accepts.description),
|
||||
description: typeConverter.convertText(accepts.description),
|
||||
type: accepts.type,
|
||||
required: !!accepts.required,
|
||||
defaultValue: accepts.defaultValue,
|
||||
|
@ -239,18 +240,6 @@ var routeHelper = module.exports = {
|
|||
obj[key] = typeDesc[key];
|
||||
});
|
||||
return obj;
|
||||
},
|
||||
|
||||
/**
|
||||
* Convert a text value that can be expressed either as a string or
|
||||
* as an array of strings.
|
||||
* @param {string|Array} value
|
||||
* @returns {string}
|
||||
*/
|
||||
convertText: function(value) {
|
||||
if (Array.isArray(value))
|
||||
return value.join('\n');
|
||||
return value;
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -0,0 +1,14 @@
|
|||
var typeConverter = module.exports = {
|
||||
|
||||
/**
|
||||
* Convert a text value that can be expressed either as a string or
|
||||
* as an array of strings.
|
||||
* @param {string|Array} value
|
||||
* @returns {string}
|
||||
*/
|
||||
convertText: function(value) {
|
||||
if (Array.isArray(value))
|
||||
return value.join('\n');
|
||||
return value;
|
||||
}
|
||||
};
|
Loading…
Reference in New Issue