joi-to-json 2.3.5 → 2.3.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/parsers/json.js +17 -1
- package/package.json +1 -1
package/lib/parsers/json.js
CHANGED
|
@@ -420,14 +420,30 @@ class JoiJsonSchemaParser {
|
|
|
420
420
|
}
|
|
421
421
|
|
|
422
422
|
if (joiSpec.whens) {
|
|
423
|
-
const condition = joiSpec.whens[0]
|
|
424
423
|
schema.oneOf = []
|
|
424
|
+
|
|
425
|
+
const condition = joiSpec.whens[0]
|
|
426
|
+
|
|
427
|
+
if (condition.switch) {
|
|
428
|
+
for (const switchCondition of condition.switch) {
|
|
429
|
+
if (switchCondition.then) {
|
|
430
|
+
schema.oneOf.push(this.parse(switchCondition.then, definitions, level + 1))
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
if (switchCondition.otherwise) {
|
|
434
|
+
schema.oneOf.push(this.parse(switchCondition.otherwise, definitions, level + 1))
|
|
435
|
+
}
|
|
436
|
+
}
|
|
437
|
+
}
|
|
438
|
+
|
|
425
439
|
if (condition.then) {
|
|
426
440
|
schema.oneOf.push(this.parse(condition.then, definitions, level + 1))
|
|
427
441
|
}
|
|
442
|
+
|
|
428
443
|
if (condition.otherwise) {
|
|
429
444
|
schema.oneOf.push(this.parse(condition.otherwise, definitions, level + 1))
|
|
430
445
|
}
|
|
446
|
+
|
|
431
447
|
delete schema.type
|
|
432
448
|
return
|
|
433
449
|
}
|