Skip to content

Commit 814c96b

Browse files
committed
test: schema with properties and oneOf properties
1 parent e382efa commit 814c96b

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

tests/schema.test.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,23 @@ describe("SchemaObject", () => {
173173
})
174174
).toBe(`{ [key: string]: (string) | (number) | (boolean); }`);
175175
});
176+
177+
// https://www.jsonschemavalidator.net/s/fOyR2UtQ
178+
it("properties + oneOf", () => {
179+
expect(
180+
transform({
181+
properties: {
182+
a: {
183+
type: "string",
184+
},
185+
},
186+
anyOf: [
187+
{ properties: { b: { type: "string" } }, required: ["b"] },
188+
{ properties: { c: { type: "string" } }, required: ["c"] },
189+
],
190+
})
191+
).toBe(`{"a"?: string;} & (Partial<{"b": string;}>) & (Partial<{"c": string;}>)`);
192+
});
176193
});
177194

178195
describe("comments", () => {

0 commit comments

Comments
 (0)