-
Notifications
You must be signed in to change notification settings - Fork 0
/
utils.js
58 lines (55 loc) · 1.76 KB
/
utils.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
function getType(property) {
var returnType;
if (property.type) {
switch (property.type) {
case 'string':
return 'string';
case 'integer':
return 'number';
case 'number':
return 'number';
case 'boolean':
return 'boolean';
case 'object':
returnType = 'object';
if (property.items) {
if (property.items.$ref) {
var splitRef = property.items.$ref.split('/');
returnType += splitRef[splitRef.length - 1] + '[]';
}
}
return returnType;
case 'array':
returnType = '';
if (property.items) {
if (property.items.$ref) {
var splitRef = property.items.$ref.split('/');
returnType += splitRef[splitRef.length - 1] + '[]';
} else {
returnType = getType(property.items) + '[]';
}
} else {
returnType = '[]';
}
return returnType;
default:
return 'any';
}
} else {
if (property.$ref) {
var splitRef = property.$ref.split('/');
return splitRef[splitRef.length - 1];
} else {
return 'any';
}
}
}
exports.getType = getType;
exports.uncapitalize = function (s) {
if (typeof s !== 'string') return ''
return s.charAt(0).toLowerCase() + s.slice(1)
}
exports.capitalize = function (s) {
if (typeof s !== 'string') return ''
return s.charAt(0).toUpperCase() + s.slice(1)
}