Skip to content

Commit

Permalink
Merge commit 'refs/pull/18/head' of https://github.com/hackolade/Avro
Browse files Browse the repository at this point in the history
primitive types definitions handling
  • Loading branch information
pdesmarets committed Jan 20, 2021
2 parents f0594dc + aac8a84 commit 9f4bffe
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
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
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "Avro",
"version": "0.1.53",
"versionDate": "2021-01-15",
"version": "0.1.54",
"versionDate": "2021-01-20",
"author": "hackolade",
"engines": {
"hackolade": "3.3.2",
Expand Down
4 changes: 3 additions & 1 deletion reverse_engineering/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ const handleType = (data, schema, parentSchema, definitions) => {
if (Array.isArray(data.type)) {
schema = handleMultipleTypes(data, schema, parentSchema, definitions);
} else if (typeof data.type === 'object') {
if (data.type.name) {
if (data.type.name && ['record', 'enum', 'fixed'].includes(data.type.type)) {
data.type = addDefinitions([data.type], definitions).pop();

handleRecursiveSchema(data, schema, {}, definitions);
Expand Down 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 9f4bffe

Please sign in to comment.