Skip to content

Commit

Permalink
Fix enum field undefined issue
Browse files Browse the repository at this point in the history
  • Loading branch information
kenchen-cs committed Jun 16, 2022
1 parent a5f5c7f commit 6432afc
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions lib/parsers/json.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,14 +117,14 @@ class JoiJsonSchemaParser {

_getConst(fieldDefn) {
const enumList = fieldDefn[this.enumFieldName]
if (fieldDefn.flags && fieldDefn.flags.only && enumList.length === 1) {
if (fieldDefn.flags && fieldDefn.flags.only && _.size(enumList) === 1) {
return enumList[0]
}
}

_getEnum(fieldDefn) {
const enumList = fieldDefn[this.enumFieldName]
if (fieldDefn.flags && fieldDefn.flags.only && enumList.length > 1) {
if (fieldDefn.flags && fieldDefn.flags.only && _.size(enumList) > 1) {
return _.uniq(enumList)
}
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "joi-to-json",
"version": "2.3.4",
"version": "2.3.5",
"description": "joi to JSON / OpenAPI Schema Converter",
"main": "index.js",
"repository": {
Expand Down

0 comments on commit 6432afc

Please sign in to comment.