From aac8a840feea7256f6aa48f3acca1b8cb6c53845 Mon Sep 17 00:00:00 2001 From: Mikhail Tseluiko Date: Wed, 20 Jan 2021 11:39:51 +0200 Subject: [PATCH] RE: fix handling array items with references --- forward_engineering/api.js | 6 +++++- reverse_engineering/api.js | 2 ++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/forward_engineering/api.js b/forward_engineering/api.js index 2e158da..450d468 100644 --- a/forward_engineering/api.js +++ b/forward_engineering/api.js @@ -690,7 +690,11 @@ const handleItems = (schema, avroSchema, udt) => { }); avroSchema.items = getUniqueItemsInArray(items); if(avroSchema.items.length === 1) { - avroSchema.items = avroSchema.items[0]; + if (schema.items[0].$ref && !avroSchema.items[0].name) { + avroSchema.items = avroSchema.items[0].type; + } else { + avroSchema.items = avroSchema.items[0]; + } } }; diff --git a/reverse_engineering/api.js b/reverse_engineering/api.js index 6cd3860..f385084 100644 --- a/reverse_engineering/api.js +++ b/reverse_engineering/api.js @@ -452,6 +452,8 @@ const handleItems = (data, prop, schema, definitions) => { } else if (typeof items === 'object') { schema.items = {}; handleRecursiveSchema(items, schema.items, schema, definitions); + } else if (typeof items === 'string') { + schema.items = getType({}, data, items) } else { schema.items = { type: items