improve: support for oneOf and anyOf in array sample (#4136)

* Fixed oneOf and anyOf in array example

* Added tests for sampleFromSchema for array type

* Removed return example for array item
This commit is contained in:
Pavel Stefanov
2018-03-03 03:42:51 +03:00
committed by kyle
parent feef20dd67
commit b13b05e416
2 changed files with 175 additions and 0 deletions

View File

@@ -69,6 +69,14 @@ export const sampleFromSchema = (schema, config={}) => {
}
if(type === "array") {
if(Array.isArray(items.anyOf)) {
return items.anyOf.map(i => sampleFromSchema(i, config))
}
if(Array.isArray(items.oneOf)) {
return items.oneOf.map(i => sampleFromSchema(i, config))
}
return [ sampleFromSchema(items, config) ]
}