Skip to content

Commit 7b36358

Browse files
committed
fix: schema.content might be omitted
references openapi-ts#369
1 parent 69f0628 commit 7b36358

File tree

3 files changed

+3
-3
lines changed

3 files changed

+3
-3
lines changed

packages/openapi-typescript/src/transform/header-object.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export default function transformHeaderObject(headerObject: HeaderObject, option
1717

1818
if (headerObject.content) {
1919
const type: ts.TypeElement[] = [];
20-
for (const [contentType, mediaTypeObject] of getEntries(headerObject.content, options.ctx)) {
20+
for (const [contentType, mediaTypeObject] of getEntries(headerObject.content ?? {}, options.ctx)) {
2121
const nextPath = `${options.path ?? "#"}/${escapePointer(contentType)}`;
2222
const mediaType =
2323
"$ref" in mediaTypeObject

packages/openapi-typescript/src/transform/request-body-object.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ export default function transformRequestBodyObject(
1414
options: TransformNodeOptions,
1515
): ts.TypeNode {
1616
const type: ts.TypeElement[] = [];
17-
for (const [contentType, mediaTypeObject] of getEntries(requestBodyObject.content, options.ctx)) {
17+
for (const [contentType, mediaTypeObject] of getEntries(requestBodyObject.content ?? {}, options.ctx)) {
1818
const nextPath = createRef([options.path, contentType]);
1919
const mediaType =
2020
"$ref" in mediaTypeObject

packages/openapi-typescript/src/transform/response-object.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ export default function transformResponseObject(
7474
// content
7575
const contentObject: ts.TypeElement[] = [];
7676
if (responseObject.content) {
77-
for (const [contentType, mediaTypeObject] of getEntries(responseObject.content, options.ctx)) {
77+
for (const [contentType, mediaTypeObject] of getEntries(responseObject.content ?? {}, options.ctx)) {
7878
const property = ts.factory.createPropertySignature(
7979
/* modifiers */ tsModifiers({ readonly: options.ctx.immutable }),
8080
/* name */ tsPropertyIndex(contentType),

0 commit comments

Comments
 (0)