MarkdownBody: Handle error in getOwnPropertyDescriptor

Signed-off-by: David Mehren <git@herrmehren.de>
This commit is contained in:
David Mehren 2021-04-29 16:27:15 +02:00
parent 4959be739a
commit a453344205
No known key found for this signature in database
GPG key ID: 185982BA4C42B7C3

View file

@ -42,15 +42,20 @@ export const MarkdownBody = createParamDecorator(
}, },
[ [
(target, key): void => { (target, key): void => {
ApiConsumes('text/markdown')( const ownPropertyDescriptor = Object.getOwnPropertyDescriptor(
target, target,
key, key,
Object.getOwnPropertyDescriptor(target, key),
); );
if (!ownPropertyDescriptor) {
throw new Error(
`Could not get property descriptor for target ${target.toString()} and key ${key.toString()}`,
);
}
ApiConsumes('text/markdown')(target, key, ownPropertyDescriptor);
ApiBody({ ApiBody({
required: true, required: true,
schema: { example: '# Markdown Body' }, schema: { example: '# Markdown Body' },
})(target, key, Object.getOwnPropertyDescriptor(target, key)); })(target, key, ownPropertyDescriptor);
}, },
], ],
); );