joi-to-json
Advanced tools
Comparing version 4.2.0 to 4.2.1
@@ -124,3 +124,5 @@ /* eslint no-use-before-define: 'off' */ | ||
if (!_.isEmpty(joiSpec.shared)) { | ||
this.parse(joiSpec.shared[0], definitions, level) | ||
_.forEach(joiSpec.shared, (sharedSchema) => { | ||
this.parse(sharedSchema, definitions, level) | ||
}) | ||
} | ||
@@ -127,0 +129,0 @@ |
{ | ||
"name": "joi-to-json", | ||
"version": "4.2.0", | ||
"version": "4.2.1", | ||
"description": "joi to JSON / OpenAPI Schema Converter", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -49,5 +49,8 @@ # joi-to-json | ||
Only one API `parse` is available. It's signature is `parse(joiObj, type = 'json')` | ||
Only one API `parse` is available. | ||
Currently supported output types: | ||
Its signature is `parse(joiObj, type = 'json', definitions = {}, parserOptions = {})` | ||
### Output Type | ||
* `json` - Default. Stands for JSON Schema Draft 07 | ||
@@ -95,2 +98,11 @@ * `open-api` - Stands for OpenAPI 3.0 Schema - an extended subset of JSON Schema Specification Wright Draft 00 (aka Draft 5) | ||
### definitions | ||
This should be a JSON object containing all schemas referenced by the `joiObj` definition. It's useful if **Named Link** case is used but the referenced schemas are provided externally. This object uses the schema id as key and schema itself as value. | ||
### parserOptions | ||
* `includeSchemaDialect`: Default to be `false`. `true` makes the parsed schema containing `$schema` field automatically. Value of the `$schema` is default for different output JSON format if it's not provided in options together. | ||
* `logicalOpParser`: Refer to **Special Joi Operator Support** below for detail usage. | ||
## Features | ||
@@ -110,3 +122,3 @@ | ||
By default, the `If-Then-Else` approach is used if the output spec supports it. However, if the joi conditional expression (`alternatives` or `when`) is annotated using Meta `.meta({ 'if-style': true })`, the JSON schema conversion will use the Composition approach using `allOf` and/or `anyOf` instead. | ||
By default, the `If-Then-Else` approach is used if the output spec supports it. However, if the joi conditional expression (`alternatives` or `when`) is annotated using Meta `.meta({ 'if-style': false })`, the JSON schema conversion will use the Composition approach using `allOf` and/or `anyOf` instead. | ||
@@ -113,0 +125,0 @@ **Limitation**: Currently, if the joi condition definition is referring to another field, the `If-Then-Else` style output is not supported. Instead, it simply uses the `anyOf` composing the `then` and `otherwise` on the defined field. |
62888
1355
347