pg-mvc-service 2.0.59 → 2.0.61
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/dist/reqestResponse/ReqResType.js +4 -4
- package/dist/reqestResponse/RequestType.js +44 -14
- package/dist/reqestResponse/ResponseType.js +13 -13
- package/package.json +1 -1
- package/src/reqestResponse/ReqResType.ts +9 -9
- package/src/reqestResponse/RequestType.ts +48 -16
- package/src/reqestResponse/ResponseType.ts +13 -13
|
@@ -44,7 +44,7 @@ class ReqResType {
|
|
|
44
44
|
const key = keys[i];
|
|
45
45
|
if (typeof key === 'number') {
|
|
46
46
|
if (property.type === 'array' || property.type === 'array?') {
|
|
47
|
-
property = property.
|
|
47
|
+
property = property.item;
|
|
48
48
|
continue;
|
|
49
49
|
}
|
|
50
50
|
else {
|
|
@@ -57,7 +57,7 @@ class ReqResType {
|
|
|
57
57
|
if (typeof key !== 'number') {
|
|
58
58
|
throw new Error(`getPropertyでnumber型のINPUTで、array以外の場合はエラー\nキー一覧:${keys.join(',')} エラーキー:${key}`);
|
|
59
59
|
}
|
|
60
|
-
property = property.
|
|
60
|
+
property = property.item;
|
|
61
61
|
continue;
|
|
62
62
|
case 'object':
|
|
63
63
|
case 'object?':
|
|
@@ -202,8 +202,8 @@ class ReqResType {
|
|
|
202
202
|
if (property.type === 'enum' || property.type === 'enum?') {
|
|
203
203
|
propertyType = property.enumType;
|
|
204
204
|
}
|
|
205
|
-
else if (property.type === '
|
|
206
|
-
propertyType = property.
|
|
205
|
+
else if (property.type === 'map' || property.type === 'map?') {
|
|
206
|
+
propertyType = property.mapType;
|
|
207
207
|
}
|
|
208
208
|
propertyType = propertyType.replace('?', '');
|
|
209
209
|
propertyType = propertyType.replace('number', 'integer');
|
|
@@ -33,7 +33,8 @@ class RequestType extends ReqResType_1.default {
|
|
|
33
33
|
INVALID_DATETIME: '{property} must be a string in "YYYY-MM-DD hh:mi:ss" or "YYYY-MM-DDThh:mi:ss" format and a valid date and time. ({value})',
|
|
34
34
|
INVALID_BASE64: '{property} must be in Base64 format. ({value})',
|
|
35
35
|
INVALID_ENUM: '{property} must be in {enums}. ({value})',
|
|
36
|
-
|
|
36
|
+
INVALID_MAP_NUMBER: '{property} must be a valid number for a map key. ({value})',
|
|
37
|
+
INVALID_MAP_STRING: '{property} must be a valid string for a map key. ({value})',
|
|
37
38
|
};
|
|
38
39
|
this.ERROR_MESSAGE_JAPAN = {
|
|
39
40
|
REQUIRED: '{property}は必須項目です。',
|
|
@@ -51,7 +52,8 @@ class RequestType extends ReqResType_1.default {
|
|
|
51
52
|
INVALID_DATETIME: '{property}は"YYYY-MM-DD hh:mi:ss"または"YYYY-MM-DDThh:mi:ss"形式のstring型で入力してください。({value})',
|
|
52
53
|
INVALID_BASE64: '{property}はBase64形式のstring型で入力してください。({value})',
|
|
53
54
|
INVALID_ENUM: '{property}は{enums}のいずれかの値で入力してください。({value})',
|
|
54
|
-
|
|
55
|
+
INVALID_MAP_NUMBER: '{property} は有効な数値のマップキーでなければなりません。({value})',
|
|
56
|
+
INVALID_MAP_STRING: '{property} は有効な文字列のマップキーでなければなりません。({value})',
|
|
55
57
|
};
|
|
56
58
|
this.ERROR_MESSAGE = process.env.TZ === 'Asia/Tokyo' ? this.ERROR_MESSAGE_JAPAN : this.ERROR_MESSAGE_ENGLISH;
|
|
57
59
|
this.paramProperties = [];
|
|
@@ -166,7 +168,8 @@ class RequestType extends ReqResType_1.default {
|
|
|
166
168
|
"STRING_41": this.ERROR_MESSAGE.INVALID_STRING,
|
|
167
169
|
"ENUM_41": this.ERROR_MESSAGE.INVALID_ENUM,
|
|
168
170
|
"ENUM_42": this.ERROR_MESSAGE.INVALID_ENUM,
|
|
169
|
-
"
|
|
171
|
+
"MAP_011": this.ERROR_MESSAGE.INVALID_MAP_NUMBER,
|
|
172
|
+
"MAP_012": this.ERROR_MESSAGE.INVALID_MAP_STRING,
|
|
170
173
|
"NUMBER_91": this.ERROR_MESSAGE.INVALID_NUMBER,
|
|
171
174
|
"BOOL_91": this.ERROR_MESSAGE.INVALID_BOOL,
|
|
172
175
|
"BOOL_92": this.ERROR_MESSAGE.INVALID_BOOL,
|
|
@@ -222,7 +225,7 @@ class RequestType extends ReqResType_1.default {
|
|
|
222
225
|
// GET,DELETEメソッドの場合、?array=1&array=2で配列となるが、
|
|
223
226
|
// ?array=1のみで終わる場合は配列にならないため、直接配列にしている
|
|
224
227
|
// この処理で空文字やnullが入った場合の対処をここで行う
|
|
225
|
-
const itemProperty = this.properties[key].
|
|
228
|
+
const itemProperty = this.properties[key].item;
|
|
226
229
|
if (itemProperty.type.endsWith('?')) {
|
|
227
230
|
const tempValue = this.data[key];
|
|
228
231
|
this.data[key] = [];
|
|
@@ -270,15 +273,42 @@ class RequestType extends ReqResType_1.default {
|
|
|
270
273
|
if (request.method === 'GET' || request.method === 'DELETE') {
|
|
271
274
|
// GET,DELETEメソッドの場合、?array=1&array=2で配列となるが、
|
|
272
275
|
// ?array=1のみで終わる場合は配列にならないため、直接配列にしている
|
|
273
|
-
this.data[key] = [this.convertValue(this.properties[key].
|
|
276
|
+
this.data[key] = [this.convertValue(this.properties[key].item.type, value, [key, 0], true)];
|
|
274
277
|
}
|
|
275
278
|
else {
|
|
276
279
|
this.throwInputError("ARRAY_01", [key], value);
|
|
277
280
|
}
|
|
278
281
|
}
|
|
279
282
|
break;
|
|
280
|
-
case '
|
|
281
|
-
case '
|
|
283
|
+
case 'map':
|
|
284
|
+
case 'map?':
|
|
285
|
+
const mapData = {};
|
|
286
|
+
console.log('value', value[key]);
|
|
287
|
+
for (const [mapKey, mapValue] of value[key]) {
|
|
288
|
+
switch (this.properties[key].mapType) {
|
|
289
|
+
case 'number':
|
|
290
|
+
case 'number?':
|
|
291
|
+
if (this.isNumber(this.properties) === false) {
|
|
292
|
+
this.throwInputError("MAP_011", [key], value);
|
|
293
|
+
}
|
|
294
|
+
mapData[mapKey] = Number(mapValue);
|
|
295
|
+
break;
|
|
296
|
+
case 'string':
|
|
297
|
+
case 'string?':
|
|
298
|
+
switch (typeof value) {
|
|
299
|
+
case 'number':
|
|
300
|
+
mapData[mapKey] = value.toString();
|
|
301
|
+
break;
|
|
302
|
+
case 'string':
|
|
303
|
+
mapData[mapKey] = value;
|
|
304
|
+
break;
|
|
305
|
+
default:
|
|
306
|
+
this.throwInputError("MAP_012", [key], value);
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
console.log('mapData', mapData);
|
|
311
|
+
this.changeBody([key], mapData);
|
|
282
312
|
break;
|
|
283
313
|
case 'enum':
|
|
284
314
|
case 'enum?':
|
|
@@ -367,8 +397,8 @@ class RequestType extends ReqResType_1.default {
|
|
|
367
397
|
}
|
|
368
398
|
for (let i = 0; i < values.length; i++) {
|
|
369
399
|
// NULL Check
|
|
370
|
-
if (values[i] === undefined || values[i] === null || (property.
|
|
371
|
-
if (property.
|
|
400
|
+
if (values[i] === undefined || values[i] === null || (property.item.type.replace("?", "") !== "string" && values[i] === "")) {
|
|
401
|
+
if (property.item.type.endsWith('?')) {
|
|
372
402
|
this.changeBody([...keys, i], values[i] === undefined ? undefined : null);
|
|
373
403
|
continue;
|
|
374
404
|
}
|
|
@@ -376,7 +406,7 @@ class RequestType extends ReqResType_1.default {
|
|
|
376
406
|
this.throwInputError("REQUIRE_31", [...keys, i], "");
|
|
377
407
|
}
|
|
378
408
|
}
|
|
379
|
-
switch (property.
|
|
409
|
+
switch (property.item.type) {
|
|
380
410
|
case 'object':
|
|
381
411
|
case 'object?':
|
|
382
412
|
this.setObject([...keys, i], values[i]);
|
|
@@ -808,12 +838,12 @@ class RequestType extends ReqResType_1.default {
|
|
|
808
838
|
}
|
|
809
839
|
const space = ' '.repeat(tabCount);
|
|
810
840
|
let ymlString = `${space}items:\n`;
|
|
811
|
-
ymlString += `${space} type: ${this.replaceFromPropertyTypeToSwagger(arrayProperty.
|
|
812
|
-
if (((_a = arrayProperty.
|
|
841
|
+
ymlString += `${space} type: ${this.replaceFromPropertyTypeToSwagger(arrayProperty.item)}\n`;
|
|
842
|
+
if (((_a = arrayProperty.item.description) !== null && _a !== void 0 ? _a : '') !== '') {
|
|
813
843
|
const descJoin = `\n${space} `;
|
|
814
|
-
ymlString += `${space} description: |${descJoin}${((_b = arrayProperty.
|
|
844
|
+
ymlString += `${space} description: |${descJoin}${((_b = arrayProperty.item.description) !== null && _b !== void 0 ? _b : '').replaceAll('\n', descJoin)}\n`;
|
|
815
845
|
}
|
|
816
|
-
switch (arrayProperty.
|
|
846
|
+
switch (arrayProperty.item.type) {
|
|
817
847
|
case 'object':
|
|
818
848
|
case 'object?':
|
|
819
849
|
ymlString += this.makeSwaggerProperyFromObject([...keys, 0], tabCount + 1);
|
|
@@ -109,7 +109,7 @@ class ResponseType extends ReqResType_1.default {
|
|
|
109
109
|
}
|
|
110
110
|
let resData = [];
|
|
111
111
|
for (let i = 0; i < data.length; i++) {
|
|
112
|
-
switch (arrayProperty.
|
|
112
|
+
switch (arrayProperty.item.type) {
|
|
113
113
|
case 'object':
|
|
114
114
|
case 'object?':
|
|
115
115
|
resData.push(this.getObject([...keys, i]));
|
|
@@ -256,8 +256,8 @@ class ResponseType extends ReqResType_1.default {
|
|
|
256
256
|
return value;
|
|
257
257
|
}
|
|
258
258
|
return undefined;
|
|
259
|
-
case '
|
|
260
|
-
case '
|
|
259
|
+
case 'map':
|
|
260
|
+
case 'map?':
|
|
261
261
|
// if (Object.keys(property.enums).includes(value)) {
|
|
262
262
|
// return value;
|
|
263
263
|
// }
|
|
@@ -307,8 +307,8 @@ class ResponseType extends ReqResType_1.default {
|
|
|
307
307
|
case 'array?':
|
|
308
308
|
ymlString += this.makeSwaggerPropertyFromArray([key], tabCount + 1);
|
|
309
309
|
break;
|
|
310
|
-
case '
|
|
311
|
-
case '
|
|
310
|
+
case 'map':
|
|
311
|
+
case 'map?':
|
|
312
312
|
ymlString += this.makeSwaggerPropertyFromDictionary([key], tabCount + 1);
|
|
313
313
|
break;
|
|
314
314
|
}
|
|
@@ -347,8 +347,8 @@ class ResponseType extends ReqResType_1.default {
|
|
|
347
347
|
case 'array?':
|
|
348
348
|
ymlString += this.makeSwaggerPropertyFromArray([...keys, key], tabCount + 2);
|
|
349
349
|
break;
|
|
350
|
-
case '
|
|
351
|
-
case '
|
|
350
|
+
case 'map':
|
|
351
|
+
case 'map?':
|
|
352
352
|
ymlString += this.makeSwaggerPropertyFromDictionary([...keys, key], tabCount + 2);
|
|
353
353
|
break;
|
|
354
354
|
}
|
|
@@ -368,12 +368,12 @@ class ResponseType extends ReqResType_1.default {
|
|
|
368
368
|
}
|
|
369
369
|
const space = ' '.repeat(tabCount);
|
|
370
370
|
let ymlString = `${space}items:\n`;
|
|
371
|
-
ymlString += `${space} type: ${this.replaceFromPropertyTypeToSwagger(arrayProperty.
|
|
372
|
-
if (arrayProperty.
|
|
371
|
+
ymlString += `${space} type: ${this.replaceFromPropertyTypeToSwagger(arrayProperty.item)}\n`;
|
|
372
|
+
if (arrayProperty.item.description !== undefined) {
|
|
373
373
|
const joinSpace = `\n${space} `;
|
|
374
|
-
ymlString += `${space} description: |${joinSpace}${arrayProperty.
|
|
374
|
+
ymlString += `${space} description: |${joinSpace}${arrayProperty.item.description.replaceAll("\n", joinSpace)}\n`;
|
|
375
375
|
}
|
|
376
|
-
switch (arrayProperty.
|
|
376
|
+
switch (arrayProperty.item.type) {
|
|
377
377
|
case 'object':
|
|
378
378
|
case 'object?':
|
|
379
379
|
ymlString += this.makeSwaggerProperyFromObject([...keys, 0], tabCount + 1);
|
|
@@ -382,8 +382,8 @@ class ResponseType extends ReqResType_1.default {
|
|
|
382
382
|
case 'array?':
|
|
383
383
|
ymlString += this.makeSwaggerPropertyFromArray([...keys, 0], tabCount + 1);
|
|
384
384
|
break;
|
|
385
|
-
case '
|
|
386
|
-
case '
|
|
385
|
+
case 'map':
|
|
386
|
+
case 'map?':
|
|
387
387
|
ymlString += this.makeSwaggerPropertyFromDictionary([...keys, 0], tabCount + 1);
|
|
388
388
|
break;
|
|
389
389
|
}
|
package/package.json
CHANGED
|
@@ -16,12 +16,12 @@ export type ObjectType = {
|
|
|
16
16
|
export type ArrayType = {
|
|
17
17
|
type: 'array' | 'array?';
|
|
18
18
|
description?: string;
|
|
19
|
-
|
|
19
|
+
item: PropertyType;
|
|
20
20
|
};
|
|
21
|
-
export type
|
|
22
|
-
type: '
|
|
21
|
+
export type MapType = {
|
|
22
|
+
type: 'map' | 'map?';
|
|
23
23
|
description?: string;
|
|
24
|
-
|
|
24
|
+
mapType: 'string' | 'number' | 'string?' | 'number?';
|
|
25
25
|
};
|
|
26
26
|
export type EnumType = {
|
|
27
27
|
type: 'enum' | 'enum?';
|
|
@@ -30,7 +30,7 @@ export type EnumType = {
|
|
|
30
30
|
enums: {[key: string | number]: string};
|
|
31
31
|
};
|
|
32
32
|
|
|
33
|
-
export type PropertyType = PrimitiveType | ObjectType | ArrayType | EnumType |
|
|
33
|
+
export type PropertyType = PrimitiveType | ObjectType | ArrayType | EnumType | MapType;
|
|
34
34
|
|
|
35
35
|
export default class ReqResType {
|
|
36
36
|
|
|
@@ -81,7 +81,7 @@ export default class ReqResType {
|
|
|
81
81
|
const key = keys[i];
|
|
82
82
|
if (typeof key === 'number') {
|
|
83
83
|
if (property.type === 'array' || property.type === 'array?') {
|
|
84
|
-
property = property.
|
|
84
|
+
property = property.item;
|
|
85
85
|
continue;
|
|
86
86
|
} else {
|
|
87
87
|
throw new Error(`getPropertyでnumber型のINPUTにも関わらず、array以外のtypeの場合のエラー\nキー一覧:${keys.join(',')} エラーキー:${key}`);
|
|
@@ -94,7 +94,7 @@ export default class ReqResType {
|
|
|
94
94
|
if (typeof key !== 'number') {
|
|
95
95
|
throw new Error(`getPropertyでnumber型のINPUTで、array以外の場合はエラー\nキー一覧:${keys.join(',')} エラーキー:${key}`);
|
|
96
96
|
}
|
|
97
|
-
property = property.
|
|
97
|
+
property = property.item;
|
|
98
98
|
continue;
|
|
99
99
|
case 'object':
|
|
100
100
|
case 'object?':
|
|
@@ -252,8 +252,8 @@ export default class ReqResType {
|
|
|
252
252
|
let propertyType: string = property.type;
|
|
253
253
|
if (property.type === 'enum' || property.type === 'enum?') {
|
|
254
254
|
propertyType = property.enumType;
|
|
255
|
-
} else if (property.type === '
|
|
256
|
-
propertyType = property.
|
|
255
|
+
} else if (property.type === 'map' || property.type === 'map?') {
|
|
256
|
+
propertyType = property.mapType;
|
|
257
257
|
}
|
|
258
258
|
propertyType = propertyType.replace('?', '');
|
|
259
259
|
propertyType = propertyType.replace('number', 'integer');
|
|
@@ -21,7 +21,8 @@ export interface ErrorMessageType {
|
|
|
21
21
|
INVALID_DATETIME: string;
|
|
22
22
|
INVALID_BASE64: string;
|
|
23
23
|
INVALID_ENUM: string;
|
|
24
|
-
|
|
24
|
+
INVALID_MAP_NUMBER: string;
|
|
25
|
+
INVALID_MAP_STRING: string;
|
|
25
26
|
}
|
|
26
27
|
|
|
27
28
|
export class RequestType extends ReqResType {
|
|
@@ -48,7 +49,8 @@ export class RequestType extends ReqResType {
|
|
|
48
49
|
INVALID_DATETIME: '{property} must be a string in "YYYY-MM-DD hh:mi:ss" or "YYYY-MM-DDThh:mi:ss" format and a valid date and time. ({value})',
|
|
49
50
|
INVALID_BASE64: '{property} must be in Base64 format. ({value})',
|
|
50
51
|
INVALID_ENUM: '{property} must be in {enums}. ({value})',
|
|
51
|
-
|
|
52
|
+
INVALID_MAP_NUMBER: '{property} must be a valid number for a map key. ({value})',
|
|
53
|
+
INVALID_MAP_STRING: '{property} must be a valid string for a map key. ({value})',
|
|
52
54
|
}
|
|
53
55
|
private readonly ERROR_MESSAGE_JAPAN: ErrorMessageType = {
|
|
54
56
|
REQUIRED: '{property}は必須項目です。',
|
|
@@ -66,7 +68,8 @@ export class RequestType extends ReqResType {
|
|
|
66
68
|
INVALID_DATETIME: '{property}は"YYYY-MM-DD hh:mi:ss"または"YYYY-MM-DDThh:mi:ss"形式のstring型で入力してください。({value})',
|
|
67
69
|
INVALID_BASE64: '{property}はBase64形式のstring型で入力してください。({value})',
|
|
68
70
|
INVALID_ENUM: '{property}は{enums}のいずれかの値で入力してください。({value})',
|
|
69
|
-
|
|
71
|
+
INVALID_MAP_NUMBER: '{property} は有効な数値のマップキーでなければなりません。({value})',
|
|
72
|
+
INVALID_MAP_STRING: '{property} は有効な文字列のマップキーでなければなりません。({value})',
|
|
70
73
|
}
|
|
71
74
|
protected readonly ERROR_MESSAGE: ErrorMessageType = process.env.TZ === 'Asia/Tokyo' ? this.ERROR_MESSAGE_JAPAN : this.ERROR_MESSAGE_ENGLISH;
|
|
72
75
|
|
|
@@ -141,7 +144,7 @@ export class RequestType extends ReqResType {
|
|
|
141
144
|
"TIME_21" | "DATETIME_21" | "DATETIME_22" | "HTTPS_21" | "BASE64_21" |
|
|
142
145
|
"REQUIRE_31" |
|
|
143
146
|
"ENUM_41" | "ENUM_42" | "NUMBER_41" | "STRING_41" |
|
|
144
|
-
"
|
|
147
|
+
"MAP_011" | "MAP_012" |
|
|
145
148
|
"NUMBER_91" | "BOOL_91" | "BOOL_92" | "BOOL_93" | "STRING_91" | "UUID_91" | "MAIL_91" | "DATE_91" | "DATE_92" |
|
|
146
149
|
"TIME_91" | "DATETIME_91" | "DATETIME_92" | "HTTPS_91" | "BASE64_91"
|
|
147
150
|
, keys: Array<string | number>, value: any): never {
|
|
@@ -174,7 +177,8 @@ export class RequestType extends ReqResType {
|
|
|
174
177
|
"STRING_41": this.ERROR_MESSAGE.INVALID_STRING,
|
|
175
178
|
"ENUM_41": this.ERROR_MESSAGE.INVALID_ENUM,
|
|
176
179
|
"ENUM_42": this.ERROR_MESSAGE.INVALID_ENUM,
|
|
177
|
-
"
|
|
180
|
+
"MAP_011": this.ERROR_MESSAGE.INVALID_MAP_NUMBER,
|
|
181
|
+
"MAP_012": this.ERROR_MESSAGE.INVALID_MAP_STRING,
|
|
178
182
|
"NUMBER_91": this.ERROR_MESSAGE.INVALID_NUMBER,
|
|
179
183
|
"BOOL_91": this.ERROR_MESSAGE.INVALID_BOOL,
|
|
180
184
|
"BOOL_92": this.ERROR_MESSAGE.INVALID_BOOL,
|
|
@@ -236,7 +240,7 @@ export class RequestType extends ReqResType {
|
|
|
236
240
|
// GET,DELETEメソッドの場合、?array=1&array=2で配列となるが、
|
|
237
241
|
// ?array=1のみで終わる場合は配列にならないため、直接配列にしている
|
|
238
242
|
// この処理で空文字やnullが入った場合の対処をここで行う
|
|
239
|
-
const itemProperty = this.properties[key].
|
|
243
|
+
const itemProperty = this.properties[key].item;
|
|
240
244
|
if (itemProperty.type.endsWith('?')) {
|
|
241
245
|
const tempValue = this.data[key];
|
|
242
246
|
this.data[key] = [];
|
|
@@ -279,14 +283,42 @@ export class RequestType extends ReqResType {
|
|
|
279
283
|
if (request.method === 'GET' || request.method === 'DELETE') {
|
|
280
284
|
// GET,DELETEメソッドの場合、?array=1&array=2で配列となるが、
|
|
281
285
|
// ?array=1のみで終わる場合は配列にならないため、直接配列にしている
|
|
282
|
-
this.data[key] = [this.convertValue(this.properties[key].
|
|
286
|
+
this.data[key] = [this.convertValue(this.properties[key].item.type, value, [key, 0], true)];
|
|
283
287
|
} else {
|
|
284
288
|
this.throwInputError("ARRAY_01", [key], value);
|
|
285
289
|
}
|
|
286
290
|
}
|
|
287
291
|
break;
|
|
288
|
-
case '
|
|
289
|
-
case '
|
|
292
|
+
case 'map':
|
|
293
|
+
case 'map?':
|
|
294
|
+
const mapData: {[key: string]: string | number} = {};
|
|
295
|
+
console.log('value', value[key]);
|
|
296
|
+
for (const [mapKey, mapValue] of value[key]) {
|
|
297
|
+
switch (this.properties[key].mapType) {
|
|
298
|
+
case 'number':
|
|
299
|
+
case 'number?':
|
|
300
|
+
if (this.isNumber(this.properties) === false) {
|
|
301
|
+
this.throwInputError("MAP_011", [key], value);
|
|
302
|
+
}
|
|
303
|
+
mapData[mapKey] = Number(mapValue);
|
|
304
|
+
break;
|
|
305
|
+
case 'string':
|
|
306
|
+
case 'string?':
|
|
307
|
+
switch (typeof value) {
|
|
308
|
+
case 'number':
|
|
309
|
+
mapData[mapKey] = value.toString();
|
|
310
|
+
break;
|
|
311
|
+
case 'string':
|
|
312
|
+
mapData[mapKey] = value;
|
|
313
|
+
break;
|
|
314
|
+
default:
|
|
315
|
+
this.throwInputError("MAP_012", [key], value);
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
console.log('mapData', mapData);
|
|
321
|
+
this.changeBody([key], mapData);
|
|
290
322
|
break;
|
|
291
323
|
case 'enum':
|
|
292
324
|
case 'enum?':
|
|
@@ -383,8 +415,8 @@ export class RequestType extends ReqResType {
|
|
|
383
415
|
for (let i = 0;i < values.length; i++) {
|
|
384
416
|
|
|
385
417
|
// NULL Check
|
|
386
|
-
if (values[i] === undefined || values[i] === null || (property.
|
|
387
|
-
if (property.
|
|
418
|
+
if (values[i] === undefined || values[i] === null || (property.item.type.replace("?", "") !== "string" && values[i] === "")) {
|
|
419
|
+
if (property.item.type.endsWith('?')) {
|
|
388
420
|
this.changeBody([...keys, i], values[i] === undefined ? undefined : null);
|
|
389
421
|
continue;
|
|
390
422
|
} else {
|
|
@@ -392,7 +424,7 @@ export class RequestType extends ReqResType {
|
|
|
392
424
|
}
|
|
393
425
|
}
|
|
394
426
|
|
|
395
|
-
switch (property.
|
|
427
|
+
switch (property.item.type) {
|
|
396
428
|
case 'object':
|
|
397
429
|
case 'object?':
|
|
398
430
|
this.setObject([...keys, i], values[i]);
|
|
@@ -859,14 +891,14 @@ export class RequestType extends ReqResType {
|
|
|
859
891
|
const space = ' '.repeat(tabCount);
|
|
860
892
|
|
|
861
893
|
let ymlString = `${space}items:\n`;
|
|
862
|
-
ymlString += `${space} type: ${this.replaceFromPropertyTypeToSwagger(arrayProperty.
|
|
863
|
-
if ((arrayProperty.
|
|
894
|
+
ymlString += `${space} type: ${this.replaceFromPropertyTypeToSwagger(arrayProperty.item)}\n`;
|
|
895
|
+
if ((arrayProperty.item.description ?? '') !== '') {
|
|
864
896
|
const descJoin = `\n${space} `;
|
|
865
|
-
ymlString += `${space} description: |${descJoin}${(arrayProperty.
|
|
897
|
+
ymlString += `${space} description: |${descJoin}${(arrayProperty.item.description ?? '').replaceAll('\n', descJoin)}\n`;
|
|
866
898
|
}
|
|
867
899
|
|
|
868
900
|
|
|
869
|
-
switch (arrayProperty.
|
|
901
|
+
switch (arrayProperty.item.type) {
|
|
870
902
|
case 'object':
|
|
871
903
|
case 'object?':
|
|
872
904
|
ymlString += this.makeSwaggerProperyFromObject([...keys, 0], tabCount + 1);
|
|
@@ -118,7 +118,7 @@ export class ResponseType extends ReqResType {
|
|
|
118
118
|
|
|
119
119
|
let resData: Array<any> = [];
|
|
120
120
|
for (let i = 0;i < data.length; i++) {
|
|
121
|
-
switch (arrayProperty.
|
|
121
|
+
switch (arrayProperty.item.type) {
|
|
122
122
|
case 'object':
|
|
123
123
|
case 'object?':
|
|
124
124
|
resData.push(this.getObject([...keys, i]));
|
|
@@ -278,8 +278,8 @@ export class ResponseType extends ReqResType {
|
|
|
278
278
|
return value;
|
|
279
279
|
}
|
|
280
280
|
return undefined;
|
|
281
|
-
case '
|
|
282
|
-
case '
|
|
281
|
+
case 'map':
|
|
282
|
+
case 'map?':
|
|
283
283
|
// if (Object.keys(property.enums).includes(value)) {
|
|
284
284
|
// return value;
|
|
285
285
|
// }
|
|
@@ -336,8 +336,8 @@ export class ResponseType extends ReqResType {
|
|
|
336
336
|
case 'array?':
|
|
337
337
|
ymlString += this.makeSwaggerPropertyFromArray([key], tabCount + 1);
|
|
338
338
|
break;
|
|
339
|
-
case '
|
|
340
|
-
case '
|
|
339
|
+
case 'map':
|
|
340
|
+
case 'map?':
|
|
341
341
|
ymlString += this.makeSwaggerPropertyFromDictionary([key], tabCount + 1);
|
|
342
342
|
break;
|
|
343
343
|
}
|
|
@@ -381,8 +381,8 @@ export class ResponseType extends ReqResType {
|
|
|
381
381
|
case 'array?':
|
|
382
382
|
ymlString += this.makeSwaggerPropertyFromArray([...keys, key], tabCount + 2);
|
|
383
383
|
break;
|
|
384
|
-
case '
|
|
385
|
-
case '
|
|
384
|
+
case 'map':
|
|
385
|
+
case 'map?':
|
|
386
386
|
ymlString += this.makeSwaggerPropertyFromDictionary([...keys, key], tabCount + 2);
|
|
387
387
|
break;
|
|
388
388
|
}
|
|
@@ -406,12 +406,12 @@ export class ResponseType extends ReqResType {
|
|
|
406
406
|
|
|
407
407
|
const space = ' '.repeat(tabCount);
|
|
408
408
|
let ymlString = `${space}items:\n`;
|
|
409
|
-
ymlString += `${space} type: ${this.replaceFromPropertyTypeToSwagger(arrayProperty.
|
|
410
|
-
if (arrayProperty.
|
|
409
|
+
ymlString += `${space} type: ${this.replaceFromPropertyTypeToSwagger(arrayProperty.item)}\n`;
|
|
410
|
+
if (arrayProperty.item.description !== undefined) {
|
|
411
411
|
const joinSpace = `\n${space} `;
|
|
412
|
-
ymlString += `${space} description: |${joinSpace}${arrayProperty.
|
|
412
|
+
ymlString += `${space} description: |${joinSpace}${arrayProperty.item.description.replaceAll("\n", joinSpace)}\n`;
|
|
413
413
|
}
|
|
414
|
-
switch (arrayProperty.
|
|
414
|
+
switch (arrayProperty.item.type) {
|
|
415
415
|
case 'object':
|
|
416
416
|
case 'object?':
|
|
417
417
|
ymlString += this.makeSwaggerProperyFromObject([...keys, 0], tabCount + 1);
|
|
@@ -420,8 +420,8 @@ export class ResponseType extends ReqResType {
|
|
|
420
420
|
case 'array?':
|
|
421
421
|
ymlString += this.makeSwaggerPropertyFromArray([...keys, 0], tabCount + 1);
|
|
422
422
|
break;
|
|
423
|
-
case '
|
|
424
|
-
case '
|
|
423
|
+
case 'map':
|
|
424
|
+
case 'map?':
|
|
425
425
|
ymlString += this.makeSwaggerPropertyFromDictionary([...keys, 0], tabCount + 1);
|
|
426
426
|
break;
|
|
427
427
|
}
|