Skip to content

Commit a9dece4

Browse files
committed
Handle null responses
1 parent e19a345 commit a9dece4

1 file changed

Lines changed: 8 additions & 4 deletions

File tree

src/lib/report.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -320,17 +320,21 @@ function processResponseKeys(endpoint: Endpoint, report: Report): void {
320320

321321
function getOpenapiResponseProperties(
322322
path: string,
323-
): Record<string, unknown> | undefined {
323+
): Record<string, unknown> | undefined | null {
324324
const openapiEndpointDef = openapi.paths[path as keyof typeof openapi.paths]
325325

326326
if (openapiEndpointDef == null) {
327327
// eslint-disable-next-line no-console
328328
console.warn(`OpenAPI definition not found for endpoint: ${path}`)
329-
return
329+
return null
330330
}
331331

332-
return openapiEndpointDef.post.responses['200']?.content['application/json']
333-
?.schema?.properties
332+
const res = openapiEndpointDef.post.responses['200']
333+
if ('content' in res) {
334+
return res.content['application/json']?.schema?.properties
335+
}
336+
337+
return null
334338
}
335339

336340
function processParameters(

0 commit comments

Comments
 (0)