Skip to content

Commit 77295a5

Browse files
committed
Fix complex extensions handling
1 parent 17eb346 commit 77295a5

File tree

3 files changed

+11
-4
lines changed

3 files changed

+11
-4
lines changed

forward_engineering/helpers/extensionsHelper.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,14 @@ function getExtensions(data = []) {
22
return data
33
.filter(filterExtensionsByPrefix)
44
.reduce((acc, { extensionPattern, extensionValue }) => {
5-
acc[extensionPattern] = extensionValue;
5+
let parsedValue;
6+
try {
7+
parsedValue = JSON.parse(extensionValue);
8+
} catch(err) {
9+
parsedValue = extensionValue;
10+
}
11+
acc[extensionPattern] = parsedValue;
12+
613
return acc;
714
}, {});
815

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "OpenAPI",
3-
"version": "0.1.9",
4-
"versionDate": "2019-12-20",
3+
"version": "0.1.10",
4+
"versionDate": "2019-12-23",
55
"author": "hackolade",
66
"engines": {
77
"hackolade": "3.3.0",

reverse_engineering/helpers/dataHelper.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ const getExtensions = (schema) => {
1111
const isExtension = (keyword) => keyword.substring(0, 2) === EXTENSION_SYMBOL;
1212
const getExtension = (keyword, data) => ({
1313
extensionPattern: keyword,
14-
extensionValue: data
14+
extensionValue: typeof data === 'object' ? JSON.stringify(data) : data
1515
});
1616

1717
return Object.keys(schema).reduce((accumulator, key) => {

0 commit comments

Comments
 (0)