Skip to content

Commit

Permalink
cyclosproject#31 fix model referenced in oneOf in path is ignored
Browse files Browse the repository at this point in the history
  • Loading branch information
remkoboschker committed Jul 30, 2019
1 parent 1836b60 commit 10b5ae8
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions lib/gen-type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ export abstract class GenType {
this.additionalDependencies = [...this._additionalDependencies];
}

protected isNullableType(schema: SchemaObject) {
return schema.oneOf && schema.oneOf.length === 1 && schema.nullable;
}

protected collectImports(schema: SchemaObject | ReferenceObject | undefined, additional?: true): void {
if (!schema) {
return;
Expand All @@ -55,6 +59,10 @@ export abstract class GenType {
schema = schema as SchemaObject;
(schema.allOf || []).forEach(i => this.collectImports(i, additional));
(schema.anyOf || []).forEach(i => this.collectImports(i, additional));
// Specific work-around for nullable types
if (this.isNullableType(schema)) {
this.collectImports((schema.oneOf as ReferenceObject[])[0], additional);
}
if (schema.items) {
this.collectImports(schema.items, additional);
}
Expand Down

0 comments on commit 10b5ae8

Please sign in to comment.