Skip to content

Commit

Permalink
RE: fix handling array items with references
Browse files Browse the repository at this point in the history
  • Loading branch information
mtseluiko committed Jan 20, 2021
1 parent 271f11e commit aac8a84
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
6 changes: 5 additions & 1 deletion forward_engineering/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -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];
}
}
};

Expand Down
2 changes: 2 additions & 0 deletions reverse_engineering/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit aac8a84

Please sign in to comment.