Skip to content

Commit 5c0a07f

Browse files
committed
Merge branch 'master' into dependabot/npm_and_yarn/typescript-4.1.2
2 parents 390b916 + 3eb981c commit 5c0a07f

File tree

4 files changed

+27
-11
lines changed

4 files changed

+27
-11
lines changed

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,6 @@
6666
"handlebars": "4.7.6",
6767
"js-yaml": "3.14.0",
6868
"mkdirp": "1.0.4",
69-
"path": "0.12.7",
7069
"rimraf": "3.0.2"
7170
},
7271
"devDependencies": {

rollup.config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ module.exports = {
6565
'fs',
6666
'os',
6767
'util',
68+
'path',
6869
'http',
6970
'https',
7071
'handlebars/runtime',

src/openApi/v2/parser/getModelComposition.ts

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,19 @@ export function getModelComposition(openApi: OpenApi, definitions: OpenApiSchema
1515
};
1616

1717
const modes = definitions.map(definition => getModel(openApi, definition));
18-
modes.forEach(model => {
19-
composition.imports.push(...model.imports);
20-
composition.enums.push(...model.enums);
21-
composition.properties.push(model);
22-
});
18+
modes
19+
.filter(model => {
20+
const hasProperties = model.properties.length;
21+
const hasEnums = model.enums.length;
22+
const isObject = model.type === 'any';
23+
const isEmpty = isObject && !hasProperties && !hasEnums;
24+
return !isEmpty;
25+
})
26+
.forEach(model => {
27+
composition.imports.push(...model.imports);
28+
composition.enums.push(...model.enums);
29+
composition.properties.push(model);
30+
});
2331

2432
return composition;
2533
}

src/openApi/v3/parser/getModelComposition.ts

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,19 @@ export function getModelComposition(openApi: OpenApi, definitions: OpenApiSchema
1515
};
1616

1717
const modes = definitions.map(definition => getModel(openApi, definition));
18-
modes.forEach(model => {
19-
composition.imports.push(...model.imports);
20-
composition.enums.push(...model.enums);
21-
composition.properties.push(model);
22-
});
18+
modes
19+
.filter(model => {
20+
const hasProperties = model.properties.length;
21+
const hasEnums = model.enums.length;
22+
const isObject = model.type === 'any';
23+
const isEmpty = isObject && !hasProperties && !hasEnums;
24+
return !isEmpty;
25+
})
26+
.forEach(model => {
27+
composition.imports.push(...model.imports);
28+
composition.enums.push(...model.enums);
29+
composition.properties.push(model);
30+
});
2331

2432
return composition;
2533
}

0 commit comments

Comments
 (0)