Skip to content

Commit 404db56

Browse files
committed
format
1 parent 101da06 commit 404db56

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

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

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -668,17 +668,21 @@ function transformSchemaObjectCore(schemaObject: SchemaObject, options: Transfor
668668
schemaObject.additionalProperties === true ||
669669
(typeof schemaObject.additionalProperties === "object" &&
670670
Object.keys(schemaObject.additionalProperties).length === 0);
671+
const patternProperties = hasKey(schemaObject, "patternProperties") ? schemaObject.patternProperties : undefined;
671672
const hasExplicitPatternProperties =
672-
typeof schemaObject.patternProperties === "object" && Object.keys(schemaObject.patternProperties).length;
673+
typeof patternProperties === "object" && patternProperties !== null && Object.keys(patternProperties).length > 0;
673674
const stringIndexTypes = [];
674675
if (hasExplicitAdditionalProperties) {
675676
stringIndexTypes.push(transformSchemaObject(schemaObject.additionalProperties as SchemaObject, options, true));
676677
}
677678
if (hasImplicitAdditionalProperties || (!schemaObject.additionalProperties && options.ctx.additionalProperties)) {
678679
stringIndexTypes.push(UNKNOWN);
679680
}
680-
if (hasExplicitPatternProperties) {
681-
for (const [_, v] of getEntries(schemaObject.patternProperties ?? {}, options.ctx)) {
681+
if (hasExplicitPatternProperties && patternProperties && typeof patternProperties === "object") {
682+
for (const [_, v] of getEntries(
683+
patternProperties as Record<string, SchemaObject | ReferenceObject>,
684+
options.ctx,
685+
)) {
682686
stringIndexTypes.push(transformSchemaObject(v, options));
683687
}
684688
}

0 commit comments

Comments
 (0)