Fix example generation for "any" schema types (#21290)
This commit is contained in:
committed by
GitHub
parent
f5281f6454
commit
264a4f2fbc
@@ -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)}`)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user