@devlearning/swagger-generator 0.0.8 → 0.0.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/autogeneration/output/api.autogenerated.ts +13 -745
- package/dist/api.constants.js +16 -0
- package/dist/generator.js +252 -249
- package/dist/index.js +2 -300
- package/dist/model.constants.js +4 -0
- package/dist/models/swagger-component-property.js +1 -0
- package/dist/models/swagger-content.js +1 -0
- package/dist/models/swagger-info.js +1 -0
- package/dist/models/swagger-method.js +1 -0
- package/dist/models/swagger-schema.js +1 -0
- package/package.json +2 -2
- package/src/api.constants.ts +19 -0
- package/src/generator.ts +303 -309
- package/src/index.ts +3 -355
- package/src/model.constants.ts +7 -0
- package/src/models/swagger-component-property.ts +8 -0
- package/src/models/swagger-component.ts +1 -1
- package/src/models/swagger-content.ts +5 -0
- package/src/models/swagger-info.ts +4 -0
- package/src/models/swagger-method.ts +8 -0
- package/src/models/swagger-schema.ts +6 -0
- package/src/models/swagger.ts +4 -30
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export const API_PRE = `import { HttpClient } from '@angular/common/http';
|
|
2
|
+
import { Observable, catchError, map } from 'rxjs';
|
|
3
|
+
import { httpOptions } from 'src/app/core/utils/http-options';
|
|
4
|
+
import * as Models from './model.autogenerated';
|
|
5
|
+
|
|
6
|
+
export abstract class ApiAutogeneratedService {
|
|
7
|
+
constructor(
|
|
8
|
+
private _http: HttpClient,
|
|
9
|
+
private _baseUrl: string,
|
|
10
|
+
) { }
|
|
11
|
+
|
|
12
|
+
protected abstract _handleRequest<T>(request: T): T;
|
|
13
|
+
protected abstract _handleResponse<T>(response: T): T;
|
|
14
|
+
protected abstract _handleError(error: any, obs: any): any;
|
|
15
|
+
`;
|
|
16
|
+
export const API_POST = `}`;
|
package/dist/generator.js
CHANGED
|
@@ -1,249 +1,252 @@
|
|
|
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
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
//
|
|
70
|
-
//
|
|
71
|
-
//
|
|
72
|
-
//
|
|
73
|
-
//
|
|
74
|
-
//
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
//
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
//
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
//
|
|
206
|
-
//
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
1
|
+
import fs from 'fs';
|
|
2
|
+
import { API_PRE, API_POST } from './api.constants.js';
|
|
3
|
+
import { MODEL_POST, MODEL_PRE } from './model.constants.js';
|
|
4
|
+
const contentType = 'application/json';
|
|
5
|
+
export class Generator {
|
|
6
|
+
_swagger;
|
|
7
|
+
_outputDirectory;
|
|
8
|
+
constructor(swagger, outputDirectory) {
|
|
9
|
+
this._swagger = swagger;
|
|
10
|
+
this._outputDirectory = outputDirectory;
|
|
11
|
+
}
|
|
12
|
+
generateApi() {
|
|
13
|
+
console.debug(`Start autogeneration Apis`);
|
|
14
|
+
let apiMethods = ``;
|
|
15
|
+
for (let index = 0; index < Object.getOwnPropertyNames(this._swagger.paths).length; index++) {
|
|
16
|
+
const apiName = Object.getOwnPropertyNames(this._swagger.paths)[index];
|
|
17
|
+
const swaggerMethod = this._swagger.paths[apiName];
|
|
18
|
+
const method = Object.getOwnPropertyNames(swaggerMethod)[0];
|
|
19
|
+
const swaggerMethodInfo = swaggerMethod[method];
|
|
20
|
+
console.debug(`\tAPI - ${apiName} - ${method}`);
|
|
21
|
+
let parametersString = this.retrieveParameters(swaggerMethodInfo);
|
|
22
|
+
let queryParameters = this.retrieveQueryParameters(swaggerMethodInfo);
|
|
23
|
+
let returnTypeString = this.retrieveReturnType(swaggerMethodInfo);
|
|
24
|
+
if (returnTypeString == null)
|
|
25
|
+
returnTypeString = 'void';
|
|
26
|
+
let prepareRequestString = ``; //request = this._handleRequest(request);
|
|
27
|
+
let haveRequest = swaggerMethodInfo.requestBody != null;
|
|
28
|
+
if (haveRequest) {
|
|
29
|
+
prepareRequestString = `request = this._handleRequest(request);
|
|
30
|
+
`;
|
|
31
|
+
}
|
|
32
|
+
apiMethods +=
|
|
33
|
+
`
|
|
34
|
+
public ${apiName.replace('/api/v{version}/', '').replaceAll('/', '_')}(${parametersString}): Observable<${returnTypeString}>{
|
|
35
|
+
${prepareRequestString}return this._http.${method}<${returnTypeString}>(\`\${_baseUrl}${apiName.replace('{version}', '1')}${queryParameters}\`${haveRequest ? ', request' : ''}, httpOptions)
|
|
36
|
+
.pipe(
|
|
37
|
+
map(x => this._handleResponse(x)),
|
|
38
|
+
catchError((err, obs) => {
|
|
39
|
+
return this._handleError(err, <Observable<any>>obs);
|
|
40
|
+
})
|
|
41
|
+
);
|
|
42
|
+
}
|
|
43
|
+
`;
|
|
44
|
+
}
|
|
45
|
+
fs.writeFileSync(this._outputDirectory + "/api.autogenerated.ts", `${API_PRE}
|
|
46
|
+
${API_POST}`, { flag: 'w' });
|
|
47
|
+
}
|
|
48
|
+
generateModel() {
|
|
49
|
+
let usedTypes = [];
|
|
50
|
+
for (let index = 0; index < Object.getOwnPropertyNames(this._swagger.paths).length; index++) {
|
|
51
|
+
const apiName = Object.getOwnPropertyNames(this._swagger.paths)[index];
|
|
52
|
+
const swaggerMethod = this._swagger.paths[apiName];
|
|
53
|
+
const method = Object.getOwnPropertyNames(swaggerMethod)[0];
|
|
54
|
+
const swaggerMethodInfo = swaggerMethod[method];
|
|
55
|
+
// if(apiName == "/api/v{version}/Ticket/Create"){
|
|
56
|
+
// debugger
|
|
57
|
+
// }
|
|
58
|
+
let parametersRefType = swaggerMethodInfo.parameters.filter(x => x.in == 'query' && x.schema?.$ref != null).map(x => x.schema.$ref.replace('#/components/schemas/', ''));
|
|
59
|
+
usedTypes = usedTypes.concat(parametersRefType);
|
|
60
|
+
if (swaggerMethodInfo.responses[200].content[contentType].schema.$ref != null) {
|
|
61
|
+
usedTypes.push(swaggerMethodInfo.responses[200].content[contentType].schema.$ref.replace('#/components/schemas/', ''));
|
|
62
|
+
}
|
|
63
|
+
if (swaggerMethodInfo.requestBody?.content[contentType]?.schema?.$ref) {
|
|
64
|
+
usedTypes.push(swaggerMethodInfo.requestBody?.content[contentType]?.schema?.$ref.replace('#/components/schemas/', ''));
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
this.retrieveNestedObjects(usedTypes);
|
|
68
|
+
usedTypes = [...new Set(usedTypes.map(item => item))]; // [ 'A', 'B']
|
|
69
|
+
// usedTypes = usedTypes.filter((value, index, array) => {
|
|
70
|
+
// array.indexOf(value) === index;
|
|
71
|
+
// });
|
|
72
|
+
// usedTypes.forEach(element => {
|
|
73
|
+
// console.debug(element);
|
|
74
|
+
// });
|
|
75
|
+
console.debug(`Start autogeneration Models`);
|
|
76
|
+
let models = ``;
|
|
77
|
+
for (let index = 0; index < Object.getOwnPropertyNames(this._swagger.components.schemas).length; index++) {
|
|
78
|
+
const modelName = Object.getOwnPropertyNames(this._swagger.components.schemas)[index];
|
|
79
|
+
if (modelName == 'ActivatedVoucherSnackListResponse') {
|
|
80
|
+
console.debug("ActivatedVoucherSnackListResponse");
|
|
81
|
+
}
|
|
82
|
+
if (usedTypes.indexOf(modelName) < 0) {
|
|
83
|
+
console.debug(`\tModel SKIP - ${modelName}`);
|
|
84
|
+
continue;
|
|
85
|
+
}
|
|
86
|
+
;
|
|
87
|
+
const swaggerCopmponent = this._swagger.components.schemas[modelName];
|
|
88
|
+
console.debug(`\tModel - ${modelName}`);
|
|
89
|
+
let type = swaggerCopmponent.type == 'integer' ? 'enum' : 'class';
|
|
90
|
+
let content = this.retrieveObjectContent(modelName, swaggerCopmponent);
|
|
91
|
+
models +=
|
|
92
|
+
`
|
|
93
|
+
export ${type} ${modelName} {${content}
|
|
94
|
+
}
|
|
95
|
+
`;
|
|
96
|
+
}
|
|
97
|
+
fs.writeFileSync(this._outputDirectory + "/model.autogenerated.ts", `${MODEL_PRE}
|
|
98
|
+
${models}
|
|
99
|
+
${MODEL_POST}`, { flag: 'w' });
|
|
100
|
+
}
|
|
101
|
+
retrieveParameters(swaggerMethodInfo) {
|
|
102
|
+
if (swaggerMethodInfo.requestBody != null) {
|
|
103
|
+
return `request: Models.${swaggerMethodInfo.requestBody.content[contentType].schema.$ref.replace('#/components/schemas/', '')}`;
|
|
104
|
+
}
|
|
105
|
+
let parameters = ``;
|
|
106
|
+
swaggerMethodInfo.parameters.filter(x => x.in == 'query').forEach(parameter => {
|
|
107
|
+
if (parameter.schema.$ref != null) {
|
|
108
|
+
parameters += `Models.${parameter.name}: ${parameter.schema.$ref.replace('#/components/schemas/', '')}, `;
|
|
109
|
+
}
|
|
110
|
+
else {
|
|
111
|
+
parameters += `${parameter.name}: ${this.getNativeType(parameter.schema)}, `;
|
|
112
|
+
}
|
|
113
|
+
});
|
|
114
|
+
if (parameters.length > 2)
|
|
115
|
+
parameters = parameters.substring(0, parameters.length - 2);
|
|
116
|
+
return parameters;
|
|
117
|
+
}
|
|
118
|
+
retrieveQueryParameters(swaggerMethodInfo) {
|
|
119
|
+
if (swaggerMethodInfo.requestBody != null)
|
|
120
|
+
return ``;
|
|
121
|
+
let filteredParameters = swaggerMethodInfo.parameters.filter(x => x.in == 'query');
|
|
122
|
+
if (filteredParameters.length == 0)
|
|
123
|
+
return ``;
|
|
124
|
+
let parameters = `?`;
|
|
125
|
+
filteredParameters.forEach(parameter => {
|
|
126
|
+
if (parameter.schema.$ref != null) {
|
|
127
|
+
this.parametrizeObject(parameter.schema.$ref);
|
|
128
|
+
//parameters += `${parameter.name}: ${parameter.schema.$ref.replace('#/components/schemas/', '')}&`;
|
|
129
|
+
}
|
|
130
|
+
else {
|
|
131
|
+
parameters += `${this.lowercaseFirstLetter(parameter.name)}=\${` + this.lowercaseFirstLetter(parameter.name) + `}&`;
|
|
132
|
+
}
|
|
133
|
+
});
|
|
134
|
+
if (parameters.length > 1)
|
|
135
|
+
parameters = parameters.substring(0, parameters.length - 1);
|
|
136
|
+
return parameters;
|
|
137
|
+
}
|
|
138
|
+
retrieveReturnType(swaggerMethodInfo) {
|
|
139
|
+
if (swaggerMethodInfo.responses[200] == null)
|
|
140
|
+
return 'void';
|
|
141
|
+
if (swaggerMethodInfo.responses[200].content[contentType].schema.$ref != null)
|
|
142
|
+
return `Models.${swaggerMethodInfo.responses[200]?.content[contentType].schema.$ref.replace('#/components/schemas/', '')}`;
|
|
143
|
+
if (swaggerMethodInfo.responses[200]?.content[contentType].schema.type != null)
|
|
144
|
+
return this.getNativeType(swaggerMethodInfo.responses[200]?.content[contentType].schema);
|
|
145
|
+
console.error("unmanaged swaggerMethodInfo", swaggerMethodInfo);
|
|
146
|
+
throw new Error("unmanaged swaggerMethodInfo");
|
|
147
|
+
}
|
|
148
|
+
retrieveType(swaggerComponentProperty) {
|
|
149
|
+
if (swaggerComponentProperty.$ref != null)
|
|
150
|
+
return swaggerComponentProperty.$ref.replace('#/components/schemas/', '');
|
|
151
|
+
if (swaggerComponentProperty.type != null && swaggerComponentProperty.type == 'array')
|
|
152
|
+
if (swaggerComponentProperty.items.$ref != null)
|
|
153
|
+
return swaggerComponentProperty.items.$ref.replace('#/components/schemas/', '');
|
|
154
|
+
else
|
|
155
|
+
return this.getNativeType(swaggerComponentProperty);
|
|
156
|
+
if (swaggerComponentProperty.type != null)
|
|
157
|
+
return this.getNativeType(swaggerComponentProperty);
|
|
158
|
+
if (swaggerComponentProperty.type == null)
|
|
159
|
+
return '';
|
|
160
|
+
console.error("unmanaged swaggerMethodInfo", swaggerComponentProperty);
|
|
161
|
+
throw new Error("unmanaged swaggerMethodInfo");
|
|
162
|
+
}
|
|
163
|
+
parametrizeObject(objectName) {
|
|
164
|
+
let component = this._swagger.components.schemas[objectName.replace('#/components/schemas/', '')];
|
|
165
|
+
if (component == null || component.properties == null)
|
|
166
|
+
return ``;
|
|
167
|
+
console.debug(component.properties);
|
|
168
|
+
return ``;
|
|
169
|
+
}
|
|
170
|
+
retrieveObjectContent(name, swaggerComponent) {
|
|
171
|
+
if (swaggerComponent.type == 'object')
|
|
172
|
+
return this.retrieveObjectProperties(swaggerComponent);
|
|
173
|
+
else if (swaggerComponent.type == 'integer')
|
|
174
|
+
return this.retrieveEnumValues(name, swaggerComponent);
|
|
175
|
+
}
|
|
176
|
+
retrieveObjectProperties(swaggerCopmponent) {
|
|
177
|
+
if (swaggerCopmponent.properties == null)
|
|
178
|
+
return ``;
|
|
179
|
+
// console.debug(`\t\t${Object.getOwnPropertyNames(swaggerCopmponent.properties).length}`);
|
|
180
|
+
let properties = ``;
|
|
181
|
+
for (let index = 0; index < Object.getOwnPropertyNames(swaggerCopmponent.properties).length; index++) {
|
|
182
|
+
const propertyName = Object.getOwnPropertyNames(swaggerCopmponent.properties)[index];
|
|
183
|
+
properties +=
|
|
184
|
+
`
|
|
185
|
+
${propertyName}: ${this.retrieveType(swaggerCopmponent.properties[propertyName])} | undefined;`;
|
|
186
|
+
}
|
|
187
|
+
return properties;
|
|
188
|
+
}
|
|
189
|
+
retrieveEnumValues(name, swaggerCopmponent) {
|
|
190
|
+
if (swaggerCopmponent.enum == null)
|
|
191
|
+
return ``;
|
|
192
|
+
let properties = ``;
|
|
193
|
+
for (let index = 0; index < swaggerCopmponent.enum.length; index++) {
|
|
194
|
+
const name = swaggerCopmponent.enum[index].split('-')[0].trim();
|
|
195
|
+
const value = swaggerCopmponent.enum[index].split('-')[1].trim();
|
|
196
|
+
properties +=
|
|
197
|
+
`
|
|
198
|
+
${name} = ${value},`;
|
|
199
|
+
}
|
|
200
|
+
return properties;
|
|
201
|
+
}
|
|
202
|
+
retrieveNestedObjects(usedTypes) {
|
|
203
|
+
for (let i = 0; i < usedTypes.length; i++) {
|
|
204
|
+
const swaggerCopmponent = this._swagger.components.schemas[usedTypes[i]];
|
|
205
|
+
// const name = usedTypes[i]
|
|
206
|
+
// const modelName = <string>Object.getOwnPropertyNames(this._swagger.components.schemas)[name];
|
|
207
|
+
this.retrieveNestedObjects2(swaggerCopmponent, usedTypes);
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
retrieveNestedObjects2(swaggerComponent, usedTypes) {
|
|
211
|
+
if (!swaggerComponent.properties)
|
|
212
|
+
return;
|
|
213
|
+
for (let j = 0; j < Object.getOwnPropertyNames(swaggerComponent.properties).length; j++) {
|
|
214
|
+
const propertyName = Object.getOwnPropertyNames(swaggerComponent.properties)[j];
|
|
215
|
+
let nestedUsedType = '';
|
|
216
|
+
if (swaggerComponent.properties[propertyName].$ref != null) {
|
|
217
|
+
nestedUsedType = swaggerComponent.properties[propertyName].$ref.replace('#/components/schemas/', '');
|
|
218
|
+
}
|
|
219
|
+
else if (swaggerComponent.properties[propertyName].type == 'array' && swaggerComponent.properties[propertyName].items.$ref != null) {
|
|
220
|
+
nestedUsedType = swaggerComponent.properties[propertyName].items.$ref.replace('#/components/schemas/', '');
|
|
221
|
+
}
|
|
222
|
+
if (nestedUsedType != '' && usedTypes.findIndex(x => x == nestedUsedType) == -1) {
|
|
223
|
+
usedTypes.push(nestedUsedType);
|
|
224
|
+
let nested = this._swagger.components.schemas[nestedUsedType];
|
|
225
|
+
this.retrieveNestedObjects2(nested, usedTypes);
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
getNativeType(schema) {
|
|
230
|
+
if (schema.type == 'integer')
|
|
231
|
+
return 'number';
|
|
232
|
+
if (schema.type == 'string' && schema.format == null)
|
|
233
|
+
return 'string';
|
|
234
|
+
if (schema.type == 'string' && schema.format == 'date-time')
|
|
235
|
+
return 'moment.Moment';
|
|
236
|
+
if (schema.type == 'string' && schema.format == 'uuid')
|
|
237
|
+
return 'string';
|
|
238
|
+
if (schema.type == 'number')
|
|
239
|
+
return 'number';
|
|
240
|
+
if (schema.type == 'array')
|
|
241
|
+
return '[]';
|
|
242
|
+
if (schema.type == 'boolean')
|
|
243
|
+
return 'boolean';
|
|
244
|
+
if (schema.type == 'object')
|
|
245
|
+
return 'any';
|
|
246
|
+
console.error("unmanaged schema type", schema);
|
|
247
|
+
throw new Error("unmanaged schema");
|
|
248
|
+
}
|
|
249
|
+
lowercaseFirstLetter(value) {
|
|
250
|
+
return value.charAt(0).toLowerCase() + value.slice(1);
|
|
251
|
+
}
|
|
252
|
+
}
|