How to use the @nestjs/swagger.ApiNotFoundResponse 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 jiayisheji / jianshu / libs / database / src / lib / crud.controller.ts View on Github external
@ApiUnauthorizedResponse({ description: 'Unauthorized' })
@ApiForbiddenResponse({ description: 'Forbidden.' })
export abstract class CrudController  {

  constructor(private readonly crudService: CrudRepositoryService) { }

  @ApiOperation({ title: 'find all' })
  @ApiOkResponse({ description: 'Found records' })
  @Get()
  public async findAll(@Query() filter: PaginationParams>): Promise>> {
    return this.crudService.paginator(filter);
  }

  @ApiOperation({ title: 'Find by id' })
  @ApiOkResponse({ description: 'Found one record' })
  @ApiNotFoundResponse({ description: 'Record not found' })
  @Get(':id')
  public async findById(@Param('id') id: string): Promise> {
    return this.crudService.findOne(id);
  }

  @ApiOperation({ title: 'Create new record' })
  @ApiCreatedResponse({ description: 'The record has been successfully created.' })
  @ApiBadRequestResponse({ description: 'Invalid input, The response body may contain clues as to what went wrong' })
  @HttpCode(HttpStatus.CREATED)
  @Post()
  public async create(@Body() entity: Partial): Promise> {
    return this.crudService.create(entity);
  }

  @ApiOperation({ title: 'Update an existing record' })
  @ApiCreatedResponse({ description: 'The record has been successfully edited.' })
github jiayisheji / jianshu / libs / database / src / lib / crud.controller.ts View on Github external
public async findById(@Param('id') id: string): Promise> {
    return this.crudService.findOne(id);
  }

  @ApiOperation({ title: 'Create new record' })
  @ApiCreatedResponse({ description: 'The record has been successfully created.' })
  @ApiBadRequestResponse({ description: 'Invalid input, The response body may contain clues as to what went wrong' })
  @HttpCode(HttpStatus.CREATED)
  @Post()
  public async create(@Body() entity: Partial): Promise> {
    return this.crudService.create(entity);
  }

  @ApiOperation({ title: 'Update an existing record' })
  @ApiCreatedResponse({ description: 'The record has been successfully edited.' })
  @ApiNotFoundResponse({ description: 'Record not found' })
  @ApiBadRequestResponse({ description: 'Invalid input, The response body may contain clues as to what went wrong' })
  @HttpCode(HttpStatus.CREATED)
  @Put(':id')
  public async update(@Param('id') id: string, @Body() entity: Partial>): Promise> {
    return this.crudService.update(id, entity);
  }

  @ApiOperation({ title: 'Delete record' })
  @ApiResponse({ status: HttpStatus.NO_CONTENT, description: 'The record has been successfully deleted' })
  @ApiNotFoundResponse({ description: 'Record not found' })
  @HttpCode(HttpStatus.NO_CONTENT)
  @Delete(':id')
  public async delete(@Param('id') id: string): Promise>> {
    return this.crudService.delete(id);
  }
}
github jiayisheji / jianshu / libs / database / src / lib / crud.controller.ts View on Github external
return this.crudService.create(entity);
  }

  @ApiOperation({ title: 'Update an existing record' })
  @ApiCreatedResponse({ description: 'The record has been successfully edited.' })
  @ApiNotFoundResponse({ description: 'Record not found' })
  @ApiBadRequestResponse({ description: 'Invalid input, The response body may contain clues as to what went wrong' })
  @HttpCode(HttpStatus.CREATED)
  @Put(':id')
  public async update(@Param('id') id: string, @Body() entity: Partial>): Promise> {
    return this.crudService.update(id, entity);
  }

  @ApiOperation({ title: 'Delete record' })
  @ApiResponse({ status: HttpStatus.NO_CONTENT, description: 'The record has been successfully deleted' })
  @ApiNotFoundResponse({ description: 'Record not found' })
  @HttpCode(HttpStatus.NO_CONTENT)
  @Delete(':id')
  public async delete(@Param('id') id: string): Promise>> {
    return this.crudService.delete(id);
  }
}