Ported prepareDataType() from old strong-remoting:ext/swagger.js
This commit is contained in:
parent
1a96d84035
commit
c6754baf83
|
@ -113,6 +113,40 @@ var routeHelper = module.exports = {
|
||||||
* See https://github.com/wordnik/swagger-spec/blob/master/versions/1.2.md#523-operation-object
|
* See https://github.com/wordnik/swagger-spec/blob/master/versions/1.2.md#523-operation-object
|
||||||
*/
|
*/
|
||||||
routeToAPIDoc: function routeToAPIDoc(route, classDef) {
|
routeToAPIDoc: function routeToAPIDoc(route, classDef) {
|
||||||
|
/**
|
||||||
|
* Converts from an sl-remoting data type to a Swagger dataType.
|
||||||
|
*/
|
||||||
|
function prepareDataType(type) {
|
||||||
|
if (!type) {
|
||||||
|
return 'void';
|
||||||
|
}
|
||||||
|
|
||||||
|
if(Array.isArray(type)) {
|
||||||
|
return 'array'; // todo items support
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO(schoon) - Add support for complex dataTypes, "models", etc.
|
||||||
|
switch (type) {
|
||||||
|
case 'Array':
|
||||||
|
return 'array';
|
||||||
|
case 'Boolean':
|
||||||
|
return 'boolean';
|
||||||
|
case 'buffer':
|
||||||
|
return 'byte';
|
||||||
|
case 'Date':
|
||||||
|
return 'date';
|
||||||
|
case 'number':
|
||||||
|
case 'Number':
|
||||||
|
return 'double';
|
||||||
|
case 'Object':
|
||||||
|
return 'object';
|
||||||
|
case 'String':
|
||||||
|
return 'string';
|
||||||
|
}
|
||||||
|
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
|
||||||
var returnDesc;
|
var returnDesc;
|
||||||
|
|
||||||
// Some parameters need to be altered; eventually most of this should
|
// Some parameters need to be altered; eventually most of this should
|
||||||
|
|
Loading…
Reference in New Issue