improved openapi docs (added search filters)

main
Inga 🏳‍🌈 1 year ago
parent 8e521876e7
commit 71f602efd4
  1. 16
      src/movies.controller.ts

@ -7,63 +7,75 @@ import {
Param, Param,
Query, Query,
} from '@nestjs/common'; } from '@nestjs/common';
import { EnrichedDataService } from './types'; import { ApiPropertyOptional } from '@nestjs/swagger';
import { IsIn, IsInt, IsOptional, IsString, Length } from 'class-validator';
import { Type } from 'class-transformer'; 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; const ENTRY_TYPES = ['movie', 'series', 'episode'] as const;
class SearchDto { class SearchDto {
@ApiPropertyOptional()
@IsString() @IsString()
@Length(1) @Length(1)
@IsOptional() @IsOptional()
actors?: string; actors?: string;
@ApiPropertyOptional()
@IsString() @IsString()
@Length(2, 2) @Length(2, 2)
@IsOptional() @IsOptional()
availableLanguages?: string; availableLanguages?: string;
@ApiPropertyOptional()
@IsString() @IsString()
@Length(1) @Length(1)
@IsOptional() @IsOptional()
directors?: string; directors?: string;
@ApiPropertyOptional()
@IsString() @IsString()
@Length(1) @Length(1)
@IsOptional() @IsOptional()
localTitle?: string; localTitle?: string;
@ApiPropertyOptional()
@IsString() @IsString()
@Length(2, 2) @Length(2, 2)
@IsOptional() @IsOptional()
originalLanguage?: string; originalLanguage?: string;
@ApiPropertyOptional()
@IsString() @IsString()
@Length(1) @Length(1)
@IsOptional() @IsOptional()
productionCountries?: string; productionCountries?: string;
@ApiPropertyOptional()
@IsInt() @IsInt()
@Type(() => Number) @Type(() => Number)
@IsOptional() @IsOptional()
productionYear?: number; productionYear?: number;
@ApiPropertyOptional()
@IsString() @IsString()
@Length(1) @Length(1)
@IsOptional() @IsOptional()
studios?: string; studios?: string;
@ApiPropertyOptional()
@IsString() @IsString()
@Length(1) @Length(1)
@IsOptional() @IsOptional()
title?: string; title?: string;
@ApiPropertyOptional()
@IsString() @IsString()
@IsIn(ENTRY_TYPES) @IsIn(ENTRY_TYPES)
@IsOptional() @IsOptional()
type?: (typeof ENTRY_TYPES)[number]; type?: (typeof ENTRY_TYPES)[number];
@ApiPropertyOptional()
@IsString() @IsString()
@Length(1) @Length(1)
@IsOptional() @IsOptional()

Loading…
Cancel
Save