Skip to content

Commit dd38fbc

Browse files
committed
Don't emit additional properties when the node does not have a type but does have Any/One/All Of.
1 parent 54c10d0 commit dd38fbc

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/transform/schema.ts

+6-3
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,9 @@ export function transformSchemaObj(node: any, options: Options): string {
137137
let additionalProperties: string | undefined;
138138
if (node.additionalProperties || (node.additionalProperties === undefined && options.version === 3)) {
139139
if ((node.additionalProperties ?? true) === true || Object.keys(node.additionalProperties).length === 0) {
140-
additionalProperties = `{ ${readonly}[key: string]: unknown }`;
140+
if (!(node.type == null && isAnyOfOrOneOfOrAllOf)) {
141+
additionalProperties = `{ ${readonly}[key: string]: unknown }`;
142+
}
141143
} else if (typeof node.additionalProperties === "object") {
142144
const oneOf: any[] | undefined = (node.additionalProperties as any).oneOf || undefined; // TypeScript does a really bad job at inference here, so we enforce a type
143145
const anyOf: any[] | undefined = (node.additionalProperties as any).anyOf || undefined; // "
@@ -146,8 +148,9 @@ export function transformSchemaObj(node: any, options: Options): string {
146148
} else if (anyOf) {
147149
additionalProperties = `{ ${readonly}[key: string]: ${transformAnyOf(anyOf, options)}; }`;
148150
} else {
149-
additionalProperties = `{ ${readonly}[key: string]: ${transformSchemaObj(node.additionalProperties, options) || "any"
150-
}; }`;
151+
additionalProperties = `{ ${readonly}[key: string]: ${
152+
transformSchemaObj(node.additionalProperties, options) || "any"
153+
}; }`;
151154
}
152155
}
153156
}

0 commit comments

Comments
 (0)