mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2025-05-17 16:44:49 -04:00
Enable automatic OpenAPI spec generation.
NestJS can automatically generate an OpenAPI spec by analyzing controllers and used DTOs. This commit enables this feature. The API docs are served under /apidoc. Signed-off-by: David Mehren <git@herrmehren.de>
This commit is contained in:
parent
06c62cc422
commit
1906f44e74
4 changed files with 61 additions and 4 deletions
|
@ -1,9 +1,18 @@
|
|||
import { ValidationPipe } from '@nestjs/common';
|
||||
import { NestFactory } from '@nestjs/core';
|
||||
import { DocumentBuilder, SwaggerModule } from '@nestjs/swagger';
|
||||
import { AppModule } from './app.module';
|
||||
|
||||
async function bootstrap() {
|
||||
const app = await NestFactory.create(AppModule);
|
||||
|
||||
const swaggerOptions = new DocumentBuilder()
|
||||
.setTitle('HedgeDoc')
|
||||
.setVersion('2.0-dev')
|
||||
.build();
|
||||
const document = SwaggerModule.createDocument(app, swaggerOptions);
|
||||
SwaggerModule.setup('apidoc', app, document);
|
||||
|
||||
app.useGlobalPipes(
|
||||
new ValidationPipe({
|
||||
forbidUnknownValues: true,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue