From e5dc33b2b2658bbb33553c786a52d909dc221500 Mon Sep 17 00:00:00 2001 From: nodkz Date: Tue, 4 Jun 2019 22:22:45 +0600 Subject: [PATCH] fix: Boolean cannot represent a non boolean value --- src/ElasticApiParser.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/ElasticApiParser.js b/src/ElasticApiParser.js index d51296d..3e7c36c 100644 --- a/src/ElasticApiParser.js +++ b/src/ElasticApiParser.js @@ -323,7 +323,7 @@ export default class ElasticApiParser { if (paramCfg.default) { result.defaultValue = paramCfg.default; - if (result.type === 'Float') { + if (result.type === 'Float' || result.type === 'Int') { const defaultNumber = Number(result.defaultValue); if (Number.isNaN(defaultNumber)) { // Handle broken data where default is not valid for the given type @@ -332,6 +332,9 @@ export default class ElasticApiParser { } else { result.defaultValue = defaultNumber; } + } else if (result.type === 'Boolean') { + const t = result.defaultValue; + result.defaultValue = t === 'true' || t === '1' || t === true; } } else if (fieldName === 'format') { result.defaultValue = 'json';