mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2024-11-27 03:58:02 -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,
|
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));
|
||||||
|
},
|
||||||
|
],
|
||||||
);
|
);
|
||||||
|
|
Loading…
Reference in a new issue