From 71f602efd41cee623097aefecc388dded89b578d Mon Sep 17 00:00:00 2001 From: Inga <52715130+inga-lovinde@users.noreply.github.com> Date: Mon, 11 Dec 2023 12:04:10 +0000 Subject: [PATCH] improved openapi docs (added search filters) --- src/movies.controller.ts | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/movies.controller.ts b/src/movies.controller.ts index df55548..60880bd 100644 --- a/src/movies.controller.ts +++ b/src/movies.controller.ts @@ -7,63 +7,75 @@ import { Param, Query, } from '@nestjs/common'; -import { EnrichedDataService } from './types'; -import { IsIn, IsInt, IsOptional, IsString, Length } from 'class-validator'; +import { ApiPropertyOptional } from '@nestjs/swagger'; import { Type } from 'class-transformer'; +import { IsIn, IsInt, IsOptional, IsString, Length } from 'class-validator'; +import { EnrichedDataService } from './types'; const ENTRY_TYPES = ['movie', 'series', 'episode'] as const; class SearchDto { + @ApiPropertyOptional() @IsString() @Length(1) @IsOptional() actors?: string; + @ApiPropertyOptional() @IsString() @Length(2, 2) @IsOptional() availableLanguages?: string; + @ApiPropertyOptional() @IsString() @Length(1) @IsOptional() directors?: string; + @ApiPropertyOptional() @IsString() @Length(1) @IsOptional() localTitle?: string; + @ApiPropertyOptional() @IsString() @Length(2, 2) @IsOptional() originalLanguage?: string; + @ApiPropertyOptional() @IsString() @Length(1) @IsOptional() productionCountries?: string; + @ApiPropertyOptional() @IsInt() @Type(() => Number) @IsOptional() productionYear?: number; + @ApiPropertyOptional() @IsString() @Length(1) @IsOptional() studios?: string; + @ApiPropertyOptional() @IsString() @Length(1) @IsOptional() title?: string; + @ApiPropertyOptional() @IsString() @IsIn(ENTRY_TYPES) @IsOptional() type?: (typeof ENTRY_TYPES)[number]; + @ApiPropertyOptional() @IsString() @Length(1) @IsOptional()