Skip to content

Commit

Permalink
Throw is responseKey is undefined
Browse files Browse the repository at this point in the history
  • Loading branch information
razor-x committed Oct 7, 2024
1 parent ac806fe commit b38b44c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
11 changes: 10 additions & 1 deletion src/lib/blueprint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -719,15 +719,24 @@ const createResponse = (
}

const description = okResponse.description ?? ''

if (!('x-response-key' in parsedOperation)) {
throw new Error(`Missing responseKey for ${path}`)
}

const responseKey = parsedOperation['x-response-key']

if (responseKey == null) {
if (responseKey === null) {
return {
responseType: 'void',
description,
}
}

if (responseKey == null) {
throw new Error(`Missing responseKey for ${path}`)
}

const content = 'content' in okResponse ? okResponse.content : null
if (typeof content !== 'object' || content === null) {
return {
Expand Down
2 changes: 1 addition & 1 deletion src/lib/openapi-schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export const OpenapiOperationSchema = z.object({
.optional(),
responses: ResponseSchema,
deprecated: z.boolean().default(false),
'x-response-key': z.string().nullable().default(null),
'x-response-key': z.string().nullable().optional(),
'x-title': z.string().default(''),
'x-undocumented': z.string().default(''),
'x-deprecated': z.string().default(''),
Expand Down

0 comments on commit b38b44c

Please sign in to comment.