Skip to content

Commit

Permalink
Fixed issue with FE of multiple types inside choices
Browse files Browse the repository at this point in the history
  • Loading branch information
Vitalii4as committed Dec 20, 2021
1 parent 98515b5 commit 5adcbe5
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions forward_engineering/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -678,14 +678,17 @@ const handleChoice = (schema, choice, udt) => {
multipleField.type.push(newField);
} else if (Object(newField.type) === newField.type) {
newField.name = newField.name || field.name || fieldName;
multipleField.type = multipleField.type.concat([newField]);
const type = _.isArray(newField.type)
? _.map(newField.type, type => _.assign({}, newField, { type }))
: [newField];
multipleField.type = multipleField.type.concat(type);
} else if (Array.isArray(filedType)) {
multipleField.type = multipleField.type.concat(filedType);
} else {
multipleField.type = multipleField.type.concat([filedType]);
}

multipleField.type = _.uniq(multipleField.type);
multipleField.type = _.uniqBy(multipleField.type, type => (_.isObject(type) ? type.type : type));
if (multipleField.type.length === 1) {
multipleField.type = _.first(multipleField.type);
}
Expand Down

0 comments on commit 5adcbe5

Please sign in to comment.