Merge pull request #708 from hedgedoc/feat/swagger-markdown-body

MarkdownBody: Register swagger metadata
This commit is contained in:
David Mehren 2021-01-10 19:29:57 +01:00 committed by GitHub
commit 432ebe1386
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -10,6 +10,7 @@ import {
ExecutionContext, ExecutionContext,
InternalServerErrorException, InternalServerErrorException,
} from '@nestjs/common'; } from '@nestjs/common';
import { ApiBody, ApiConsumes } from '@nestjs/swagger';
import * as getRawBody from 'raw-body'; import * as getRawBody from 'raw-body';
/** /**
@ -37,4 +38,17 @@ export const MarkdownBody = createParamDecorator(
); );
} }
}, },
[
(target, key) => {
ApiConsumes('text/markdown')(
target,
key,
Object.getOwnPropertyDescriptor(target, key),
);
ApiBody({
required: true,
schema: { example: '# Markdown Body' },
})(target, key, Object.getOwnPropertyDescriptor(target, key));
},
],
); );