pg-mvc-service 2.0.51 → 2.0.52
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 +3 -0
- package/dist/reqestResponse/RequestType.js +62 -2
- package/dist/reqestResponse/ResponseType.js +32 -0
- package/package.json +1 -1
- package/src/reqestResponse/ReqResType.ts +13 -4
- package/src/reqestResponse/RequestType.ts +74 -3
- package/src/reqestResponse/ResponseType.ts +36 -1
|
@@ -125,6 +125,9 @@ class ReqResType {
|
|
|
125
125
|
if (property.type === 'enum' || property.type === 'enum?') {
|
|
126
126
|
propertyType = property.enumType;
|
|
127
127
|
}
|
|
128
|
+
else if (property.type === 'dictionary' || property.type === 'dictionary?') {
|
|
129
|
+
propertyType = property.dictionaryType;
|
|
130
|
+
}
|
|
128
131
|
propertyType = propertyType.replace('?', '');
|
|
129
132
|
propertyType = propertyType.replace('number', 'integer');
|
|
130
133
|
propertyType = propertyType.replace(/datetime|date|time|uuid|mail|https|base64/g, 'string');
|
|
@@ -32,7 +32,8 @@ class RequestType extends ReqResType_1.default {
|
|
|
32
32
|
INVALID_TIME: '{property} must be a string in "hh:mi" format and a valid time. ({value})',
|
|
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
|
-
INVALID_ENUM: '{property} must be in {enums}. ({value})'
|
|
35
|
+
INVALID_ENUM: '{property} must be in {enums}. ({value})',
|
|
36
|
+
INVALID_DICTIONAY: '{property} must be a valid dictionary key. ({value})',
|
|
36
37
|
};
|
|
37
38
|
this.ERROR_MESSAGE_JAPAN = {
|
|
38
39
|
REQUIRED: '{property}は必須項目です。',
|
|
@@ -49,10 +50,32 @@ class RequestType extends ReqResType_1.default {
|
|
|
49
50
|
INVALID_TIME: '{property}は"hh:mi"形式のstring型で入力してください。({value})',
|
|
50
51
|
INVALID_DATETIME: '{property}は"YYYY-MM-DD hh:mi:ss"または"YYYY-MM-DDThh:mi:ss"形式のstring型で入力してください。({value})',
|
|
51
52
|
INVALID_BASE64: '{property}はBase64形式のstring型で入力してください。({value})',
|
|
52
|
-
INVALID_ENUM: '{property}は{enums}のいずれかの値で入力してください。({value})'
|
|
53
|
+
INVALID_ENUM: '{property}は{enums}のいずれかの値で入力してください。({value})',
|
|
54
|
+
INVALID_DICTIONAY: '{property}は有効なKey-Value形式で入力してください。({value})'
|
|
53
55
|
};
|
|
54
56
|
this.ERROR_MESSAGE = process.env.TZ === 'Asia/Tokyo' ? this.ERROR_MESSAGE_JAPAN : this.ERROR_MESSAGE_ENGLISH;
|
|
55
57
|
this.paramProperties = [];
|
|
58
|
+
// private makeSwaggerPropertyFromDictionary(keys: Array<string | number>, tabCount: number): string {
|
|
59
|
+
// const property = this.getProperty(keys).properties;
|
|
60
|
+
// const space = ' '.repeat(tabCount);
|
|
61
|
+
// let ymlString = `${space}items:\n`;
|
|
62
|
+
// ymlString += `${space} type: ${this.replaceFromPropertyTypeToSwagger(property)}\n`;
|
|
63
|
+
// if ((property.description ?? '') !== '') {
|
|
64
|
+
// const descJoin = `\n${space} `;
|
|
65
|
+
// ymlString += `${space} description: |${descJoin}${property.description.replaceAll('\n', descJoin)}\n`;
|
|
66
|
+
// }
|
|
67
|
+
// switch (property.type) {
|
|
68
|
+
// case 'object':
|
|
69
|
+
// case 'object?':
|
|
70
|
+
// ymlString += this.makeSwaggerProperyFromObject([...keys, 0], tabCount + 1);
|
|
71
|
+
// break;
|
|
72
|
+
// case 'array':
|
|
73
|
+
// case 'array?':
|
|
74
|
+
// ymlString += this.makeSwaggerPropertyFromArray([...keys, 0], tabCount + 1);
|
|
75
|
+
// break;
|
|
76
|
+
// }
|
|
77
|
+
// return ymlString;
|
|
78
|
+
// }
|
|
56
79
|
}
|
|
57
80
|
get paramPath() {
|
|
58
81
|
return this.paramProperties.map(property => `/{${property.key}}`).join("");
|
|
@@ -142,6 +165,7 @@ class RequestType extends ReqResType_1.default {
|
|
|
142
165
|
"STRING_41": this.ERROR_MESSAGE.INVALID_STRING,
|
|
143
166
|
"ENUM_41": this.ERROR_MESSAGE.INVALID_ENUM,
|
|
144
167
|
"ENUM_42": this.ERROR_MESSAGE.INVALID_ENUM,
|
|
168
|
+
"DICTIONARY_51": this.ERROR_MESSAGE.INVALID_DICTIONAY,
|
|
145
169
|
"NUMBER_91": this.ERROR_MESSAGE.INVALID_NUMBER,
|
|
146
170
|
"BOOL_91": this.ERROR_MESSAGE.INVALID_BOOL,
|
|
147
171
|
"BOOL_92": this.ERROR_MESSAGE.INVALID_BOOL,
|
|
@@ -252,6 +276,9 @@ class RequestType extends ReqResType_1.default {
|
|
|
252
276
|
}
|
|
253
277
|
}
|
|
254
278
|
break;
|
|
279
|
+
case 'dictionary':
|
|
280
|
+
case 'dictionary?':
|
|
281
|
+
break;
|
|
255
282
|
case 'enum':
|
|
256
283
|
case 'enum?':
|
|
257
284
|
this.setEnum([key], value);
|
|
@@ -363,6 +390,39 @@ class RequestType extends ReqResType_1.default {
|
|
|
363
390
|
}
|
|
364
391
|
}
|
|
365
392
|
}
|
|
393
|
+
setDictionary(keys, values) {
|
|
394
|
+
// const property = this.getProperty(keys);
|
|
395
|
+
// for (let i = 0;i < values.length; i++) {
|
|
396
|
+
// // NULL Check
|
|
397
|
+
// if (values[i] === undefined || values[i] === null || (property.properties.type.replace("?", "") !== "string" && values[i] === "")) {
|
|
398
|
+
// if (property.properties.type.endsWith('?')) {
|
|
399
|
+
// this.changeBody([...keys, i], values[i] === undefined ? undefined : null);
|
|
400
|
+
// continue;
|
|
401
|
+
// } else {
|
|
402
|
+
// this.throwInputError("DICTIONARY_51", [...keys, i], "");
|
|
403
|
+
// }
|
|
404
|
+
// }
|
|
405
|
+
// switch (property.properties.type) {
|
|
406
|
+
// case 'object':
|
|
407
|
+
// case 'object?':
|
|
408
|
+
// this.setObject([...keys, i], values[i]);
|
|
409
|
+
// break;
|
|
410
|
+
// case 'array':
|
|
411
|
+
// case 'array?':
|
|
412
|
+
// this.setArray([...keys, i], values[i]);
|
|
413
|
+
// break;
|
|
414
|
+
// case 'enum':
|
|
415
|
+
// case 'enum?':
|
|
416
|
+
// for (const value of values) {
|
|
417
|
+
// this.setEnum([...keys, i], value);
|
|
418
|
+
// }
|
|
419
|
+
// break;
|
|
420
|
+
// default:
|
|
421
|
+
// this.convertInput([...keys, i], values[i]);
|
|
422
|
+
// break;
|
|
423
|
+
// }
|
|
424
|
+
// }
|
|
425
|
+
}
|
|
366
426
|
/**
|
|
367
427
|
* Retrieve the property definition corresponding to the specified key path.
|
|
368
428
|
* 指定されたキーパスに対応するプロパティ定義を取得します。
|
|
@@ -269,6 +269,12 @@ class ResponseType extends ReqResType_1.default {
|
|
|
269
269
|
return value;
|
|
270
270
|
}
|
|
271
271
|
return undefined;
|
|
272
|
+
case 'dictionary':
|
|
273
|
+
case 'dictionary?':
|
|
274
|
+
// if (Object.keys(property.enums).includes(value)) {
|
|
275
|
+
// return value;
|
|
276
|
+
// }
|
|
277
|
+
return undefined;
|
|
272
278
|
default:
|
|
273
279
|
return undefined;
|
|
274
280
|
}
|
|
@@ -314,6 +320,10 @@ class ResponseType extends ReqResType_1.default {
|
|
|
314
320
|
case 'array?':
|
|
315
321
|
ymlString += this.makeSwaggerPropertyFromArray([key], tabCount + 1);
|
|
316
322
|
break;
|
|
323
|
+
case 'dictionary':
|
|
324
|
+
case 'dictionary?':
|
|
325
|
+
ymlString += this.makeSwaggerPropertyFromDictionary([key], tabCount + 1);
|
|
326
|
+
break;
|
|
317
327
|
}
|
|
318
328
|
}
|
|
319
329
|
return ymlString;
|
|
@@ -347,6 +357,10 @@ class ResponseType extends ReqResType_1.default {
|
|
|
347
357
|
case 'array?':
|
|
348
358
|
ymlString += this.makeSwaggerPropertyFromArray([...keys, key], tabCount + 2);
|
|
349
359
|
break;
|
|
360
|
+
case 'dictionary':
|
|
361
|
+
case 'dictionary?':
|
|
362
|
+
ymlString += this.makeSwaggerPropertyFromDictionary([...keys, key], tabCount + 2);
|
|
363
|
+
break;
|
|
350
364
|
}
|
|
351
365
|
}
|
|
352
366
|
return ymlString;
|
|
@@ -375,8 +389,26 @@ class ResponseType extends ReqResType_1.default {
|
|
|
375
389
|
case 'array?':
|
|
376
390
|
ymlString += this.makeSwaggerPropertyFromArray([...keys, 0], tabCount + 1);
|
|
377
391
|
break;
|
|
392
|
+
case 'dictionary':
|
|
393
|
+
case 'dictionary?':
|
|
394
|
+
ymlString += this.makeSwaggerPropertyFromDictionary([...keys, 0], tabCount + 1);
|
|
395
|
+
break;
|
|
378
396
|
}
|
|
379
397
|
return ymlString;
|
|
380
398
|
}
|
|
399
|
+
/**
|
|
400
|
+
* Generates Swagger properties from array type properties
|
|
401
|
+
* 配列型のプロパティからSwaggerのプロパティを生成
|
|
402
|
+
* @param {Array.<string|number>} keys - Path to the properties, プロパティへのパス
|
|
403
|
+
* @returns {string} Swagger format property definition, Swagger形式のプロパティ定義
|
|
404
|
+
*/
|
|
405
|
+
makeSwaggerPropertyFromDictionary(keys, tabCount) {
|
|
406
|
+
const property = this.getProperty(keys);
|
|
407
|
+
const space = ' '.repeat(tabCount);
|
|
408
|
+
let ymlString = `${space}properties:\n`;
|
|
409
|
+
ymlString += `${space} key:\n`;
|
|
410
|
+
ymlString += `${space} type: ${this.replaceFromPropertyTypeToSwagger(property)}\n`;
|
|
411
|
+
return ymlString;
|
|
412
|
+
}
|
|
381
413
|
}
|
|
382
414
|
exports.ResponseType = ResponseType;
|
package/package.json
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
|
+
type PrimitiveKeyType =
|
|
2
|
+
'string' | 'number' | 'boolean' | 'date' | 'datetime' | 'time' | 'uuid' | 'mail' | 'https' | 'base64' |
|
|
3
|
+
'string?' | 'number?' | 'boolean?' | 'date?' | 'datetime?' | 'time?' | 'uuid?' | 'mail?' | 'https?' | 'base64?';
|
|
4
|
+
|
|
1
5
|
export type PrimitiveType = {
|
|
2
|
-
type:
|
|
3
|
-
'string' | 'number' | 'boolean' | 'date' | 'datetime' | 'time' | 'uuid' | 'mail' | 'https' | 'base64' |
|
|
4
|
-
'string?' | 'number?' | 'boolean?' | 'date?' | 'datetime?' | 'time?' | 'uuid?' | 'mail?' | 'https?' | 'base64?';
|
|
6
|
+
type: PrimitiveKeyType;
|
|
5
7
|
description?: string;
|
|
6
8
|
};
|
|
7
9
|
export type ObjectType = {
|
|
@@ -16,6 +18,11 @@ export type ArrayType = {
|
|
|
16
18
|
description?: string;
|
|
17
19
|
properties: PropertyType;
|
|
18
20
|
};
|
|
21
|
+
export type DictionaryType = {
|
|
22
|
+
type: 'dictionary' | 'dictionary?';
|
|
23
|
+
description?: string;
|
|
24
|
+
dictionaryType: 'string' | 'number' | 'string?' | 'number?';
|
|
25
|
+
};
|
|
19
26
|
export type EnumType = {
|
|
20
27
|
type: 'enum' | 'enum?';
|
|
21
28
|
description?: string;
|
|
@@ -23,7 +30,7 @@ export type EnumType = {
|
|
|
23
30
|
enums: {[key: string | number]: string};
|
|
24
31
|
};
|
|
25
32
|
|
|
26
|
-
export type PropertyType = PrimitiveType | ObjectType | ArrayType | EnumType;
|
|
33
|
+
export type PropertyType = PrimitiveType | ObjectType | ArrayType | EnumType | DictionaryType;
|
|
27
34
|
|
|
28
35
|
export default class ReqResType {
|
|
29
36
|
|
|
@@ -161,6 +168,8 @@ export default class ReqResType {
|
|
|
161
168
|
let propertyType: string = property.type;
|
|
162
169
|
if (property.type === 'enum' || property.type === 'enum?') {
|
|
163
170
|
propertyType = property.enumType;
|
|
171
|
+
} else if (property.type === 'dictionary' || property.type === 'dictionary?') {
|
|
172
|
+
propertyType = property.dictionaryType;
|
|
164
173
|
}
|
|
165
174
|
propertyType = propertyType.replace('?', '');
|
|
166
175
|
propertyType = propertyType.replace('number', 'integer');
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Request } from 'express';
|
|
2
|
-
import ReqResType, { EnumType, PrimitiveType, PropertyType } from "./ReqResType";
|
|
2
|
+
import ReqResType, { ArrayType, EnumType, PrimitiveType, PropertyType } from "./ReqResType";
|
|
3
3
|
import { InputErrorException } from '../exceptions/Exception';
|
|
4
4
|
import StringUtil from '../Utils/StringUtil';
|
|
5
5
|
import { ValidateStringUtil } from 'type-utils-n-daira';
|
|
@@ -21,6 +21,7 @@ export interface ErrorMessageType {
|
|
|
21
21
|
INVALID_DATETIME: string;
|
|
22
22
|
INVALID_BASE64: string;
|
|
23
23
|
INVALID_ENUM: string;
|
|
24
|
+
INVALID_DICTIONAY: string;
|
|
24
25
|
}
|
|
25
26
|
|
|
26
27
|
export class RequestType extends ReqResType {
|
|
@@ -46,7 +47,8 @@ export class RequestType extends ReqResType {
|
|
|
46
47
|
INVALID_TIME: '{property} must be a string in "hh:mi" format and a valid time. ({value})',
|
|
47
48
|
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})',
|
|
48
49
|
INVALID_BASE64: '{property} must be in Base64 format. ({value})',
|
|
49
|
-
INVALID_ENUM: '{property} must be in {enums}. ({value})'
|
|
50
|
+
INVALID_ENUM: '{property} must be in {enums}. ({value})',
|
|
51
|
+
INVALID_DICTIONAY: '{property} must be a valid dictionary key. ({value})',
|
|
50
52
|
}
|
|
51
53
|
private readonly ERROR_MESSAGE_JAPAN: ErrorMessageType = {
|
|
52
54
|
REQUIRED: '{property}は必須項目です。',
|
|
@@ -63,7 +65,8 @@ export class RequestType extends ReqResType {
|
|
|
63
65
|
INVALID_TIME: '{property}は"hh:mi"形式のstring型で入力してください。({value})',
|
|
64
66
|
INVALID_DATETIME: '{property}は"YYYY-MM-DD hh:mi:ss"または"YYYY-MM-DDThh:mi:ss"形式のstring型で入力してください。({value})',
|
|
65
67
|
INVALID_BASE64: '{property}はBase64形式のstring型で入力してください。({value})',
|
|
66
|
-
INVALID_ENUM: '{property}は{enums}のいずれかの値で入力してください。({value})'
|
|
68
|
+
INVALID_ENUM: '{property}は{enums}のいずれかの値で入力してください。({value})',
|
|
69
|
+
INVALID_DICTIONAY: '{property}は有効なKey-Value形式で入力してください。({value})'
|
|
67
70
|
}
|
|
68
71
|
protected readonly ERROR_MESSAGE: ErrorMessageType = process.env.TZ === 'Asia/Tokyo' ? this.ERROR_MESSAGE_JAPAN : this.ERROR_MESSAGE_ENGLISH;
|
|
69
72
|
|
|
@@ -138,6 +141,7 @@ export class RequestType extends ReqResType {
|
|
|
138
141
|
"TIME_21" | "DATETIME_21" | "DATETIME_22" | "HTTPS_21" | "BASE64_21" |
|
|
139
142
|
"REQUIRE_31" |
|
|
140
143
|
"ENUM_41" | "ENUM_42" | "NUMBER_41" | "STRING_41" |
|
|
144
|
+
"DICTIONARY_51" |
|
|
141
145
|
"NUMBER_91" | "BOOL_91" | "BOOL_92" | "BOOL_93" | "STRING_91" | "UUID_91" | "MAIL_91" | "DATE_91" | "DATE_92" |
|
|
142
146
|
"TIME_91" | "DATETIME_91" | "DATETIME_92" | "HTTPS_91" | "BASE64_91"
|
|
143
147
|
, keys: Array<string | number>, value: any): never {
|
|
@@ -170,6 +174,7 @@ export class RequestType extends ReqResType {
|
|
|
170
174
|
"STRING_41": this.ERROR_MESSAGE.INVALID_STRING,
|
|
171
175
|
"ENUM_41": this.ERROR_MESSAGE.INVALID_ENUM,
|
|
172
176
|
"ENUM_42": this.ERROR_MESSAGE.INVALID_ENUM,
|
|
177
|
+
"DICTIONARY_51": this.ERROR_MESSAGE.INVALID_DICTIONAY,
|
|
173
178
|
"NUMBER_91": this.ERROR_MESSAGE.INVALID_NUMBER,
|
|
174
179
|
"BOOL_91": this.ERROR_MESSAGE.INVALID_BOOL,
|
|
175
180
|
"BOOL_92": this.ERROR_MESSAGE.INVALID_BOOL,
|
|
@@ -280,6 +285,9 @@ export class RequestType extends ReqResType {
|
|
|
280
285
|
}
|
|
281
286
|
}
|
|
282
287
|
break;
|
|
288
|
+
case 'dictionary':
|
|
289
|
+
case 'dictionary?':
|
|
290
|
+
break;
|
|
283
291
|
case 'enum':
|
|
284
292
|
case 'enum?':
|
|
285
293
|
this.setEnum([key], value);
|
|
@@ -399,6 +407,42 @@ export class RequestType extends ReqResType {
|
|
|
399
407
|
}
|
|
400
408
|
}
|
|
401
409
|
|
|
410
|
+
private setDictionary(keys: Array<string | number>, values: any) {
|
|
411
|
+
// const property = this.getProperty(keys);
|
|
412
|
+
// for (let i = 0;i < values.length; i++) {
|
|
413
|
+
|
|
414
|
+
// // NULL Check
|
|
415
|
+
// if (values[i] === undefined || values[i] === null || (property.properties.type.replace("?", "") !== "string" && values[i] === "")) {
|
|
416
|
+
// if (property.properties.type.endsWith('?')) {
|
|
417
|
+
// this.changeBody([...keys, i], values[i] === undefined ? undefined : null);
|
|
418
|
+
// continue;
|
|
419
|
+
// } else {
|
|
420
|
+
// this.throwInputError("DICTIONARY_51", [...keys, i], "");
|
|
421
|
+
// }
|
|
422
|
+
// }
|
|
423
|
+
|
|
424
|
+
// switch (property.properties.type) {
|
|
425
|
+
// case 'object':
|
|
426
|
+
// case 'object?':
|
|
427
|
+
// this.setObject([...keys, i], values[i]);
|
|
428
|
+
// break;
|
|
429
|
+
// case 'array':
|
|
430
|
+
// case 'array?':
|
|
431
|
+
// this.setArray([...keys, i], values[i]);
|
|
432
|
+
// break;
|
|
433
|
+
// case 'enum':
|
|
434
|
+
// case 'enum?':
|
|
435
|
+
// for (const value of values) {
|
|
436
|
+
// this.setEnum([...keys, i], value);
|
|
437
|
+
// }
|
|
438
|
+
// break;
|
|
439
|
+
// default:
|
|
440
|
+
// this.convertInput([...keys, i], values[i]);
|
|
441
|
+
// break;
|
|
442
|
+
// }
|
|
443
|
+
// }
|
|
444
|
+
}
|
|
445
|
+
|
|
402
446
|
/**
|
|
403
447
|
* Retrieve the property definition corresponding to the specified key path.
|
|
404
448
|
* 指定されたキーパスに対応するプロパティ定義を取得します。
|
|
@@ -848,6 +892,33 @@ export class RequestType extends ReqResType {
|
|
|
848
892
|
|
|
849
893
|
return ymlString;
|
|
850
894
|
}
|
|
895
|
+
|
|
896
|
+
// private makeSwaggerPropertyFromDictionary(keys: Array<string | number>, tabCount: number): string {
|
|
897
|
+
|
|
898
|
+
// const property = this.getProperty(keys).properties;
|
|
899
|
+
|
|
900
|
+
// const space = ' '.repeat(tabCount);
|
|
901
|
+
|
|
902
|
+
// let ymlString = `${space}items:\n`;
|
|
903
|
+
// ymlString += `${space} type: ${this.replaceFromPropertyTypeToSwagger(property)}\n`;
|
|
904
|
+
// if ((property.description ?? '') !== '') {
|
|
905
|
+
// const descJoin = `\n${space} `;
|
|
906
|
+
// ymlString += `${space} description: |${descJoin}${property.description.replaceAll('\n', descJoin)}\n`;
|
|
907
|
+
// }
|
|
908
|
+
|
|
909
|
+
// switch (property.type) {
|
|
910
|
+
// case 'object':
|
|
911
|
+
// case 'object?':
|
|
912
|
+
// ymlString += this.makeSwaggerProperyFromObject([...keys, 0], tabCount + 1);
|
|
913
|
+
// break;
|
|
914
|
+
// case 'array':
|
|
915
|
+
// case 'array?':
|
|
916
|
+
// ymlString += this.makeSwaggerPropertyFromArray([...keys, 0], tabCount + 1);
|
|
917
|
+
// break;
|
|
918
|
+
// }
|
|
919
|
+
|
|
920
|
+
// return ymlString;
|
|
921
|
+
// }
|
|
851
922
|
}
|
|
852
923
|
|
|
853
924
|
// Requestのheaderで定義されているIFをそのまま拝借
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ValidateStringUtil } from "type-utils-n-daira";
|
|
2
2
|
import StringUtil from "../Utils/StringUtil";
|
|
3
|
-
import ReqResType from "./ReqResType";
|
|
3
|
+
import ReqResType, { ArrayType } from "./ReqResType";
|
|
4
4
|
|
|
5
5
|
export class ResponseType extends ReqResType {
|
|
6
6
|
|
|
@@ -291,6 +291,12 @@ export class ResponseType extends ReqResType {
|
|
|
291
291
|
return value;
|
|
292
292
|
}
|
|
293
293
|
return undefined;
|
|
294
|
+
case 'dictionary':
|
|
295
|
+
case 'dictionary?':
|
|
296
|
+
// if (Object.keys(property.enums).includes(value)) {
|
|
297
|
+
// return value;
|
|
298
|
+
// }
|
|
299
|
+
return undefined;
|
|
294
300
|
default:
|
|
295
301
|
return undefined;
|
|
296
302
|
}
|
|
@@ -343,6 +349,10 @@ export class ResponseType extends ReqResType {
|
|
|
343
349
|
case 'array?':
|
|
344
350
|
ymlString += this.makeSwaggerPropertyFromArray([key], tabCount + 1);
|
|
345
351
|
break;
|
|
352
|
+
case 'dictionary':
|
|
353
|
+
case 'dictionary?':
|
|
354
|
+
ymlString += this.makeSwaggerPropertyFromDictionary([key], tabCount + 1);
|
|
355
|
+
break;
|
|
346
356
|
}
|
|
347
357
|
}
|
|
348
358
|
|
|
@@ -381,6 +391,10 @@ export class ResponseType extends ReqResType {
|
|
|
381
391
|
case 'array?':
|
|
382
392
|
ymlString += this.makeSwaggerPropertyFromArray([...keys, key], tabCount + 2);
|
|
383
393
|
break;
|
|
394
|
+
case 'dictionary':
|
|
395
|
+
case 'dictionary?':
|
|
396
|
+
ymlString += this.makeSwaggerPropertyFromDictionary([...keys, key], tabCount + 2);
|
|
397
|
+
break;
|
|
384
398
|
}
|
|
385
399
|
}
|
|
386
400
|
|
|
@@ -413,8 +427,29 @@ export class ResponseType extends ReqResType {
|
|
|
413
427
|
case 'array?':
|
|
414
428
|
ymlString += this.makeSwaggerPropertyFromArray([...keys, 0], tabCount + 1);
|
|
415
429
|
break;
|
|
430
|
+
case 'dictionary':
|
|
431
|
+
case 'dictionary?':
|
|
432
|
+
ymlString += this.makeSwaggerPropertyFromDictionary([...keys, 0], tabCount + 1);
|
|
433
|
+
break;
|
|
416
434
|
}
|
|
417
435
|
|
|
436
|
+
return ymlString;
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
/**
|
|
440
|
+
* Generates Swagger properties from array type properties
|
|
441
|
+
* 配列型のプロパティからSwaggerのプロパティを生成
|
|
442
|
+
* @param {Array.<string|number>} keys - Path to the properties, プロパティへのパス
|
|
443
|
+
* @returns {string} Swagger format property definition, Swagger形式のプロパティ定義
|
|
444
|
+
*/
|
|
445
|
+
private makeSwaggerPropertyFromDictionary(keys: Array<string | number>, tabCount: number): string {
|
|
446
|
+
|
|
447
|
+
const property = this.getProperty(keys);
|
|
448
|
+
const space = ' '.repeat(tabCount);
|
|
449
|
+
let ymlString = `${space}properties:\n`;
|
|
450
|
+
ymlString += `${space} key:\n`;
|
|
451
|
+
ymlString += `${space} type: ${this.replaceFromPropertyTypeToSwagger(property)}\n`;
|
|
452
|
+
|
|
418
453
|
return ymlString;
|
|
419
454
|
}
|
|
420
455
|
}
|