- Small fix for anyOf without a "type": "object" property

This commit is contained in:
Ferdi Koomen 2020-07-15 23:42:40 +02:00
parent aa82bc97ba
commit 19fc49b590
3 changed files with 5 additions and 5 deletions

View File

@ -1,6 +1,6 @@
{
"name": "openapi-typescript-codegen",
"version": "0.4.6",
"version": "0.4.7",
"description": "NodeJS library that generates Typescript or Javascript clients based on the OpenAPI specification.",
"author": "Ferdi Koomen",
"homepage": "https://github.com/ferdikoomen/openapi-typescript-codegen",

View File

@ -120,12 +120,12 @@ export function getModel(openApi: OpenApi, definition: OpenApiSchema, isDefiniti
}
}
if (definition.type === 'object') {
if (definition.type === 'object' || definition.allOf) {
model.export = 'interface';
model.type = PrimaryType.OBJECT;
model.base = PrimaryType.OBJECT;
if (definition.allOf) {
if (definition.allOf && definition.allOf.length) {
definition.allOf.forEach(parent => {
if (parent.$ref) {
const parentRef = getType(parent.$ref);

View File

@ -143,13 +143,13 @@ export function getModel(openApi: OpenApi, definition: OpenApiSchema, isDefiniti
return model;
}
if (definition.type === 'object') {
if (definition.type === 'object' || definition.allOf) {
model.export = 'interface';
model.type = PrimaryType.OBJECT;
model.base = PrimaryType.OBJECT;
model.default = getModelDefault(definition, model);
if (definition.allOf) {
if (definition.allOf && definition.allOf.length) {
definition.allOf.forEach(parent => {
if (parent.$ref) {
const parentRef = getType(parent.$ref);