Skip to content

Commit

Permalink
fix(serverless-openapi): handle optional response correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
Nightapes committed Feb 6, 2022
1 parent c3f8d52 commit 322e194
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions packages/serverless-openapi/src/lib/generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -212,11 +212,17 @@ export class Generator {
}

private handleResponses(
responseSchemas: { [key: string]: { 'application/json': Schema } },
responseSchemas:
| { [key: string]: { 'application/json': Schema } }
| undefined,
openApi: OpenAPIV3.Document
): OpenAPIV3.ResponsesObject {
): OpenAPIV3.ResponsesObject | undefined {
const responses: OpenAPIV3.ResponsesObject = {};

if (!responseSchemas) {
return undefined;
}

for (const code of Object.keys(responseSchemas)) {
const schemaJSON = responseSchemas[code]['application/json'];
responses[code] = {
Expand Down

0 comments on commit 322e194

Please sign in to comment.