How to use the @nestjs/swagger.ApiOperation function in @nestjs/swagger

To help you get started, we’ve selected a few @nestjs/swagger examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github devonfw / devon4node / Samples / my-thai-star / src / management / booking / booking.controller.ts View on Github external
@Roles(UserRole.Waiter)
  @ApiResponse({ status: HttpStatus.OK, type: BookingResponseVm })
  @ApiResponse({ status: HttpStatus.BAD_REQUEST, type: ApiException })
  @ApiOperation(GetOperationId('Booking', 'Search'))
  async getAll(@Body() filter: CustomFilter): Promise {
    try {
      return await this._service.findBookings(filter);
    } catch (e) {
      throw e;
    }
  }

  @Get('cancel/:token')
  @ApiResponse({ status: HttpStatus.OK, type: InvitationResponse })
  @ApiResponse({ status: HttpStatus.BAD_REQUEST, type: ApiException })
  @ApiOperation(GetOperationId('Booking', 'Cancel'))
  async cancelBooking(@Param('token') token: string): Promise {
    try {
      const booking = await this._service.findOne({ bookingToken: token });
      return await this._service.deleteById(booking.id);
    } catch (error) {
      return error;
    }
  }
}
github jmcdo29 / zeldaPlay / src / server / app / zeldaplay / character / character.controller.ts View on Github external
constructor(private readonly characterService: CharacterService) {}

  @Get()
  @ApiOperation({
    title: 'Get All Unassigned Characters',
    description:
      'Get all of the characters who do not belong to a user. ' +
      'These are returned and shown as an example for the user to get an idea of how the app works.'
  })
  @ApiOkResponse({ type: DbCharacterShort, isArray: true })
  getAll(): Observable {
    return this.characterService.getAll();
  }

  @Post('new/:userId')
  @ApiOperation({
    title: 'New Character',
    description:
      'Using the User id, create and assign a new character based on the incoming body'
  })
  @ApiImplicitBody({ name: 'character', type: CharacterDTO })
  @ApiImplicitParam({ name: 'userId', type: 'string', required: true })
  @UseGuards(AuthGuard)
  @ApiBearerAuth()
  @ApiOkResponse({ type: DbCharacter })
  newChar(
    @Param() params: UserIdParam,
    @Body('character', CharacterPipe) character: DbCharacter
  ): Observable {
    return this.characterService.newChar(character, params.userId);
  }
github xmlking / ngx-starter-kit / apps / api / src / app / notifications / subscription / subscription.controller.ts View on Github external
@ApiOperation({ summary: 'Find all Subscriptions. Admins only' })
  @ApiTags('Admin')
  @Roles(RolesEnum.ADMIN)
  @Get()
  async findAll(@Query() filter: FindSubscriptionsDto): Promise {
    return this.subscriptionService.findAll(filter);
  }

  @ApiOperation({ summary: 'find all user Subscriptions' })
  @Get('own')
  async findOwn(@Query() filter: FindOwnSubscriptionsDto, @CurrentUser() user): Promise {
    return this.subscriptionService.findOwn(filter, user);
  }

  @ApiOperation({ summary: 'Find by id. Admins only' })
  @ApiTags('Admin')
  @Roles(RolesEnum.ADMIN)
  @Get(':id')
  async findById(@Param('id') id: string): Promise {
    return super.findById(id);
  }

  @ApiOperation({ summary: 'Create new record' })
  @Post()
  async create(@Body() entity: CreateSubscriptionDto, @CurrentUser() user: User): Promise {
    const { total, items } = await this.subscriptionService.findAll(
      new FindSubscriptionsDto({ endpoint: entity.endpoint }),
    );
    if (total === 0) {
      return super.create({ ...entity, username: user.username });
    } else {
github xmlking / ngx-starter-kit / apps / api / src / app / project / project.controller.ts View on Github external
import { KubeContext } from './interfaces/kube-context';
import { KubernetesService } from './kubernetes/kubernetes.service';
import { Project } from './project.entity';
import { ProjectService } from './project.service';

@ApiOAuth2(['read'])
@ApiTags('Project')
@Controller('project')
export class ProjectController extends CrudController {
  private readonly logger = new Logger(ProjectController.name);

  constructor(private readonly projectService: ProjectService, private readonly kservice: KubernetesService) {
    super(projectService);
  }

  @ApiOperation({ summary: 'Find all Projects. Admins only' })
  @ApiTags('Admin')
  @Roles(RolesEnum.ADMIN)
  @Get()
  async findAll(@Query() filter: FindProjectsDto): Promise {
    return this.projectService.findAll(filter);
  }

  @ApiOperation({
    summary: 'Search all Projects. Admins only',
    description: 'Ref: https://github.com/rjlopezdev/typeorm-express-query-builder',
  })
  @ApiTags('Admin')
  @Roles(RolesEnum.ADMIN)
  @Get('/search')
  async searchAll(query: any): Promise {
    return this.projectService.searchAll(query);
github kuangshp / nestjs-mysql-api / src / core / user / user.controller.ts View on Github external
}

  @ApiOperation({
    title: '根据用户id删除用户',
    description: '可传递id或者uuid',
  })
  @ApiBearerAuth()
  @Delete('user/:id')
  @HttpCode(HttpStatus.OK)
  async destroyById(
    @Param('id', new ParseIdAndUuidPipe()) id: string,
  ): Promise {
    return await this.userService.destroyById(id);
  }

  @ApiOperation({
    title: '根据用户id修改当前用户是否可用',
    description: '可传递id或者uuid',
  })
  @ApiBearerAuth()
  @Post('change_status/:id')
  @HttpCode(HttpStatus.OK)
  async changeStatus(
    @Param('id', new ParseIdAndUuidPipe()) id: string,
  ): Promise {
    return await this.userService.changeStatus(id);
  }

  @ApiOperation({ title: '创建用户' })
  @ApiBearerAuth()
  @Post('user/add_user')
  @HttpCode(HttpStatus.CREATED)
github scalio / bazel-nx-example / apps / api / src / cats / cats.controller.ts View on Github external
constructor(private readonly catsService: CatsService) {}

  @Post()
  @ApiOperation({ title: 'Add cat' })
  async create(@Body() createCatDto: CreateCatDto) {
    return this.catsService.create(createCatDto);
  }

  @Get()
  @ApiOperation({ title: 'Get all cats' })
  async findAll(): Promise {
    return this.catsService.findAll();
  }

  @Get(':id')
  @ApiOperation({ title: 'Get cat by id' })
  async findOneById(@Param('id', ParseIntPipe) id: number) {
    return this.catsService.findOneById(id);
  }

  @ApiOperation({ title: 'Delete item' })
  @Delete(':id')
  @HttpCode(HttpStatus.NO_CONTENT)
  async delete(@Param('id', ParseIntPipe) id: number): Promise {
    await this.catsService.remove(id);
  }
}