From 844a29d726a487cae3ff4a92b2b8392ef0726d53 Mon Sep 17 00:00:00 2001 From: Kenneth Aasan Date: Wed, 13 Sep 2023 11:51:59 +0200 Subject: [PATCH] renames parentUnions to parents --- src/generators/AbstractGenerator.ts | 8 ++++---- src/generators/java/renderers/ClassRenderer.ts | 11 +++++++---- src/models/ConstrainedMetaModel.ts | 2 +- 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/src/generators/AbstractGenerator.ts b/src/generators/AbstractGenerator.ts index 01f9c20202..3f6da294e5 100644 --- a/src/generators/AbstractGenerator.ts +++ b/src/generators/AbstractGenerator.ts @@ -101,7 +101,7 @@ export abstract class AbstractGenerator< /** * Generates an array of ConstrainedMetaModel with its dependency manager from an InputMetaModel. - * It also adds parentUnions to the ConstrainedMetaModel's which can be used in renderers which needs to know what parents they belong to. + * It also adds parents to the ConstrainedMetaModel's which can be used in renderers which needs to know what parents they belong to. */ private getConstrainedModels(inputModel: InputMetaModel): Array<{ constrainedModel: ConstrainedMetaModel; @@ -154,11 +154,11 @@ export abstract class AbstractGenerator< m.type === constrainedModel.type ) ) { - if (!constrainedModel.options.parentUnions) { - constrainedModel.options.parentUnions = []; + if (!constrainedModel.options.parents) { + constrainedModel.options.parents = []; } - constrainedModel.options.parentUnions.push( + constrainedModel.options.parents.push( unionConstrainedModel.constrainedModel ); } diff --git a/src/generators/java/renderers/ClassRenderer.ts b/src/generators/java/renderers/ClassRenderer.ts index b311684c71..072408b3fd 100644 --- a/src/generators/java/renderers/ClassRenderer.ts +++ b/src/generators/java/renderers/ClassRenderer.ts @@ -100,13 +100,16 @@ ${this.indent(this.renderBlock(content, 2))} private getParentUnions(): ConstrainedUnionModel[] | undefined { const parentUnions: ConstrainedUnionModel[] = []; - if (!this.model.options.parentUnions) { + if (!this.model.options.parents) { return undefined; } - for (const unionModel of this.model.options.parentUnions) { - if (!unionIncludesBuiltInTypes(unionModel)) { - parentUnions.push(unionModel); + for (const model of this.model.options.parents) { + if ( + model instanceof ConstrainedUnionModel && + !unionIncludesBuiltInTypes(model) + ) { + parentUnions.push(model); } } diff --git a/src/models/ConstrainedMetaModel.ts b/src/models/ConstrainedMetaModel.ts index 3374971dac..767e562eea 100644 --- a/src/models/ConstrainedMetaModel.ts +++ b/src/models/ConstrainedMetaModel.ts @@ -19,7 +19,7 @@ export interface ConstrainedMetaModelOptionsDiscriminator export class ConstrainedMetaModelOptions extends MetaModelOptions { const?: ConstrainedMetaModelOptionsConst; discriminator?: ConstrainedMetaModelOptionsDiscriminator; - parentUnions?: ConstrainedUnionModel[]; + parents?: ConstrainedMetaModel[]; } export abstract class ConstrainedMetaModel extends MetaModel {