joi-to-json
Advanced tools
Comparing version 2.3.3 to 2.3.4
@@ -118,5 +118,12 @@ /* eslint no-use-before-define: 'off' */ | ||
_getConst(fieldDefn) { | ||
const enumList = fieldDefn[this.enumFieldName] | ||
if (fieldDefn.flags && fieldDefn.flags.only && enumList.length === 1) { | ||
return enumList[0] | ||
} | ||
} | ||
_getEnum(fieldDefn) { | ||
const enumList = fieldDefn[this.enumFieldName] | ||
if (fieldDefn.flags && fieldDefn.flags.only && !_.isEmpty(enumList)) { | ||
if (fieldDefn.flags && fieldDefn.flags.only && enumList.length > 1) { | ||
return _.uniq(enumList) | ||
@@ -145,2 +152,3 @@ } | ||
this._setIfNotEmpty(fieldSchema, 'default', this._getDefaultValue(fieldDefn)) | ||
this._setIfNotEmpty(fieldSchema, 'const', this._getConst(fieldDefn)) | ||
this._setIfNotEmpty(fieldSchema, 'enum', this._getEnum(fieldDefn)) | ||
@@ -147,0 +155,0 @@ } |
@@ -56,2 +56,6 @@ const _ = require('lodash') | ||
if (fullSchema.const) { | ||
schema.enum = [fullSchema.const] | ||
} | ||
return schema | ||
@@ -58,0 +62,0 @@ } |
{ | ||
"name": "joi-to-json", | ||
"version": "2.3.3", | ||
"version": "2.3.4", | ||
"description": "joi to JSON / OpenAPI Schema Converter", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
32183
843