Skip to content

Commit 264a4f2

Browse files
author
Marc-Andre Giroux
authored
Fix example generation for "any" schema types (github#21290)
1 parent f5281f6 commit 264a4f2

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

script/rest/utils/create-code-samples.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,7 @@ function getExampleParamValue(name, schema) {
158158
// TODO: figure out the right behavior here
159159
if (schema.oneOf && schema.oneOf[0].type) return getExampleParamValue(name, schema.oneOf[0])
160160
if (schema.anyOf && schema.anyOf[0].type) return getExampleParamValue(name, schema.anyOf[0])
161+
if (!schema.type) return 'any'
161162

162163
switch (schema.type) {
163164
case 'string':
@@ -173,5 +174,6 @@ function getExampleParamValue(name, schema) {
173174
case 'array':
174175
return [getExampleParamValue(name, schema.items)]
175176
}
177+
176178
throw new Error(`Unknown data type in schema:, ${JSON.stringify(schema, null, 2)}`)
177179
}

0 commit comments

Comments
 (0)