We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
`import { NestFactory } from '@nestjs/core'; import { SwaggerModule, DocumentBuilder } from '@nestjs/swagger'; import { AppModule } from './app.module';
async function bootstrap() { const app = await NestFactory.create(AppModule);
// Configure Swagger const config = new DocumentBuilder() .setTitle('My API') .setDescription('The API description') .setVersion('1.0') .addTag('my-tag') .build(); const document = SwaggerModule.createDocument(app, config); SwaggerModule.setup('api', app, document);
await app.listen(3000); } bootstrap();`
4.在应用程序中,使用装饰器为 API 端点添加文档信息。这些装饰器包括 @ApiTags, @ApiOperation, @ApiParam, @ApiBody, @apiquery, @ApiResponse 等。这些装饰器可以在控制器和实体类中使用,以提供有关 API 的详细信息。 `import { Controller, Get, Param, } from '@nestjs/common'; import { ApiTags, ApiOperation, ApiParam } from '@nestjs/swagger';
@ApiTags('users') @controller('users') export class UsersController { @get(':id') @ApiOperation({ summary: 'Get user by ID' }) @ApiParam({ name: 'id', description: 'User ID' }) findOne(@param('id') id: string): string { return User with ID ${id}; } }`
User with ID ${id}
No response
The text was updated successfully, but these errors were encountered:
T8840
No branches or pull requests
任务内容 Task Details
`import { NestFactory } from '@nestjs/core';
import { SwaggerModule, DocumentBuilder } from '@nestjs/swagger';
import { AppModule } from './app.module';
async function bootstrap() {
const app = await NestFactory.create(AppModule);
// Configure Swagger
const config = new DocumentBuilder()
.setTitle('My API')
.setDescription('The API description')
.setVersion('1.0')
.addTag('my-tag')
.build();
const document = SwaggerModule.createDocument(app, config);
SwaggerModule.setup('api', app, document);
await app.listen(3000);
}
bootstrap();`
4.在应用程序中,使用装饰器为 API 端点添加文档信息。这些装饰器包括 @ApiTags, @ApiOperation, @ApiParam, @ApiBody, @apiquery, @ApiResponse 等。这些装饰器可以在控制器和实体类中使用,以提供有关 API 的详细信息。
`import {
Controller,
Get,
Param,
} from '@nestjs/common';
import { ApiTags, ApiOperation, ApiParam } from '@nestjs/swagger';
@ApiTags('users')
@controller('users')
export class UsersController {
@get(':id')
@ApiOperation({ summary: 'Get user by ID' })
@ApiParam({ name: 'id', description: 'User ID' })
findOne(@param('id') id: string): string {
return
User with ID ${id}
;}
}`
交付物 (选填) Deliverables
截止期限 (选填) Deadline (optional)
No response
检查清单 Checklist:
The text was updated successfully, but these errors were encountered: