pg-mvc-service 2.0.112 → 2.0.114

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/Service.js CHANGED
@@ -34,6 +34,13 @@ class Service {
34
34
  get Response() { return this.response; }
35
35
  ; // swaggerで必要なので、ここだけ宣言
36
36
  get Tags() { return this.tags; }
37
+ get ErrorList() {
38
+ return [...this.errorList, {
39
+ status: 500,
40
+ code: '',
41
+ description: 'サーバー内部エラー(予期せぬエラー)'
42
+ }];
43
+ }
37
44
  constructor(request, response) {
38
45
  this.method = 'GET';
39
46
  this.endpoint = '';
@@ -44,6 +51,7 @@ class Service {
44
51
  this.response = new ResponseType_1.ResponseType();
45
52
  this.isTest = process.env.NODE_ENV === 'test';
46
53
  this.tags = [];
54
+ this.errorList = [];
47
55
  this.dbUser = process.env.DB_USER;
48
56
  this.dbHost = process.env.DB_HOST;
49
57
  this.dbName = process.env.DB_DATABASE;
@@ -59,7 +59,8 @@ const createSwagger = (services, name, url, params = []) => {
59
59
  }
60
60
  }
61
61
  yml += service.Request.createSwagger(service.Method);
62
- yml += service.Response.createSwagger(service.Request.getInputErrorLost(service.Method, service.ApiCode));
62
+ const errorList = [...service.ErrorList, ...service.Request.getInputErrorList(service.Method, service.ApiCode)];
63
+ yml += service.Response.createSwagger(errorList);
63
64
  endpontSwaggerYml[service.Endpoint][service.Method] = yml;
64
65
  }
65
66
  let swaggerInfo = `openapi: 3.0.0
@@ -118,15 +118,7 @@ class RequestType extends ReqResType_1.default {
118
118
  this.headers = (_b = request.headers) !== null && _b !== void 0 ? _b : {};
119
119
  this.remoteAddress = (_c = request.socket) === null || _c === void 0 ? void 0 : _c.remoteAddress;
120
120
  }
121
- /**
122
- * Generates an error message based on the provided code, keys, and value.
123
- * 指定されたコード、キー、および値に基づいてエラーメッセージを生成します。
124
- * @param {string} code - The error code. エラーコード
125
- * @param {Array<string | number>} keys - The keys indicating the property path. プロパティパスを示すキー
126
- * @param {any} value - The value that caused the error. エラーを引き起こした値
127
- * @returns {string} The generated error message. 生成されたエラーメッセージ
128
- */
129
- throwInputError(code, keys, value) {
121
+ createErrorMessage(code, keys, value) {
130
122
  var _a, _b, _c, _d, _e;
131
123
  const list = {
132
124
  "REQUIRE_00": this.ERROR_MESSAGE.REQUIRED,
@@ -214,8 +206,25 @@ class RequestType extends ReqResType_1.default {
214
206
  errorMessage = errorMessage.replace('{min}', ((_e = property.min) !== null && _e !== void 0 ? _e : '[未指定]').toString());
215
207
  break;
216
208
  }
217
- errorMessage = errorMessage.replace("{property}", keys.join('.')).replace("{value}", value);
218
- throw new Exception_1.InputErrorException(code, errorMessage);
209
+ errorMessage = errorMessage.replace("{property}", keys.join('.'));
210
+ if (value === undefined) {
211
+ errorMessage = errorMessage.replace("{value}", value);
212
+ }
213
+ else {
214
+ errorMessage = errorMessage.replace("{value}", "");
215
+ }
216
+ return errorMessage;
217
+ }
218
+ /**
219
+ * Generates an error message based on the provided code, keys, and value.
220
+ * 指定されたコード、キー、および値に基づいてエラーメッセージを生成します。
221
+ * @param {string} code - The error code. エラーコード
222
+ * @param {Array<string | number>} keys - The keys indicating the property path. プロパティパスを示すキー
223
+ * @param {any} value - The value that caused the error. エラーを引き起こした値
224
+ * @returns {string} The generated error message. 生成されたエラーメッセージ
225
+ */
226
+ throwInputError(code, keys, value) {
227
+ throw new Exception_1.InputErrorException(code, this.createErrorMessage(code, keys, value));
219
228
  }
220
229
  /**
221
230
  * Sets the values of the request body to the class properties.
@@ -239,8 +248,7 @@ class RequestType extends ReqResType_1.default {
239
248
  this.data = request.body;
240
249
  }
241
250
  if (this.data === undefined) {
242
- // ここは基本通ることはないと思いますが...
243
- throw new Error(`リクエストBodyがundefinedです。`);
251
+ this.data = {};
244
252
  }
245
253
  for (const key of Object.keys(this.properties)) {
246
254
  // NULLチェック
@@ -1013,44 +1021,86 @@ class RequestType extends ReqResType_1.default {
1013
1021
  }
1014
1022
  return ymlString;
1015
1023
  }
1016
- getInputErrorLost(method, code) {
1024
+ getInputErrorList(method, code) {
1017
1025
  const errorList = [];
1018
- if (method === 'GET' || method === 'DELETE') {
1019
- const tabCount = 4;
1020
- const space = ' '.repeat(tabCount);
1021
- let ymlString = '';
1022
- for (const [key, property] of Object.entries(this.properties)) {
1023
- if (property.type.endsWith('?') === false) {
1026
+ for (const [key, property] of Object.entries(this.properties)) {
1027
+ if (property.type.endsWith('?') === false) {
1028
+ const errorCode = property.type === 'array' && ['GET', 'DELETE'].includes(method) ? 'REQUIRE_00' : 'REQUIRE_01';
1029
+ errorList.push({
1030
+ status: 400,
1031
+ code: code + '-' + errorCode,
1032
+ description: this.createErrorMessage(errorCode, [key])
1033
+ });
1034
+ }
1035
+ switch (property.type) {
1036
+ case 'object':
1037
+ case 'object?':
1024
1038
  errorList.push({
1025
1039
  status: 400,
1026
- code: code + '',
1027
- description: `${key}:未入力エラー(未指定、null、空文字の場合にエラー)`
1040
+ code: code + '-OBJECT_01',
1041
+ description: this.createErrorMessage('OBJECT_01', [key])
1028
1042
  });
1029
- }
1030
- // ymlString += `${space}- name: ${key}\n`;
1031
- // ymlString += `${space} in: query\n`;
1032
- // const descJoin = `\n${space} `;
1033
- // if (property.type === 'enum' || property.type === 'enum?') {
1034
- // ymlString += `${space} description: |${property.description === undefined ? '' : `${descJoin}${property.description.replaceAll("\n", descJoin)}`}`;
1035
- // ymlString += `${descJoin}enum list`;
1036
- // ymlString += `${Object.entries(property.enums).map(([key, value]) => `${descJoin}- ${key}: ${value}`)}\n`;
1037
- // } else if (property.description !== undefined) {
1038
- // ymlString += `${space} description: |\n${space} ${property.description.replaceAll("\n", descJoin)}\n`;
1039
- // }
1040
- // ymlString += `${space} required: ${property.type.endsWith('?') ? 'false' : 'true'}\n`;
1041
- // ymlString += `${space} schema:\n`;
1042
- // ymlString += `${space} type: ${this.replaceFromPropertyTypeToSwagger(property)}\n`;
1043
- // if (property.type === 'enum' || property.type === 'enum?') {
1044
- // ymlString += `${space} nullable: ${property.enumType.endsWith('?')}\n`;
1045
- // ymlString += `${space} enum:\n`;
1046
- // for (const type of Object.keys(property.enumType)) {
1047
- // ymlString += `${space} - ${type}\n`;
1048
- // }
1049
- // if (property.enumType.endsWith('?')) {
1050
- // ymlString += `${space} - null\n`;
1051
- // }
1052
- // }
1043
+ break;
1044
+ case 'array':
1045
+ case 'array?':
1046
+ errorList.push({
1047
+ status: 400,
1048
+ code: code + '-ARRAY_01',
1049
+ description: this.createErrorMessage('ARRAY_01', [key])
1050
+ });
1051
+ break;
1052
+ case 'map':
1053
+ case 'map?':
1054
+ switch (property.mapType) {
1055
+ case 'number':
1056
+ errorList.push({
1057
+ status: 400,
1058
+ code: code + '-MAP_01',
1059
+ description: this.createErrorMessage('MAP_01', [key])
1060
+ });
1061
+ break;
1062
+ case 'string':
1063
+ errorList.push({
1064
+ status: 400,
1065
+ code: code + '-MAP_02',
1066
+ description: this.createErrorMessage('MAP_02', [key])
1067
+ });
1068
+ break;
1069
+ case 'bool':
1070
+ errorList.push({
1071
+ status: 400,
1072
+ code: code + '-MAP_03',
1073
+ description: this.createErrorMessage('MAP_03', [key])
1074
+ });
1075
+ errorList.push({
1076
+ status: 400,
1077
+ code: code + '-MAP_04',
1078
+ description: this.createErrorMessage('MAP_04', [key])
1079
+ });
1080
+ errorList.push({
1081
+ status: 400,
1082
+ code: code + '-MAP_05',
1083
+ description: this.createErrorMessage('MAP_05', [key])
1084
+ });
1085
+ break;
1086
+ }
1087
+ break;
1088
+ case 'enum':
1089
+ case 'enum?':
1090
+ break;
1091
+ default:
1092
+ break;
1053
1093
  }
1094
+ // this.changeBody([key], mapData);
1095
+ // break;
1096
+ // case 'enum':
1097
+ // case 'enum?':
1098
+ // this.setEnum([key], value);
1099
+ // break;
1100
+ // default:
1101
+ // this.convertInput([key], value);
1102
+ // break;
1103
+ // }
1054
1104
  }
1055
1105
  return errorList;
1056
1106
  }
@@ -10,7 +10,6 @@ const ReqResType_1 = __importDefault(require("./ReqResType"));
10
10
  class ResponseType extends ReqResType_1.default {
11
11
  constructor() {
12
12
  super(...arguments);
13
- this.errorList = [];
14
13
  /**
15
14
  * Property to store response data
16
15
  * レスポンスデータを格納するためのプロパティ
@@ -338,7 +337,7 @@ class ResponseType extends ReqResType_1.default {
338
337
  * @returns {string} Swagger format response definition
339
338
  * Swagger形式のレスポンス定義
340
339
  */
341
- createSwagger(requestErrorList) {
340
+ createSwagger(errorList) {
342
341
  let ymlString = ` responses:
343
342
  '200':
344
343
  description: 成功事レスポンス
@@ -376,19 +375,13 @@ class ResponseType extends ReqResType_1.default {
376
375
  break;
377
376
  }
378
377
  }
379
- const errorList = [...this.errorList, ...requestErrorList];
380
- errorList.push({
381
- status: 500,
382
- code: '',
383
- description: 'サーバー内部エラー(予期せぬエラー)'
384
- });
385
378
  // statusごとにグルーピング
386
379
  const grouped = {};
387
- for (const e of errorList) {
388
- if (grouped[e.status] === undefined) {
389
- grouped[e.status] = [];
380
+ for (const error of errorList) {
381
+ if (grouped[error.status] === undefined) {
382
+ grouped[error.status] = [];
390
383
  }
391
- grouped[e.status].push(e);
384
+ grouped[error.status].push(error);
392
385
  }
393
386
  // 出力順(存在するものだけ出す)
394
387
  const statusOrder = [400, 401, 404, 409, 422, 500];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pg-mvc-service",
3
- "version": "2.0.112",
3
+ "version": "2.0.114",
4
4
  "description": "",
5
5
  "homepage": "https://github.com/n-daira/npm-pack_mvc-service#readme",
6
6
  "bugs": {
package/src/Service.ts CHANGED
@@ -11,6 +11,11 @@ import { EncryptClient } from './clients/EncryptClient';
11
11
  import PoolManager from './PoolManager';
12
12
 
13
13
  export type MethodType = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE';
14
+ export interface IError {
15
+ status: 400 | 401 | 404 | 409 | 422 | 500,
16
+ code: string;
17
+ description: string;
18
+ }
14
19
 
15
20
  export class Service {
16
21
  protected readonly method: MethodType = 'GET';
@@ -31,6 +36,14 @@ export class Service {
31
36
  protected readonly isTest: boolean = process.env.NODE_ENV === 'test';
32
37
  protected readonly tags: Array<string> = [];
33
38
  get Tags(): Array<string> { return this.tags; }
39
+ protected readonly errorList: Array<IError> = [];
40
+ get ErrorList(): Array<IError> {
41
+ return [...this.errorList, {
42
+ status: 500,
43
+ code: '',
44
+ description: 'サーバー内部エラー(予期せぬエラー)'
45
+ }];
46
+ }
34
47
 
35
48
  protected readonly req: Request;
36
49
  protected readonly res: Response;
@@ -72,7 +72,8 @@ export const createSwagger = (services: Service[], name: string, url: string, pa
72
72
  }
73
73
 
74
74
  yml += service.Request.createSwagger(service.Method);
75
- yml += service.Response.createSwagger(service.Request.getInputErrorLost(service.Method, service.ApiCode));
75
+ const errorList = [...service.ErrorList, ...service.Request.getInputErrorList(service.Method, service.ApiCode)]
76
+ yml += service.Response.createSwagger(errorList);
76
77
 
77
78
  endpontSwaggerYml[service.Endpoint][service.Method] = yml;
78
79
  }
@@ -3,7 +3,7 @@ import ReqResType, { EnumType, NumberType, PrimitiveType, PropertyType, StringTy
3
3
  import { InputErrorException } from '../exceptions/Exception';
4
4
  import StringUtil from '../Utils/StringUtil';
5
5
  import { ValidateStringUtil } from 'type-utils-n-daira';
6
- import { IError } from './ResponseType';
6
+ import { IError } from '../Service';
7
7
 
8
8
  // エラーメッセージの型定義
9
9
  export interface ErrorMessageType {
@@ -145,15 +145,7 @@ export class RequestType extends ReqResType {
145
145
  this.remoteAddress = request.socket?.remoteAddress;
146
146
  }
147
147
 
148
- /**
149
- * Generates an error message based on the provided code, keys, and value.
150
- * 指定されたコード、キー、および値に基づいてエラーメッセージを生成します。
151
- * @param {string} code - The error code. エラーコード
152
- * @param {Array<string | number>} keys - The keys indicating the property path. プロパティパスを示すキー
153
- * @param {any} value - The value that caused the error. エラーを引き起こした値
154
- * @returns {string} The generated error message. 生成されたエラーメッセージ
155
- */
156
- private throwInputError(code:
148
+ private createErrorMessage(code:
157
149
  "REQUIRE_00" | "REQUIRE_01" | "OBJECT_01" | "ARRAY_01" | "UNNECESSARY_01" |
158
150
  "REQUIRE_11" | "OBJECT_11" | "ARRAY_11" | "UNNECESSARY_11" |
159
151
  "NUMBER_21" | "NUMBER_22" | "NUMBER_23" | "BOOL_21" | "BOOL_22" | "BOOL_23" | "STRING_21" | "STRING_22" | "STRING_23" | "UUID_21" | "MAIL_21" | "DATE_21" | "DATE_22" |
@@ -163,8 +155,10 @@ export class RequestType extends ReqResType {
163
155
  "MAP_01" | "MAP_02" | "MAP_03" | "MAP_04" | "MAP_05" | "MAP_11" | "MAP_12" | "MAP_13" | "MAP_14" | "MAP_15" |
164
156
  "MAP_31" | "MAP_32" | "MAP_33" | "MAP_34" | "MAP_35" |
165
157
  "NUMBER_91" | "NUMBER_92" | "NUMBER_93" | "BOOL_91" | "BOOL_92" | "BOOL_93" | "STRING_91" | "STRING_92" | "STRING_93" | "UUID_91" | "MAIL_91" | "DATE_91" | "DATE_92" |
166
- "TIME_91" | "DATETIME_91" | "DATETIME_92" | "HTTPS_91" | "BASE64_91"
167
- , keys: Array<string | number>, value: any): never {
158
+ "TIME_91" | "DATETIME_91" | "DATETIME_92" | "HTTPS_91" | "BASE64_91",
159
+ keys: Array<string | number>,
160
+ value?: any
161
+ ) {
168
162
  const list = {
169
163
  "REQUIRE_00": this.ERROR_MESSAGE.REQUIRED,
170
164
  "REQUIRE_01": this.ERROR_MESSAGE.REQUIRED,
@@ -253,9 +247,38 @@ export class RequestType extends ReqResType {
253
247
  break;
254
248
  }
255
249
 
256
- errorMessage = errorMessage.replace("{property}", keys.join('.')).replace("{value}", value);
250
+ errorMessage = errorMessage.replace("{property}", keys.join('.'));
251
+ if (value === undefined) {
252
+ errorMessage = errorMessage.replace("{value}", value);
253
+ } else {
254
+ errorMessage = errorMessage.replace("{value}", "");
255
+ }
256
+
257
+ return errorMessage;
258
+ }
257
259
 
258
- throw new InputErrorException(code, errorMessage);
260
+ /**
261
+ * Generates an error message based on the provided code, keys, and value.
262
+ * 指定されたコード、キー、および値に基づいてエラーメッセージを生成します。
263
+ * @param {string} code - The error code. エラーコード
264
+ * @param {Array<string | number>} keys - The keys indicating the property path. プロパティパスを示すキー
265
+ * @param {any} value - The value that caused the error. エラーを引き起こした値
266
+ * @returns {string} The generated error message. 生成されたエラーメッセージ
267
+ */
268
+ private throwInputError(code:
269
+ "REQUIRE_00" | "REQUIRE_01" | "OBJECT_01" | "ARRAY_01" | "UNNECESSARY_01" |
270
+ "REQUIRE_11" | "OBJECT_11" | "ARRAY_11" | "UNNECESSARY_11" |
271
+ "NUMBER_21" | "NUMBER_22" | "NUMBER_23" | "BOOL_21" | "BOOL_22" | "BOOL_23" | "STRING_21" | "STRING_22" | "STRING_23" | "UUID_21" | "MAIL_21" | "DATE_21" | "DATE_22" |
272
+ "TIME_21" | "DATETIME_21" | "DATETIME_22" | "HTTPS_21" | "BASE64_21" |
273
+ "REQUIRE_31" |
274
+ "ENUM_32" | "ENUM_41" | "ENUM_42" | "NUMBER_41" | "STRING_41" |
275
+ "MAP_01" | "MAP_02" | "MAP_03" | "MAP_04" | "MAP_05" | "MAP_11" | "MAP_12" | "MAP_13" | "MAP_14" | "MAP_15" |
276
+ "MAP_31" | "MAP_32" | "MAP_33" | "MAP_34" | "MAP_35" |
277
+ "NUMBER_91" | "NUMBER_92" | "NUMBER_93" | "BOOL_91" | "BOOL_92" | "BOOL_93" | "STRING_91" | "STRING_92" | "STRING_93" | "UUID_91" | "MAIL_91" | "DATE_91" | "DATE_92" |
278
+ "TIME_91" | "DATETIME_91" | "DATETIME_92" | "HTTPS_91" | "BASE64_91"
279
+ , keys: Array<string | number>, value: any): never {
280
+
281
+ throw new InputErrorException(code, this.createErrorMessage(code, keys, value));
259
282
  }
260
283
 
261
284
  /**
@@ -280,8 +303,7 @@ export class RequestType extends ReqResType {
280
303
  }
281
304
 
282
305
  if (this.data === undefined) {
283
- // ここは基本通ることはないと思いますが...
284
- throw new Error(`リクエストBodyがundefinedです。`);
306
+ this.data = {};
285
307
  }
286
308
 
287
309
  for (const key of Object.keys(this.properties)) {
@@ -1100,48 +1122,88 @@ export class RequestType extends ReqResType {
1100
1122
  return ymlString;
1101
1123
  }
1102
1124
 
1103
- public getInputErrorLost(method: string, code: string): Array<IError> {
1125
+ public getInputErrorList(method: string, code: string): Array<IError> {
1104
1126
  const errorList: Array<IError> = [];
1127
+ for (const [key, property] of Object.entries(this.properties)) {
1128
+ if (property.type.endsWith('?') === false) {
1129
+ const errorCode = property.type === 'array' && ['GET', 'DELETE'].includes(method) ? 'REQUIRE_00' : 'REQUIRE_01';
1130
+ errorList.push({
1131
+ status: 400,
1132
+ code: code + '-' + errorCode,
1133
+ description: this.createErrorMessage(errorCode, [key])
1134
+ });
1135
+ }
1105
1136
 
1106
- if (method === 'GET' || method === 'DELETE') {
1107
-
1108
- const tabCount = 4;
1109
- const space = ' '.repeat(tabCount);
1110
-
1111
- let ymlString = '';
1112
- for (const [key, property] of Object.entries(this.properties)) {
1113
- if (property.type.endsWith('?') === false) {
1137
+ switch (property.type) {
1138
+ case 'object':
1139
+ case 'object?':
1114
1140
  errorList.push({
1115
1141
  status: 400,
1116
- code: code + '',
1117
- description: `${key}:未入力エラー(未指定、null、空文字の場合にエラー)`
1142
+ code: code + '-OBJECT_01',
1143
+ description: this.createErrorMessage('OBJECT_01', [key])
1118
1144
  });
1119
- }
1120
- // ymlString += `${space}- name: ${key}\n`;
1121
- // ymlString += `${space} in: query\n`;
1122
-
1123
- // const descJoin = `\n${space} `;
1124
- // if (property.type === 'enum' || property.type === 'enum?') {
1125
- // ymlString += `${space} description: |${property.description === undefined ? '' : `${descJoin}${property.description.replaceAll("\n", descJoin)}`}`;
1126
- // ymlString += `${descJoin}enum list`;
1127
- // ymlString += `${Object.entries(property.enums).map(([key, value]) => `${descJoin}- ${key}: ${value}`)}\n`;
1128
- // } else if (property.description !== undefined) {
1129
- // ymlString += `${space} description: |\n${space} ${property.description.replaceAll("\n", descJoin)}\n`;
1130
- // }
1131
- // ymlString += `${space} required: ${property.type.endsWith('?') ? 'false' : 'true'}\n`;
1132
- // ymlString += `${space} schema:\n`;
1133
- // ymlString += `${space} type: ${this.replaceFromPropertyTypeToSwagger(property)}\n`;
1134
- // if (property.type === 'enum' || property.type === 'enum?') {
1135
- // ymlString += `${space} nullable: ${property.enumType.endsWith('?')}\n`;
1136
- // ymlString += `${space} enum:\n`;
1137
- // for (const type of Object.keys(property.enumType)) {
1138
- // ymlString += `${space} - ${type}\n`;
1139
- // }
1140
- // if (property.enumType.endsWith('?')) {
1141
- // ymlString += `${space} - null\n`;
1142
- // }
1143
- // }
1145
+ break;
1146
+ case 'array':
1147
+ case 'array?':
1148
+ errorList.push({
1149
+ status: 400,
1150
+ code: code + '-ARRAY_01',
1151
+ description: this.createErrorMessage('ARRAY_01', [key])
1152
+ });
1153
+ break;
1154
+ case 'map':
1155
+ case 'map?':
1156
+ switch (property.mapType) {
1157
+ case 'number':
1158
+ errorList.push({
1159
+ status: 400,
1160
+ code: code + '-MAP_01',
1161
+ description: this.createErrorMessage('MAP_01', [key])
1162
+ });
1163
+ break;
1164
+ case 'string':
1165
+ errorList.push({
1166
+ status: 400,
1167
+ code: code + '-MAP_02',
1168
+ description: this.createErrorMessage('MAP_02', [key])
1169
+ });
1170
+ break;
1171
+ case 'bool':
1172
+ errorList.push({
1173
+ status: 400,
1174
+ code: code + '-MAP_03',
1175
+ description: this.createErrorMessage('MAP_03', [key])
1176
+ });
1177
+ errorList.push({
1178
+ status: 400,
1179
+ code: code + '-MAP_04',
1180
+ description: this.createErrorMessage('MAP_04', [key])
1181
+ });
1182
+ errorList.push({
1183
+ status: 400,
1184
+ code: code + '-MAP_05',
1185
+ description: this.createErrorMessage('MAP_05', [key])
1186
+ });
1187
+ break;
1188
+ }
1189
+ break;
1190
+ case 'enum':
1191
+ case 'enum?':
1192
+ break;
1193
+ default:
1194
+ break;
1144
1195
  }
1196
+
1197
+ // this.changeBody([key], mapData);
1198
+ // break;
1199
+ // case 'enum':
1200
+ // case 'enum?':
1201
+ // this.setEnum([key], value);
1202
+ // break;
1203
+ // default:
1204
+ // this.convertInput([key], value);
1205
+ // break;
1206
+ // }
1145
1207
  }
1146
1208
 
1147
1209
  return errorList;
@@ -1,16 +1,11 @@
1
1
  import { ValidateStringUtil } from "type-utils-n-daira";
2
2
  import StringUtil from "../Utils/StringUtil";
3
3
  import ReqResType, { PropertyType } from "./ReqResType";
4
+ import { IError } from "../Service";
4
5
 
5
- export interface IError {
6
- status: 400 | 401 | 404 | 409 | 422 | 500,
7
- code: string;
8
- description: string;
9
- }
10
6
 
11
- export class ResponseType extends ReqResType {
12
7
 
13
- protected readonly errorList: Array<IError> = [];
8
+ export class ResponseType extends ReqResType {
14
9
 
15
10
  /**
16
11
  * Property to store response data
@@ -375,7 +370,7 @@ export class ResponseType extends ReqResType {
375
370
  * @returns {string} Swagger format response definition
376
371
  * Swagger形式のレスポンス定義
377
372
  */
378
- public createSwagger(requestErrorList: Array<IError>): string {
373
+ public createSwagger(errorList: Array<IError>): string {
379
374
  let ymlString = ` responses:
380
375
  '200':
381
376
  description: 成功事レスポンス
@@ -418,20 +413,14 @@ export class ResponseType extends ReqResType {
418
413
  }
419
414
  }
420
415
 
421
- const errorList: Array<IError> = [...this.errorList, ...requestErrorList];
422
- errorList.push({
423
- status: 500,
424
- code: '',
425
- description: 'サーバー内部エラー(予期せぬエラー)'
426
- })
427
416
 
428
417
  // statusごとにグルーピング
429
418
  const grouped: { [status: number]: IError[] } = {};
430
- for (const e of errorList) {
431
- if (grouped[e.status] === undefined) {
432
- grouped[e.status] = [];
419
+ for (const error of errorList) {
420
+ if (grouped[error.status] === undefined) {
421
+ grouped[error.status] = [];
433
422
  }
434
- grouped[e.status].push(e);
423
+ grouped[error.status].push(error);
435
424
  }
436
425
 
437
426
  // 出力順(存在するものだけ出す)
@@ -455,7 +444,6 @@ export class ResponseType extends ReqResType {
455
444
  description: |${descIndentJoin}${bullets}
456
445
  `;
457
446
  }
458
-
459
447
  }
460
448
 
461
449
  return ymlString;