diff --git a/src/builds/builds.controller.ts b/src/builds/builds.controller.ts index f597d301..fde3789c 100644 --- a/src/builds/builds.controller.ts +++ b/src/builds/builds.controller.ts @@ -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'; @@ -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 { @@ -29,7 +29,7 @@ export class BuildsController { } @Post() - @ApiResponse({ type: BuildDto }) + @ApiOkResponse({ type: BuildDto }) @ApiSecurity('api_key') @UseGuards(ApiGuard) create(@Body() createBuildDto: CreateBuildDto): Promise { @@ -37,7 +37,7 @@ export class BuildsController { } @Patch(':id') - @ApiResponse({ type: BuildDto }) + @ApiOkResponse({ type: BuildDto }) @ApiSecurity('api_key') @ApiBearerAuth() @UseGuards(MixedGuard) diff --git a/src/builds/dto/build-create.dto.ts b/src/builds/dto/build-create.dto.ts index 40420783..d9b1b0d4 100644 --- a/src/builds/dto/build-create.dto.ts +++ b/src/builds/dto/build-create.dto.ts @@ -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() diff --git a/src/shared/dto/baseline-data.dto.ts b/src/shared/dto/baseline-data.dto.ts index 2ff77dd0..008007a5 100644 --- a/src/shared/dto/baseline-data.dto.ts +++ b/src/shared/dto/baseline-data.dto.ts @@ -1,4 +1,4 @@ -import { ApiProperty } from '@nestjs/swagger'; +import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger'; import { IsString, IsOptional } from 'class-validator'; export class BaselineDataDto { @@ -6,22 +6,22 @@ export class BaselineDataDto { @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; diff --git a/src/swagger.ts b/src/swagger.ts index bedf9b73..61a4488f 100644 --- a/src/swagger.ts +++ b/src/swagger.ts @@ -2,8 +2,8 @@ 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() @@ -11,4 +11,4 @@ export function setupSwagger(app: INestApplication) { .build(); const document = SwaggerModule.createDocument(app, options); SwaggerModule.setup('api', app, document); -} \ No newline at end of file +} diff --git a/src/test-runs/dto/create-test-request.dto.ts b/src/test-runs/dto/create-test-request.dto.ts index fef46324..187e1016 100644 --- a/src/test-runs/dto/create-test-request.dto.ts +++ b/src/test-runs/dto/create-test-request.dto.ts @@ -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'; @@ -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[]; } diff --git a/src/test-variations/test-variations.controller.ts b/src/test-variations/test-variations.controller.ts index 0a88b1bd..840bf22a 100644 --- a/src/test-variations/test-variations.controller.ts +++ b/src/test-variations/test-variations.controller.ts @@ -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 {