Commit c336b2e5 authored by nanahira's avatar nanahira

add swagger

parent 600dd7e2
Pipeline #3291 passed with stages
in 1 minute and 35 seconds
#!/bin/bash #!/bin/bash
npm install --save \ npm install --save \
class-validator \
class-transformer \
@nestjs/swagger \
swagger-ui-express \
lodash \ lodash \
typeorm \ typeorm \
@nestjs/typeorm \ @nestjs/typeorm \
...@@ -11,3 +15,4 @@ npm install --save \ ...@@ -11,3 +15,4 @@ npm install --save \
npm install --save-dev \ npm install --save-dev \
@types/lodash @types/lodash
@types/express
import { NestFactory } from '@nestjs/core'; import { NestFactory } from '@nestjs/core';
import { SwaggerModule, DocumentBuilder } from '@nestjs/swagger';
import { AppModule } from './app.module'; import { AppModule } from './app.module';
async function bootstrap() { async function bootstrap() {
const app = await NestFactory.create(AppModule); const app = await NestFactory.create(AppModule);
app.enableCors(); app.enableCors();
const documentConfig = new DocumentBuilder()
.setTitle('app')
.setDescription('The app')
.setVersion('1.0')
.addTag('app-tag')
.build();
const document = SwaggerModule.createDocument(app, documentConfig);
SwaggerModule.setup('docs', app, document);
await app.listen(3000); await app.listen(3000);
} }
bootstrap(); bootstrap();
#!/bin/bash #!/bin/bash
npm install --save \ npm install --save \
class-validator \
class-transformer \
@nestjs/swagger \
swagger-ui-express \
lodash \ lodash \
typeorm \ typeorm \
@nestjs/typeorm \ @nestjs/typeorm \
...@@ -7,4 +11,5 @@ npm install --save \ ...@@ -7,4 +11,5 @@ npm install --save \
reflect-metadata reflect-metadata
npm install --save-dev \ npm install --save-dev \
@types/lodash @types/lodash \
@types/express
import { NestFactory } from '@nestjs/core'; import { NestFactory } from '@nestjs/core';
import { SwaggerModule, DocumentBuilder } from '@nestjs/swagger';
import { AppModule } from './app.module'; import { AppModule } from './app.module';
async function bootstrap() { async function bootstrap() {
const app = await NestFactory.create(AppModule); const app = await NestFactory.create(AppModule);
app.enableCors(); app.enableCors();
const documentConfig = new DocumentBuilder()
.setTitle('app')
.setDescription('The app')
.setVersion('1.0')
.addTag('app-tag')
.build();
const document = SwaggerModule.createDocument(app, documentConfig);
SwaggerModule.setup('docs', app, document);
await app.listen(3000); await app.listen(3000);
} }
bootstrap(); bootstrap();
import { NestFactory } from '@nestjs/core'; import { NestFactory } from '@nestjs/core';
import { SwaggerModule, DocumentBuilder } from '@nestjs/swagger';
import { AppModule } from './app.module'; import { AppModule } from './app.module';
async function bootstrap() { async function bootstrap() {
const app = await NestFactory.create(AppModule); const app = await NestFactory.create(AppModule);
app.enableCors(); app.enableCors();
const documentConfig = new DocumentBuilder()
.setTitle('app')
.setDescription('The app')
.setVersion('1.0')
.addTag('app-tag')
.build();
const document = SwaggerModule.createDocument(app, documentConfig);
SwaggerModule.setup('docs', app, document);
await app.listen(3000); await app.listen(3000);
} }
bootstrap(); bootstrap();
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment