From 5adcbe53ccdc99fbe3bd5cf2b875e8333cd6c5fb Mon Sep 17 00:00:00 2001 From: Vitalii Yarmus Date: Mon, 20 Dec 2021 15:00:14 +0200 Subject: [PATCH] Fixed issue with FE of multiple types inside choices --- forward_engineering/api.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/forward_engineering/api.js b/forward_engineering/api.js index 0caae3c..f8056b5 100644 --- a/forward_engineering/api.js +++ b/forward_engineering/api.js @@ -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); }