Skip to content

Commit 8c40b8f

Browse files
committed
Fix bugs in array blank data generator
1 parent e4b5a46 commit 8c40b8f

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

src/data.js

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -79,12 +79,12 @@ export function getBlankArray(schema, getRef) {
7979
let type = normalizeKeyword(schema.items.type);
8080

8181
if (!type) {
82-
if (schema.items.hasOwnProperty['oneOf'])
83-
type = schema.items.oneOf[0];
84-
else if (schema.items.hasOwnProperty['anyOf'])
85-
type = schema.items.anyOf[0];
86-
else if (schema.items.hasOwnProperty['allOf'])
87-
type = schema.items.allOf[0];
82+
if (Array.isArray(schema.items['oneOf']))
83+
type = getSchemaType(schema.items.oneOf[0]);
84+
else if (Array.isArray(schema.items['anyOf']))
85+
type = getSchemaType(schema.items.anyOf[0]);
86+
else if (Array.isArray(schema.items['allOf']))
87+
type = getSchemaType(schema.items.allOf[0]);
8888
}
8989

9090
if (type === 'array') {
@@ -95,6 +95,14 @@ export function getBlankArray(schema, getRef) {
9595
while (items.length < minItems)
9696
items.push(getBlankObject(schema.items, getRef));
9797
return items;
98+
} else if (type === 'oneOf') {
99+
while (items.length < minItems)
100+
items.push(getBlankOneOf(schema.items, getRef));
101+
return items;
102+
} else if (type === 'anyOf') {
103+
while (items.length < minItems)
104+
items.push(getBlankOneOf(schema.items, getRef));
105+
return items;
98106
}
99107

100108
if (schema.items.widget === 'multiselect')

0 commit comments

Comments
 (0)