Skip to content

Commit 40eace7

Browse files
committed
feat: Fix errors property in 500 and 502 errors schema.
1 parent 9c25c9d commit 40eace7

File tree

4 files changed

+46
-8
lines changed

4 files changed

+46
-8
lines changed

generate.ts

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,15 +59,34 @@ function main() {
5959
'Error returned when a unexpected error was thrown by the server.',
6060
{
6161
stack: { type: 'array', items: { type: 'string', description: 'A call in the error stack.', pattern: '.+' } },
62-
errors: { type: 'object', description: 'A server error.', additionalProperties: true },
62+
errors: {
63+
type: 'array',
64+
items: {
65+
type: 'object',
66+
description: 'A server error.',
67+
additionalProperties: true
68+
}
69+
},
6370
failedValidations: {
6471
type: 'object',
6572
description: 'The validation errors in the server response.',
6673
additionalProperties: true
6774
}
6875
}
6976
],
70-
502: 'Error returned when a unexpected error was thrown by a upstream server.',
77+
502: [
78+
'Error returned when a unexpected error was thrown by a upstream server.',
79+
{
80+
errors: {
81+
type: 'array',
82+
items: {
83+
type: 'object',
84+
description: 'A upstream server error.',
85+
additionalProperties: true
86+
}
87+
}
88+
}
89+
],
7190
504: 'Error returned when a upstream server timed out.'
7291
}
7392

lib/schemas.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ exports.internalServerErrorSchema = {
179179
example: 'Internal Server Error'
180180
},
181181
stack: { type: 'array', items: { type: 'string', description: 'A call in the error stack.', pattern: '.+' } },
182-
errors: { type: 'object', description: 'A server error.', additionalProperties: true },
182+
errors: { type: 'array', items: { type: 'object', description: 'A server error.', additionalProperties: true } },
183183
failedValidations: {
184184
type: 'object',
185185
description: 'The validation errors in the server response.',
@@ -202,7 +202,11 @@ exports.badGatewaySchema = {
202202
example: 'Bad Gateway'
203203
},
204204
message: { type: 'string', description: 'The error message', pattern: '.+', example: 'Bad Gateway.' },
205-
code: { type: 'string', description: 'The error code', enum: ['Bad Gateway'], example: 'Bad Gateway' }
205+
code: { type: 'string', description: 'The error code', enum: ['Bad Gateway'], example: 'Bad Gateway' },
206+
errors: {
207+
type: 'array',
208+
items: { type: 'object', description: 'A upstream server error.', additionalProperties: true }
209+
}
206210
},
207211
required: ['statusCode', 'error', 'message'],
208212
additionalProperties: false

src/schemas.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ export const internalServerErrorSchema = {
184184
example: 'Internal Server Error'
185185
},
186186
stack: { type: 'array', items: { type: 'string', description: 'A call in the error stack.', pattern: '.+' } },
187-
errors: { type: 'object', description: 'A server error.', additionalProperties: true },
187+
errors: { type: 'array', items: { type: 'object', description: 'A server error.', additionalProperties: true } },
188188
failedValidations: {
189189
type: 'object',
190190
description: 'The validation errors in the server response.',
@@ -208,7 +208,11 @@ export const badGatewaySchema = {
208208
example: 'Bad Gateway'
209209
},
210210
message: { type: 'string', description: 'The error message', pattern: '.+', example: 'Bad Gateway.' },
211-
code: { type: 'string', description: 'The error code', enum: ['Bad Gateway'], example: 'Bad Gateway' }
211+
code: { type: 'string', description: 'The error code', enum: ['Bad Gateway'], example: 'Bad Gateway' },
212+
errors: {
213+
type: 'array',
214+
items: { type: 'object', description: 'A upstream server error.', additionalProperties: true }
215+
}
212216
},
213217
required: ['statusCode', 'error', 'message'],
214218
additionalProperties: false

types/schemas.d.ts

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -314,8 +314,11 @@ export declare const internalServerErrorSchema: {
314314
};
315315
errors: {
316316
type: string;
317-
description: string;
318-
additionalProperties: boolean;
317+
items: {
318+
type: string;
319+
description: string;
320+
additionalProperties: boolean;
321+
};
319322
};
320323
failedValidations: {
321324
type: string;
@@ -355,6 +358,14 @@ export declare const badGatewaySchema: {
355358
enum: string[];
356359
example: string;
357360
};
361+
errors: {
362+
type: string;
363+
items: {
364+
type: string;
365+
description: string;
366+
additionalProperties: boolean;
367+
};
368+
};
358369
};
359370
required: string[];
360371
additionalProperties: boolean;

0 commit comments

Comments
 (0)