mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2024-11-23 10:16:32 -05:00
MarkdownBody: Register swagger metadata
As explained in https://github.com/nestjs/swagger/issues/32#issuecomment-716169471, it's possible to register swagger metadata in custom decorators by providing an array of `enhancers`. We now add metadata with the `MarkdownBody` decorator: The request needs a `body` with content-type `text/markdown`. Signed-off-by: David Mehren <git@herrmehren.de>
This commit is contained in:
parent
8d3406175b
commit
644d7a278a
1 changed files with 14 additions and 0 deletions
|
@ -10,6 +10,7 @@ import {
|
|||
ExecutionContext,
|
||||
InternalServerErrorException,
|
||||
} from '@nestjs/common';
|
||||
import { ApiBody, ApiConsumes } from '@nestjs/swagger';
|
||||
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));
|
||||
},
|
||||
],
|
||||
);
|
||||
|
|
Loading…
Reference in a new issue