Skip to content

Commit 66bb3fd

Browse files
committed
feat(movie): add code description and exapmles to movie
1 parent b2f2f6b commit 66bb3fd

File tree

1 file changed

+87
-58
lines changed

1 file changed

+87
-58
lines changed

src/movie/schemas/movie.schema.ts

+87-58
Original file line numberDiff line numberDiff line change
@@ -9,56 +9,68 @@ import { ApiPropertyOptional } from '@nestjs/swagger';
99
export class ExternalId {
1010
@ApiPropertyOptional({
1111
description: 'ID из kinopoisk HD',
12-
example: 'gsdfgujsdfgiowe23413',
12+
example: '48e8d0acb0f62d8585101798eaeceec5',
1313
})
1414
@Prop({ index: true })
1515
kpHD: string;
1616

17-
@ApiPropertyOptional()
17+
@ApiPropertyOptional({ example: 'tt0232500' })
1818
@Prop({ index: true })
1919
imdb: string;
2020

21-
@ApiPropertyOptional()
21+
@ApiPropertyOptional({ example: 9799 })
2222
@Prop({ index: true })
2323
tmdb: number;
2424
}
2525

26-
export class Rating {
27-
@ApiPropertyOptional()
28-
@Prop({ unique: true })
26+
export class Votes {
27+
@ApiPropertyOptional({ example: 60000 })
28+
@Prop({ index: true })
2929
kpHD: string;
3030

31-
@ApiPropertyOptional()
32-
@Prop({ unique: true })
31+
@ApiPropertyOptional({ example: 50000 })
32+
@Prop({ index: true })
3333
imdb: string;
3434

35-
@ApiPropertyOptional()
36-
@Prop()
35+
@ApiPropertyOptional({ example: 10000 })
36+
@Prop({ index: true })
3737
tmdb: number;
38+
39+
@ApiPropertyOptional({ example: 10000, description: 'Количество голосов кинокритиков' })
40+
@Prop({ index: true })
41+
filmCritics: number;
42+
43+
@ApiPropertyOptional({ example: 4000, description: 'Количество голосов кинокритиков из РФ' })
44+
@Prop({ index: true })
45+
russianFilmCritics: number;
46+
47+
@ApiPropertyOptional({ example: 34000, description: 'Количество ожидающих выхода' })
48+
@Prop({ index: true })
49+
await: number;
3850
}
3951

40-
export class VendorNumbers {
41-
@ApiPropertyOptional()
52+
export class Rating {
53+
@ApiPropertyOptional({ example: 6.2, description: 'Рейтинг кинопоиска' })
4254
@Prop({ index: true })
4355
kp: number;
4456

45-
@ApiPropertyOptional()
57+
@ApiPropertyOptional({ example: 8.4, description: 'Рейтинг IMDB' })
4658
@Prop({ index: true })
4759
imdb: number;
4860

49-
@ApiPropertyOptional()
61+
@ApiPropertyOptional({ example: 3.2, description: 'Рейтинг TMDB' })
5062
@Prop({ index: true })
5163
tmdb: number;
5264

53-
@ApiPropertyOptional()
65+
@ApiPropertyOptional({ example: 10, description: 'Рейтинг кинокритиков' })
5466
@Prop({ index: true })
5567
filmCritics: number;
5668

57-
@ApiPropertyOptional()
69+
@ApiPropertyOptional({ example: 5.1, description: 'Рейтинг кинокритиков из РФ' })
5870
@Prop({ index: true })
5971
russianFilmCritics: number;
6072

61-
@ApiPropertyOptional()
73+
@ApiPropertyOptional({ example: 6.1, description: 'Рейтинг основанный на ожиданиях пользователей' })
6274
@Prop({ index: true })
6375
await: number;
6476
}
@@ -100,23 +112,22 @@ export class Name {
100112
}
101113

102114
export class Video {
103-
@ApiPropertyOptional()
115+
@ApiPropertyOptional({ example: 'https://www.youtube.com/embed/ZsJz2TJAPjw', description: 'Url трейлера' })
104116
@Prop()
105117
url: string;
106118

107-
@ApiPropertyOptional()
119+
@ApiPropertyOptional({ example: 'Official Trailer' })
108120
@Prop()
109121
name: string;
110122

111-
@ApiPropertyOptional()
123+
@ApiPropertyOptional({ example: 'youtube | yandex' })
112124
@Prop()
113125
site: string;
114126

115-
@ApiPropertyOptional()
116127
@Prop()
117128
size: number;
118129

119-
@ApiPropertyOptional()
130+
@ApiPropertyOptional({ example: 'TRAILER' })
120131
@Prop()
121132
type: string;
122133
}
@@ -126,47 +137,44 @@ export class VideoTypes {
126137
@Prop({ type: () => [Video] })
127138
trailers: Video[];
128139

129-
@ApiPropertyOptional({ type: () => Video, isArray: true })
130140
@Prop({ type: () => [Video] })
131141
teasers: Video[];
132142
}
133143

134144
export class Person {
135-
@ApiPropertyOptional()
145+
@ApiPropertyOptional({ example: 6317, description: 'Id персоны с кинопоиска' })
136146
@Prop({ index: true })
137147
id: number;
138148

139-
@ApiPropertyOptional()
149+
@ApiPropertyOptional({ example: 'https://st.kp.yandex.net/images/actor_iphone/iphone360_6317.jpg' })
140150
@Prop()
141151
photo: string;
142152

143-
@ApiPropertyOptional()
153+
@ApiPropertyOptional({ example: 'Пол Уокер' })
144154
@Prop()
145155
name: string;
146156

147-
@ApiPropertyOptional()
157+
@ApiPropertyOptional({ example: 'Paul Walker' })
148158
@Prop()
149159
enName: string;
150160

151-
@ApiPropertyOptional()
152161
@Prop()
153162
description: string;
154163

155-
@ApiPropertyOptional()
164+
@ApiPropertyOptional({ example: 'actor' })
156165
@Prop()
157166
profession: string;
158167

159-
@ApiPropertyOptional()
160168
@Prop()
161169
enProfession: string;
162170
}
163171

164172
export class CurrencyValue {
165-
@ApiPropertyOptional()
173+
@ApiPropertyOptional({ example: 207283925, description: 'Сумма' })
166174
@Prop({ index: true })
167175
value: number;
168176

169-
@ApiPropertyOptional()
177+
@ApiPropertyOptional({ example: '$', description: 'Валюта' })
170178
@Prop()
171179
currency: string;
172180
}
@@ -347,11 +355,11 @@ export class Technology {
347355
}
348356

349357
export class YearRange {
350-
@ApiPropertyOptional()
358+
@ApiPropertyOptional({ example: 2022, description: 'Год начала' })
351359
@Prop()
352360
start: number;
353361

354-
@ApiPropertyOptional()
362+
@ApiPropertyOptional({ example: 2023, description: 'Год окончания' })
355363
@Prop()
356364
end: number;
357365
}
@@ -380,15 +388,14 @@ export class Movie {
380388
externalId: ExternalId;
381389

382390
// INFO: Name values
383-
@ApiPropertyOptional()
391+
@ApiPropertyOptional({ example: 'Человек паук' })
384392
@Prop({ index: true })
385393
name: string;
386394

387-
@ApiPropertyOptional()
395+
@ApiPropertyOptional({ example: 'Spider man' })
388396
@Prop({ index: true })
389397
alternativeName: string;
390398

391-
@ApiPropertyOptional()
392399
@Prop({ index: true })
393400
enName: string;
394401

@@ -397,33 +404,54 @@ export class Movie {
397404
names: Name[];
398405

399406
// INFO: Type values
400-
@ApiPropertyOptional()
401-
@Prop()
407+
@ApiPropertyOptional({
408+
example: 'movie | tv-series | cartoon | anime | animated-series | tv-show',
409+
description: 'Тип тайтла',
410+
})
411+
@Prop({ index: true })
402412
type: string;
403413

414+
@ApiPropertyOptional({
415+
example: '1 (movie) | 2 (tv-series) | 3 (cartoon) | 4 (anime) | 5 (animated-series) | 6 (tv-show)',
416+
description: 'Тип тайтла в числовом обозначении',
417+
})
404418
@Prop({ index: true })
405419
typeNumber: number;
406420

407421
@Prop({ index: true })
408422
subType: string;
409423

410424
// INFO: Year values
425+
@ApiPropertyOptional({
426+
example: '1860-2030',
427+
description: 'Год премьеры',
428+
})
411429
@Prop({ index: true })
412430
year: number;
413431

414432
// INFO: Description values
415-
@ApiPropertyOptional()
433+
@ApiPropertyOptional({
434+
description: 'Описание тайтла',
435+
})
416436
@Prop()
417437
description: string;
418438

419-
@ApiPropertyOptional()
439+
@ApiPropertyOptional({
440+
description: 'Сокращенное описание',
441+
})
420442
@Prop()
421443
shortDescription: string;
422444

423-
@ApiPropertyOptional()
445+
@ApiPropertyOptional({
446+
description: 'Слоган',
447+
})
424448
@Prop()
425449
slogan: string;
426450

451+
@ApiPropertyOptional({
452+
example: 'filming | pre-production | completed | announced | post-production',
453+
description: 'Статус релиза тайтла',
454+
})
427455
@Prop({ index: true })
428456
status: string;
429457

@@ -432,25 +460,31 @@ export class Movie {
432460
facts: Fact[];
433461

434462
// INFO: Movie rating values
435-
@ApiPropertyOptional({ type: () => VendorNumbers })
436-
@Prop({ type: () => VendorNumbers })
437-
rating: VendorNumbers;
463+
@ApiPropertyOptional({ type: () => Rating })
464+
@Prop({ type: () => Rating })
465+
rating: Rating;
438466

439-
@ApiPropertyOptional()
440-
@Prop()
441-
votes: VendorNumbers;
467+
@ApiPropertyOptional({ type: () => Votes })
468+
@Prop({ type: () => Votes })
469+
votes: Votes;
442470

443471
// INFO: Length value
444-
@ApiPropertyOptional()
472+
@ApiPropertyOptional({ example: 120, description: 'Продолжительность фильма' })
445473
@Prop()
446474
movieLength: number;
447475

448476
// INFO: Age rating values
449-
@ApiPropertyOptional()
477+
@ApiPropertyOptional({
478+
example: 'pg13',
479+
description: 'Возрастной рейтинг по MPAA',
480+
})
450481
@Prop()
451482
ratingMpaa: string;
452483

453-
@ApiPropertyOptional()
484+
@ApiPropertyOptional({
485+
example: '16',
486+
description: 'Возрастной рейтинг',
487+
})
454488
@Prop()
455489
ageRating: number;
456490

@@ -463,15 +497,13 @@ export class Movie {
463497
@Prop({ type: () => ShortImage })
464498
poster: ShortImage;
465499

466-
@ApiPropertyOptional({ type: () => ShortImage })
467500
@Prop({ type: () => ShortImage })
468501
horizontalPoster: ShortImage;
469502

470503
@ApiPropertyOptional({ type: () => ShortImage })
471504
@Prop({ type: () => ShortImage })
472505
backdrop: ShortImage;
473506

474-
@ApiPropertyOptional({ type: () => Images })
475507
@Prop({ type: () => Images })
476508
imagesInfo: Images;
477509

@@ -493,7 +525,6 @@ export class Movie {
493525
@Prop({ type: () => [Person] })
494526
persons: Person[];
495527

496-
@ApiPropertyOptional()
497528
@Prop()
498529
color: string;
499530

@@ -505,7 +536,6 @@ export class Movie {
505536
@Prop()
506537
distributors: Distributor;
507538

508-
@ApiPropertyOptional({ type: () => SpokenLanguages, isArray: true })
509539
@Prop({ type: () => [SpokenLanguages] })
510540
spokenLanguages: SpokenLanguages[];
511541

@@ -535,7 +565,6 @@ export class Movie {
535565
@Prop({ type: () => Premiere })
536566
premiere: Premiere;
537567

538-
@ApiPropertyOptional()
539568
@Prop()
540569
ticketsOnSale: boolean;
541570

@@ -559,11 +588,11 @@ export class Movie {
559588
@Prop({ type: () => [YearRange] })
560589
releaseYears: YearRange[];
561590

562-
@ApiPropertyOptional()
591+
@ApiPropertyOptional({ example: 1, description: 'Позиция тайтла в топ 10' })
563592
@Prop()
564593
top10: number;
565594

566-
@ApiPropertyOptional()
595+
@ApiPropertyOptional({ example: 200, description: 'Позиция тайтла в топ 250' })
567596
@Prop()
568597
top250: number;
569598
}

0 commit comments

Comments
 (0)