pg-mvc-service 2.0.105 → 2.0.107
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.
|
@@ -382,33 +382,92 @@ class ResponseType extends ReqResType_1.default {
|
|
|
382
382
|
code: '',
|
|
383
383
|
description: 'サーバー内部エラー(予期せぬエラー)'
|
|
384
384
|
});
|
|
385
|
-
for (const error of errorList) {
|
|
386
|
-
|
|
387
|
-
'${error.
|
|
388
|
-
|
|
389
|
-
|
|
385
|
+
// for (const error of errorList) {
|
|
386
|
+
// ymlString += `
|
|
387
|
+
// '${error.status}':
|
|
388
|
+
// description: 【エラー】${error.description}
|
|
389
|
+
// content:
|
|
390
|
+
// application/json:
|
|
391
|
+
// schema:
|
|
392
|
+
// type: object
|
|
393
|
+
// properties:`;
|
|
394
|
+
// if ([400, 404, 409, 422].includes(error.status)) {
|
|
395
|
+
// ymlString += `
|
|
396
|
+
// errorCode:
|
|
397
|
+
// type: string
|
|
398
|
+
// description: エラーコード
|
|
399
|
+
// errorMessage:
|
|
400
|
+
// type: string
|
|
401
|
+
// description: エラーメッセージ`;
|
|
402
|
+
// } else if (error.status === 401) {
|
|
403
|
+
// ymlString += `
|
|
404
|
+
// message:
|
|
405
|
+
// type: string
|
|
406
|
+
// description: Authentication expired. Please login again.`;
|
|
407
|
+
// } else if (error.status === 500) {
|
|
408
|
+
// ymlString += `
|
|
409
|
+
// message:
|
|
410
|
+
// type: string
|
|
411
|
+
// description: Internal Server Error`;
|
|
412
|
+
// }
|
|
413
|
+
// }
|
|
414
|
+
// statusごとにグルーピング
|
|
415
|
+
const grouped = {};
|
|
416
|
+
for (const e of errorList) {
|
|
417
|
+
if (grouped[e.status] === undefined) {
|
|
418
|
+
grouped[e.status] = [];
|
|
419
|
+
}
|
|
420
|
+
grouped[e.status].push(e);
|
|
421
|
+
}
|
|
422
|
+
// 出力順(存在するものだけ出す)
|
|
423
|
+
const statusOrder = [400, 401, 404, 409, 422, 500];
|
|
424
|
+
for (const status of statusOrder) {
|
|
425
|
+
const list = grouped[status];
|
|
426
|
+
if (!list || list.length === 0) {
|
|
427
|
+
continue;
|
|
428
|
+
}
|
|
429
|
+
const descIndentJoin = '\n ';
|
|
430
|
+
if (list.length === 1) {
|
|
431
|
+
// 単一エラーは1行説明
|
|
432
|
+
ymlString += `
|
|
433
|
+
'${status}':
|
|
434
|
+
description: 【エラー】${list[0].description}
|
|
435
|
+
content:
|
|
390
436
|
application/json:
|
|
391
|
-
|
|
437
|
+
schema:
|
|
392
438
|
type: object
|
|
393
439
|
properties:`;
|
|
394
|
-
|
|
440
|
+
}
|
|
441
|
+
else {
|
|
442
|
+
// 複数エラーは箇条書き
|
|
443
|
+
const bullets = list.map(e => `- ${e.code !== '' ? `${e.code}: ` : ''}${e.description}`).join(descIndentJoin);
|
|
444
|
+
ymlString += `
|
|
445
|
+
'${status}':
|
|
446
|
+
description: |${descIndentJoin}【エラー】${descIndentJoin}${bullets}
|
|
447
|
+
content:
|
|
448
|
+
application/json:
|
|
449
|
+
schema:
|
|
450
|
+
type: object
|
|
451
|
+
properties:`;
|
|
452
|
+
}
|
|
453
|
+
if ([400, 404, 409, 422].includes(status)) {
|
|
395
454
|
ymlString += `
|
|
396
|
-
|
|
455
|
+
errorCode:
|
|
397
456
|
type: string
|
|
398
457
|
description: エラーコード
|
|
399
|
-
|
|
458
|
+
errorMessage:
|
|
400
459
|
type: string
|
|
401
460
|
description: エラーメッセージ`;
|
|
402
461
|
}
|
|
403
|
-
else if (
|
|
462
|
+
else if (status === 401) {
|
|
404
463
|
ymlString += `
|
|
405
|
-
|
|
464
|
+
message:
|
|
406
465
|
type: string
|
|
407
466
|
description: Authentication expired. Please login again.`;
|
|
408
467
|
}
|
|
409
|
-
else if (
|
|
468
|
+
else if (status === 500) {
|
|
410
469
|
ymlString += `
|
|
411
|
-
|
|
470
|
+
message:
|
|
412
471
|
type: string
|
|
413
472
|
description: Internal Server Error`;
|
|
414
473
|
}
|
package/package.json
CHANGED
|
@@ -424,31 +424,93 @@ export class ResponseType extends ReqResType {
|
|
|
424
424
|
code: '',
|
|
425
425
|
description: 'サーバー内部エラー(予期せぬエラー)'
|
|
426
426
|
})
|
|
427
|
-
for (const error of errorList) {
|
|
428
|
-
|
|
429
|
-
'${error.
|
|
430
|
-
|
|
431
|
-
|
|
427
|
+
// for (const error of errorList) {
|
|
428
|
+
// ymlString += `
|
|
429
|
+
// '${error.status}':
|
|
430
|
+
// description: 【エラー】${error.description}
|
|
431
|
+
// content:
|
|
432
|
+
// application/json:
|
|
433
|
+
// schema:
|
|
434
|
+
// type: object
|
|
435
|
+
// properties:`;
|
|
436
|
+
// if ([400, 404, 409, 422].includes(error.status)) {
|
|
437
|
+
// ymlString += `
|
|
438
|
+
// errorCode:
|
|
439
|
+
// type: string
|
|
440
|
+
// description: エラーコード
|
|
441
|
+
// errorMessage:
|
|
442
|
+
// type: string
|
|
443
|
+
// description: エラーメッセージ`;
|
|
444
|
+
// } else if (error.status === 401) {
|
|
445
|
+
// ymlString += `
|
|
446
|
+
// message:
|
|
447
|
+
// type: string
|
|
448
|
+
// description: Authentication expired. Please login again.`;
|
|
449
|
+
// } else if (error.status === 500) {
|
|
450
|
+
// ymlString += `
|
|
451
|
+
// message:
|
|
452
|
+
// type: string
|
|
453
|
+
// description: Internal Server Error`;
|
|
454
|
+
// }
|
|
455
|
+
// }
|
|
456
|
+
|
|
457
|
+
// statusごとにグルーピング
|
|
458
|
+
const grouped: { [status: number]: IError[] } = {};
|
|
459
|
+
for (const e of errorList) {
|
|
460
|
+
if (grouped[e.status] === undefined) {
|
|
461
|
+
grouped[e.status] = [];
|
|
462
|
+
}
|
|
463
|
+
grouped[e.status].push(e);
|
|
464
|
+
}
|
|
465
|
+
|
|
466
|
+
// 出力順(存在するものだけ出す)
|
|
467
|
+
const statusOrder: Array<IError['status']> = [400, 401, 404, 409, 422, 500];
|
|
468
|
+
|
|
469
|
+
for (const status of statusOrder) {
|
|
470
|
+
const list = grouped[status];
|
|
471
|
+
if (!list || list.length === 0) { continue; }
|
|
472
|
+
|
|
473
|
+
const descIndentJoin = '\n ';
|
|
474
|
+
|
|
475
|
+
if (list.length === 1) {
|
|
476
|
+
// 単一エラーは1行説明
|
|
477
|
+
ymlString += `
|
|
478
|
+
'${status}':
|
|
479
|
+
description: 【エラー】${list[0].description}
|
|
480
|
+
content:
|
|
432
481
|
application/json:
|
|
433
|
-
|
|
482
|
+
schema:
|
|
434
483
|
type: object
|
|
435
484
|
properties:`;
|
|
436
|
-
|
|
485
|
+
} else {
|
|
486
|
+
// 複数エラーは箇条書き
|
|
487
|
+
const bullets = list.map(e => `- ${e.code !== '' ? `${e.code}: ` : ''}${e.description}`).join(descIndentJoin);
|
|
488
|
+
ymlString += `
|
|
489
|
+
'${status}':
|
|
490
|
+
description: |${descIndentJoin}【エラー】${descIndentJoin}${bullets}
|
|
491
|
+
content:
|
|
492
|
+
application/json:
|
|
493
|
+
schema:
|
|
494
|
+
type: object
|
|
495
|
+
properties:`;
|
|
496
|
+
}
|
|
497
|
+
|
|
498
|
+
if ([400, 404, 409, 422].includes(status)) {
|
|
437
499
|
ymlString += `
|
|
438
|
-
|
|
500
|
+
errorCode:
|
|
439
501
|
type: string
|
|
440
502
|
description: エラーコード
|
|
441
|
-
|
|
503
|
+
errorMessage:
|
|
442
504
|
type: string
|
|
443
505
|
description: エラーメッセージ`;
|
|
444
|
-
} else if (
|
|
506
|
+
} else if (status === 401) {
|
|
445
507
|
ymlString += `
|
|
446
|
-
|
|
508
|
+
message:
|
|
447
509
|
type: string
|
|
448
510
|
description: Authentication expired. Please login again.`;
|
|
449
|
-
} else if (
|
|
511
|
+
} else if (status === 500) {
|
|
450
512
|
ymlString += `
|
|
451
|
-
|
|
513
|
+
message:
|
|
452
514
|
type: string
|
|
453
515
|
description: Internal Server Error`;
|
|
454
516
|
}
|