fix(json-schema-2020-12-samples): fix examples for nullable primitive types defined as list of types (#10390)

This commit is contained in:
ctyar
2025-04-03 07:12:42 +01:00
committed by GitHub
parent ac4b549bfd
commit d375f50914
2 changed files with 18 additions and 1 deletions

View File

@@ -67,7 +67,10 @@ export const foldType = (type) => {
} else if (type.includes("object")) {
return "object"
} else {
const pickedType = randomPick(type)
const notNullTypes = type.filter((t) => t !== "null")
const pickedType = randomPick(
notNullTypes.length > 0 ? notNullTypes : type
)
if (ALL_TYPES.includes(pickedType)) {
return pickedType
}