From a453344205fe498718be22daf7c41f0a0e640bb5 Mon Sep 17 00:00:00 2001 From: David Mehren Date: Thu, 29 Apr 2021 16:27:15 +0200 Subject: [PATCH] MarkdownBody: Handle error in getOwnPropertyDescriptor Signed-off-by: David Mehren --- src/api/utils/markdownbody-decorator.ts | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/api/utils/markdownbody-decorator.ts b/src/api/utils/markdownbody-decorator.ts index 4c55256a4..7614d3f30 100644 --- a/src/api/utils/markdownbody-decorator.ts +++ b/src/api/utils/markdownbody-decorator.ts @@ -42,15 +42,20 @@ export const MarkdownBody = createParamDecorator( }, [ (target, key): void => { - ApiConsumes('text/markdown')( + const ownPropertyDescriptor = Object.getOwnPropertyDescriptor( target, 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({ required: true, schema: { example: '# Markdown Body' }, - })(target, key, Object.getOwnPropertyDescriptor(target, key)); + })(target, key, ownPropertyDescriptor); }, ], );