1
0
mirror of synced 2025-12-21 10:57:10 -05:00

Fix example generation for "any" schema types (#21290)

This commit is contained in:
Marc-Andre Giroux
2021-09-09 14:02:53 -04:00
committed by GitHub
parent f5281f6454
commit 264a4f2fbc

View File

@@ -158,6 +158,7 @@ function getExampleParamValue(name, schema) {
// TODO: figure out the right behavior here
if (schema.oneOf && schema.oneOf[0].type) return getExampleParamValue(name, schema.oneOf[0])
if (schema.anyOf && schema.anyOf[0].type) return getExampleParamValue(name, schema.anyOf[0])
if (!schema.type) return 'any'
switch (schema.type) {
case 'string':
@@ -173,5 +174,6 @@ function getExampleParamValue(name, schema) {
case 'array':
return [getExampleParamValue(name, schema.items)]
}
throw new Error(`Unknown data type in schema:, ${JSON.stringify(schema, null, 2)}`)
}