fix(json-schema-2020-12-samples): skip anyOf and oneOf while merging schemas (#9853)

Refs #9198
This commit is contained in:
Oliwia Rogala
2024-04-23 15:27:22 +02:00
committed by GitHub
parent dee2ad0c77
commit f7373a0bc1
2 changed files with 46 additions and 4 deletions

View File

@@ -810,6 +810,36 @@ describe("sampleFromSchema", () => {
expect(sampleFromSchema(definition)).toEqual(expected)
})
it("returns array of samples for oneOf with objects", function () {
const definition = {
type: "array",
items: {
oneOf: [
{
type: "object",
properties: {
name: {
type: "string",
},
},
},
{
type: "object",
properties: {
id: {
type: "string",
},
},
},
],
},
}
const expected = [{ name: "string" }, { id: "string" }]
expect(sampleFromSchema(definition)).toStrictEqual(expected)
})
it("returns array of samples for anyOf type", () => {
const definition = {
type: "array",