Skip to content

Commit

Permalink
feat: adds java interfaces when using allof
Browse files Browse the repository at this point in the history
  • Loading branch information
kennethaasan committed Nov 10, 2023
1 parent 145fcf6 commit 703336d
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
4 changes: 2 additions & 2 deletions src/helpers/CommonModelToMetaModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -514,10 +514,10 @@ export function convertToObjectModel(
metaModel.properties[String(propertyName)] = propertyModel;
}

if (jsonSchemaModel.extend) {
if (jsonSchemaModel.extend?.length) {
metaModel.options.extend = [];

for (const [, extend] of Array.from(jsonSchemaModel.extend)) {
for (const extend of jsonSchemaModel.extend) {
metaModel.options.extend.push(
convertToMetaModel(extend, alreadySeenModels)
);
Expand Down
2 changes: 1 addition & 1 deletion src/helpers/ConstrainHelpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -460,7 +460,7 @@ function constrainObjectModel<
): ConstrainedObjectModel {
const options = getConstrainedMetaModelOptions(context.metaModel);

if (context.metaModel.options.extend) {
if (context.metaModel.options.extend?.length) {
options.extend = [];

for (const extend of context.metaModel.options.extend) {
Expand Down
14 changes: 7 additions & 7 deletions src/models/CommonModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export const defaultMergingOptions: MergingOptions = {
* Common internal representation for a model.
*/
export class CommonModel {
extend?: Map<string, CommonModel>;
extend?: CommonModel[];
originalInput?: any;
$id?: string;
type?: string | string[];
Expand Down Expand Up @@ -437,19 +437,19 @@ export class CommonModel {
);
return;
}
this.extend = this.extend ?? new Map<string, CommonModel>();
if (this.extend.has(extendedModel.$id)) {

if (
this.extend?.find((commonModel) => commonModel.$id === extendedModel.$id)
) {
Logger.info(
`${this.$id} model already extends model ${extendedModel.$id}.`,
this,
extendedModel
);
return;
}
this.extend.set(
extendedModel.$id,
CommonModel.toCommonModel(extendedModel)
);
this.extend = this.extend ?? [];
this.extend.push(extendedModel);
}

/**
Expand Down

0 comments on commit 703336d

Please sign in to comment.