Skip to content

Commit

Permalink
fix: Boolean cannot represent a non boolean value
Browse files Browse the repository at this point in the history
  • Loading branch information
nodkz committed Jun 4, 2019
1 parent 4f7d288 commit e5dc33b
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/ElasticApiParser.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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';
Expand Down

0 comments on commit e5dc33b

Please sign in to comment.