Skip to content

Commit 322e194

Browse files
committed
fix(serverless-openapi): handle optional response correctly
1 parent c3f8d52 commit 322e194

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

packages/serverless-openapi/src/lib/generator.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -212,11 +212,17 @@ export class Generator {
212212
}
213213

214214
private handleResponses(
215-
responseSchemas: { [key: string]: { 'application/json': Schema } },
215+
responseSchemas:
216+
| { [key: string]: { 'application/json': Schema } }
217+
| undefined,
216218
openApi: OpenAPIV3.Document
217-
): OpenAPIV3.ResponsesObject {
219+
): OpenAPIV3.ResponsesObject | undefined {
218220
const responses: OpenAPIV3.ResponsesObject = {};
219221

222+
if (!responseSchemas) {
223+
return undefined;
224+
}
225+
220226
for (const code of Object.keys(responseSchemas)) {
221227
const schemaJSON = responseSchemas[code]['application/json'];
222228
responses[code] = {

0 commit comments

Comments
 (0)