Configure swagger api docs
This commit is contained in:
parent
f9acd67d99
commit
9fa7224303
3 changed files with 29 additions and 9 deletions
|
|
@ -16,7 +16,7 @@ describe('AppController', () => {
|
||||||
|
|
||||||
describe('root', () => {
|
describe('root', () => {
|
||||||
it('should return "Hello World!"', () => {
|
it('should return "Hello World!"', () => {
|
||||||
expect(appController.getHello()).toBe('Hello World!');
|
expect(appController.sayHello()).toBe('Hello World!');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,8 @@ export class AppController {
|
||||||
constructor(private readonly appService: AppService) {}
|
constructor(private readonly appService: AppService) {}
|
||||||
|
|
||||||
@Get()
|
@Get()
|
||||||
getHello(): string {
|
sayHello(): string {
|
||||||
return this.appService.getHello();
|
return this.appService.getHello();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,27 @@
|
||||||
import { NestFactory } from '@nestjs/core';
|
import { NestFactory } from "@nestjs/core";
|
||||||
import { AppModule } from './app.module';
|
import { AppModule } from "./app.module";
|
||||||
|
import { SwaggerModule, DocumentBuilder } from "@nestjs/swagger";
|
||||||
|
|
||||||
async function bootstrap() {
|
async function bootstrap() {
|
||||||
const app = await NestFactory.create(AppModule);
|
const app = await NestFactory.create(AppModule);
|
||||||
|
|
||||||
|
const config = new DocumentBuilder()
|
||||||
|
.setTitle("Thom Werring - CV")
|
||||||
|
.setDescription("Westerstraat 83<br/>1521ZB, Wormerveer<br/><a href='tel:+31637650849'>+31 6 37 65 08 49</a>")
|
||||||
|
.addApiKey({
|
||||||
|
type: "apiKey",
|
||||||
|
name: "Authorization",
|
||||||
|
bearerFormat: "bearer",
|
||||||
|
}, "Credentials")
|
||||||
|
.setVersion("1.0.0a")
|
||||||
|
.build();
|
||||||
|
const document = SwaggerModule.createDocument(app, config, {
|
||||||
|
operationIdFactory: (controllerKey: string, methodKey: string) => (`${methodKey[0].toUpperCase()}${methodKey.substring(1)}`)
|
||||||
|
});
|
||||||
|
|
||||||
|
SwaggerModule.setup("/api", app, document);
|
||||||
|
|
||||||
await app.listen(3000);
|
await app.listen(3000);
|
||||||
}
|
}
|
||||||
|
|
||||||
bootstrap();
|
bootstrap();
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue