openapi-typescript-codegen
Advanced tools
Comparing version
@@ -109,2 +109,20 @@ "use strict"; | ||
} | ||
if (definition.anyOf && definition.anyOf.length) { | ||
model.export = 'generic'; | ||
const compositionTypes = definition.anyOf.filter(type => type.$ref).map(type => getType_1.getType(type.$ref)); | ||
const composition = compositionTypes.map(type => type.type).join(' | '); | ||
model.imports.push(...compositionTypes.map(type => type.base)); | ||
model.type = composition; | ||
model.base = composition; | ||
return model; | ||
} | ||
if (definition.oneOf && definition.oneOf.length) { | ||
model.export = 'generic'; | ||
const compositionTypes = definition.oneOf.filter(type => type.$ref).map(type => getType_1.getType(type.$ref)); | ||
const composition = compositionTypes.map(type => type.type).join(' | '); | ||
model.imports.push(...compositionTypes.map(type => type.base)); | ||
model.type = composition; | ||
model.base = composition; | ||
return model; | ||
} | ||
if (definition.type === 'object') { | ||
@@ -111,0 +129,0 @@ model.export = 'interface'; |
{ | ||
"name": "openapi-typescript-codegen", | ||
"version": "0.1.12", | ||
"version": "0.1.13", | ||
"description": "NodeJS library that generates Typescript or Javascript clients based on the OpenAPI specification.", | ||
@@ -67,12 +67,12 @@ "author": "Ferdi Koomen", | ||
"@babel/preset-typescript": "7.8.3", | ||
"@types/jest": "24.0.25", | ||
"@types/jest": "24.9.1", | ||
"@types/js-yaml": "3.12.1", | ||
"@types/mkdirp": "0.5.2", | ||
"@types/node": "13.1.6", | ||
"@types/node": "13.5.0", | ||
"@types/rimraf": "2.0.3", | ||
"@typescript-eslint/eslint-plugin": "2.16.0", | ||
"@typescript-eslint/parser": "2.16.0", | ||
"@typescript-eslint/eslint-plugin": "2.17.0", | ||
"@typescript-eslint/parser": "2.17.0", | ||
"camelcase": "5.3.1", | ||
"chalk": "3.0.0", | ||
"codecov": "3.6.1", | ||
"codecov": "3.6.2", | ||
"commander": "4.1.0", | ||
@@ -85,4 +85,4 @@ "eslint": "6.8.0", | ||
"handlebars": "4.7.2", | ||
"jest": "24.9.0", | ||
"jest-cli": "24.9.0", | ||
"jest": "25.1.0", | ||
"jest-cli": "25.1.0", | ||
"js-yaml": "3.13.1", | ||
@@ -93,4 +93,4 @@ "mkdirp": "0.5.1", | ||
"rimraf": "3.0.0", | ||
"typescript": "3.7.4" | ||
"typescript": "3.7.5" | ||
} | ||
} |
161854
0.57%3572
0.51%