目前,我在所有方法之上使用 @ApiExcludeEndpoint() ### 来隐藏 swagger-ui 中的端点,如下所示:
import { Controller, Get, Query, Param } from '@nestjs/common';
import { ResourceService } from './resource.service';
import { Auth } from 'src/auth/auth.decorator';
import {
ApiTags,
ApiSecurity,
ApiOkResponse,
ApiForbiddenResponse,
ApiCreatedResponse,
ApiExcludeEndpoint
} from '@nestjs/swagger';
@Controller()
@ApiTags('Resources')
@ApiSecurity('apiKey')
export class ResourceController {
constructor(private readonly resourceService: ResourceService) {}
@Get('get_url')
@ApiExcludeEndpoint()
@Get()
@ApiOkResponse({
description: 'Resources list has succesfully been returned',
})
@ApiForbiddenResponse({ description: 'You are not allowed' })
@Auth(...common_privileges)
findAll(@Query() query: any): any {
......
}
@Get('get_url/:id')
@ApiExcludeEndpoint()
@ApiOkResponse({ description: 'Resource has succesfully been returned' })
@ApiForbiddenResponse({ description: 'You are not allowed' })
@Auth(...common_privileges)
findById(@Param('id') id: string, @Query() query: any): any {
......
}
}
我需要知道有没有办法使用单个装饰器隐藏控制器中的所有端点,我检查了一些文件说要使用 @ApiIgnore() 和 @Hidden() 但我在nestjs中找不到那些-昂首阔步。请对此发表评论