Skip to content

Commit 19fc49b

Browse files
committed
- Small fix for anyOf without a "type": "object" property
1 parent aa82bc9 commit 19fc49b

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "openapi-typescript-codegen",
3-
"version": "0.4.6",
3+
"version": "0.4.7",
44
"description": "NodeJS library that generates Typescript or Javascript clients based on the OpenAPI specification.",
55
"author": "Ferdi Koomen",
66
"homepage": "https://github.com/ferdikoomen/openapi-typescript-codegen",

src/openApi/v2/parser/getModel.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,12 +120,12 @@ export function getModel(openApi: OpenApi, definition: OpenApiSchema, isDefiniti
120120
}
121121
}
122122

123-
if (definition.type === 'object') {
123+
if (definition.type === 'object' || definition.allOf) {
124124
model.export = 'interface';
125125
model.type = PrimaryType.OBJECT;
126126
model.base = PrimaryType.OBJECT;
127127

128-
if (definition.allOf) {
128+
if (definition.allOf && definition.allOf.length) {
129129
definition.allOf.forEach(parent => {
130130
if (parent.$ref) {
131131
const parentRef = getType(parent.$ref);

src/openApi/v3/parser/getModel.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,13 +143,13 @@ export function getModel(openApi: OpenApi, definition: OpenApiSchema, isDefiniti
143143
return model;
144144
}
145145

146-
if (definition.type === 'object') {
146+
if (definition.type === 'object' || definition.allOf) {
147147
model.export = 'interface';
148148
model.type = PrimaryType.OBJECT;
149149
model.base = PrimaryType.OBJECT;
150150
model.default = getModelDefault(definition, model);
151151

152-
if (definition.allOf) {
152+
if (definition.allOf && definition.allOf.length) {
153153
definition.allOf.forEach(parent => {
154154
if (parent.$ref) {
155155
const parentRef = getType(parent.$ref);

0 commit comments

Comments
 (0)