Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/builds/builds.controller.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Controller, Get, UseGuards, Post, Body, Param, ParseUUIDPipe, Delete, Query, Patch } from '@nestjs/common';
import { BuildsService } from './builds.service';
import { JwtAuthGuard } from '../auth/guards/auth.guard';
import { ApiBearerAuth, ApiTags, ApiSecurity, ApiResponse } from '@nestjs/swagger';
import { ApiBearerAuth, ApiTags, ApiSecurity, ApiOkResponse } from '@nestjs/swagger';
import { CreateBuildDto } from './dto/build-create.dto';
import { ApiGuard } from '../auth/guards/api.guard';
import { Build } from '@prisma/client';
Expand All @@ -14,7 +14,7 @@ export class BuildsController {
constructor(private buildsService: BuildsService) {}

@Get()
@ApiResponse({ type: [BuildDto] })
@ApiOkResponse({ type: [BuildDto] })
@ApiBearerAuth()
@UseGuards(JwtAuthGuard)
get(@Query('projectId', new ParseUUIDPipe()) projectId: string): Promise<BuildDto[]> {
Expand All @@ -29,15 +29,15 @@ export class BuildsController {
}

@Post()
@ApiResponse({ type: BuildDto })
@ApiOkResponse({ type: BuildDto })
@ApiSecurity('api_key')
@UseGuards(ApiGuard)
create(@Body() createBuildDto: CreateBuildDto): Promise<BuildDto> {
return this.buildsService.create(createBuildDto);
}

@Patch(':id')
@ApiResponse({ type: BuildDto })
@ApiOkResponse({ type: BuildDto })
@ApiSecurity('api_key')
@ApiBearerAuth()
@UseGuards(MixedGuard)
Expand Down
4 changes: 2 additions & 2 deletions src/builds/dto/build-create.dto.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { ApiProperty } from '@nestjs/swagger';
import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
import { IsString, IsOptional, IsNotEmpty } from 'class-validator';

export class CreateBuildDto {
@ApiProperty()
@ApiPropertyOptional()
@IsOptional()
@IsString()
@IsNotEmpty()
Expand Down
10 changes: 5 additions & 5 deletions src/shared/dto/baseline-data.dto.ts
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
import { ApiProperty } from '@nestjs/swagger';
import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
import { IsString, IsOptional } from 'class-validator';

export class BaselineDataDto {
@ApiProperty()
@IsString()
name: string;

@ApiProperty()
@ApiPropertyOptional()
@IsOptional()
@IsString()
os?: string;

@ApiProperty()
@ApiPropertyOptional()
@IsOptional()
@IsString()
browser?: string;

@ApiProperty()
@ApiPropertyOptional()
@IsOptional()
@IsString()
viewport?: string;

@ApiProperty()
@ApiPropertyOptional()
@IsOptional()
@IsString()
device?: string;
Expand Down
6 changes: 3 additions & 3 deletions src/swagger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ import { INestApplication } from '@nestjs/common';
import { SwaggerModule, DocumentBuilder } from '@nestjs/swagger';

export function setupSwagger(app: INestApplication) {
const options = new DocumentBuilder()
.setTitle('Nest.js example API')
const options = new DocumentBuilder()
.setTitle('Visual Regression Tracker')
.setDescription('API Documentation')
.setVersion('1.0')
.addBearerAuth()
.addApiKey({ type: 'apiKey', name: 'apiKey', in: 'header', description: 'API Key For External calls' })
.build();
const document = SwaggerModule.createDocument(app, options);
SwaggerModule.setup('api', app, document);
}
}
8 changes: 4 additions & 4 deletions src/test-runs/dto/create-test-request.dto.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ApiProperty } from '@nestjs/swagger';
import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
import { Transform } from 'class-transformer';
import { IsOptional, IsUUID, IsNumber, IsBoolean, IsBase64 } from 'class-validator';
import { BaselineDataDto } from '../../shared/dto/baseline-data.dto';
Expand All @@ -18,17 +18,17 @@ export class CreateTestRequestDto extends BaselineDataDto {
@IsUUID()
projectId: string;

@ApiProperty()
@ApiPropertyOptional()
@IsOptional()
@IsNumber()
diffTollerancePercent?: number;

@ApiProperty()
@ApiPropertyOptional()
@IsBoolean()
@IsOptional()
merge?: boolean;

@ApiProperty({ type: [IgnoreAreaDto] })
@ApiPropertyOptional({ type: [IgnoreAreaDto] })
@IsOptional()
ignoreAreas?: IgnoreAreaDto[];
}
2 changes: 1 addition & 1 deletion src/test-variations/test-variations.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export class TestVariationsController {
}

@Get('details/:id')
@ApiQuery({ name: 'id', required: true })
@ApiParam({ name: 'id', required: true })
@ApiBearerAuth()
@UseGuards(JwtAuthGuard)
getDetails(@Param('id', new ParseUUIDPipe()) id: string): Promise<TestVariation & { baselines: Baseline[] }> {
Expand Down