Skip to content

Commit 75b6c3b

Browse files
authored
HCK-12071: convert string with enum to enum type with symbols on RE from JSON Schema (#195)
1 parent 26b778b commit 75b6c3b

1 file changed

Lines changed: 16 additions & 0 deletions

File tree

reverse_engineering/helpers/adaptJsonSchema.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@ const adaptType = field => {
2020
return adaptMultiple(field);
2121
}
2222

23+
if (type === 'string') {
24+
return handleString(field);
25+
}
26+
2327
if (type === 'number') {
2428
return handleNumber(field);
2529
}
@@ -253,4 +257,16 @@ const convertToValidAvroName = name => {
253257
return name.replace(/[^A-Za-z0-9_]/g, '_');
254258
};
255259

260+
const handleString = field => {
261+
if (Array.isArray(field.enum) && field.enum.length > 0) {
262+
return {
263+
...field,
264+
type: 'enum',
265+
symbols: field.enum,
266+
};
267+
}
268+
269+
return field;
270+
};
271+
256272
module.exports = { adaptJsonSchema, adaptJsonSchemaName };

0 commit comments

Comments
 (0)