Skip to content

Commit

Permalink
fix(): fix inheritance issue (missing properties with plugin)
Browse files Browse the repository at this point in the history
  • Loading branch information
kamilmysliwiec committed Jan 28, 2020
1 parent 3f865ec commit 884bd42
Showing 1 changed file with 18 additions and 11 deletions.
29 changes: 18 additions & 11 deletions lib/services/model-properties-accessor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,23 @@ export class ModelPropertiesAccessor {
}

applyMetadataFactory(prototype: Type<unknown>) {
if (!prototype.constructor) {
return;
}
if (!prototype.constructor[METADATA_FACTORY_NAME]) {
return;
}
const metadata = prototype.constructor[METADATA_FACTORY_NAME]();
const properties = Object.keys(metadata);
properties.forEach(key => {
createApiPropertyDecorator(metadata[key], false)(prototype, key);
});
const classPrototype = prototype;
do {
if (!prototype.constructor) {
return;
}
if (!prototype.constructor[METADATA_FACTORY_NAME]) {
continue;
}
const metadata = prototype.constructor[METADATA_FACTORY_NAME]();
const properties = Object.keys(metadata);
properties.forEach(key => {
createApiPropertyDecorator(metadata[key], false)(classPrototype, key);
});
} while (
(prototype = Reflect.getPrototypeOf(prototype) as Type<any>) &&
prototype !== Object.prototype &&
prototype
);
}
}

1 comment on commit 884bd42

@cjancsar
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where are the tests for this?

Please sign in to comment.