Commit 7a749a58 authored by nanahira's avatar nanahira

add swagger ui

parent 48b4ee09
This diff is collapsed.
......@@ -13,12 +13,24 @@ import {
CxcyReturnMessage,
CxcyReturnMessageLike,
} from './messages/CxcyReturnMessage';
import {
ApiBadRequestResponse,
ApiHeader,
ApiInternalServerErrorResponse,
ApiOkResponse,
ApiQuery,
} from '@nestjs/swagger';
@Controller('api')
export class AppController {
constructor(private readonly appService: AppService) {}
@Get('user/report.pdf')
@ApiHeader({ name: 'Authorization', description: '用户 token' })
@ApiQuery({ name: 'request_id', description: '请求 id,直接返回。' })
@ApiOkResponse({ description: '成功,会直接提供文件下载。' })
@ApiBadRequestResponse({ description: '用户不存在或者没有登录。' })
@ApiInternalServerErrorResponse({ description: '报告生成过程中出现问题。' })
async getPdf(
@Headers('Authorization') userToken: string,
@Query('request_id') requestId: string,
......
......@@ -71,7 +71,7 @@ export class AppService {
{
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
launch_options: { args: ['--no-sandbox', '--disable-setuid-sandbox'] },
launch_options: { args: ['--no-sandbox'] },
},
);
return content;
......
import { NestFactory } from '@nestjs/core';
import { AppModule } from './app.module';
import { DocumentBuilder, SwaggerModule } from '@nestjs/swagger';
async function bootstrap() {
const app = await NestFactory.create(AppModule);
app.enableCors();
const documentConfig = new DocumentBuilder()
.setTitle('cxcy-scoresheet')
.setDescription('创新创业报告生成模块')
.setVersion('1.0')
.build();
const document = SwaggerModule.createDocument(app, documentConfig);
SwaggerModule.setup('docs', app, document);
await app.listen(3000);
}
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