joi-to-json
Advanced tools
Comparing version
@@ -423,10 +423,26 @@ /* eslint no-use-before-define: 'off' */ | ||
if (joiSpec.whens) { | ||
schema.oneOf = [] | ||
const condition = joiSpec.whens[0] | ||
schema.oneOf = [] | ||
if (condition.switch) { | ||
for (const switchCondition of condition.switch) { | ||
if (switchCondition.then) { | ||
schema.oneOf.push(this.parse(switchCondition.then, definitions, level + 1)) | ||
} | ||
if (switchCondition.otherwise) { | ||
schema.oneOf.push(this.parse(switchCondition.otherwise, definitions, level + 1)) | ||
} | ||
} | ||
} | ||
if (condition.then) { | ||
schema.oneOf.push(this.parse(condition.then, definitions, level + 1)) | ||
} | ||
if (condition.otherwise) { | ||
schema.oneOf.push(this.parse(condition.otherwise, definitions, level + 1)) | ||
} | ||
delete schema.type | ||
@@ -433,0 +449,0 @@ return |
{ | ||
"name": "joi-to-json", | ||
"version": "2.3.5", | ||
"version": "2.3.6", | ||
"description": "joi to JSON / OpenAPI Schema Converter", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
32583
1.24%853
1.19%