Skip to content

Commit dcbdf12

Browse files
committed
docs: enhance Swagger documentation
1 parent 29fab8f commit dcbdf12

17 files changed

Lines changed: 79 additions & 162 deletions

src/api/auth/account/account.controller.ts

Lines changed: 1 addition & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,7 @@ import {
88
Patch,
99
Post
1010
} from '@nestjs/common'
11-
import {
12-
ApiHeader,
13-
ApiOkResponse,
14-
ApiOperation,
15-
ApiTags
16-
} from '@nestjs/swagger'
11+
import { ApiOkResponse, ApiOperation, ApiTags } from '@nestjs/swagger'
1712
import type { User } from '@prisma/generated'
1813
import { Turnstile } from 'nestjs-cloudflare-captcha'
1914

@@ -47,10 +42,6 @@ export class AccountController {
4742
@ApiOkResponse({
4843
type: AccountResponse
4944
})
50-
@ApiHeader({
51-
name: 'X-Session-Token',
52-
required: true
53-
})
5445
@Authorization()
5546
@Get()
5647
@HttpCode(HttpStatus.OK)
@@ -83,10 +74,6 @@ export class AccountController {
8374
@ApiOkResponse({
8475
type: Boolean
8576
})
86-
@ApiHeader({
87-
name: 'X-Session-Token',
88-
required: true
89-
})
9077
@Authorization()
9178
@Post('verify')
9279
@HttpCode(HttpStatus.OK)
@@ -141,10 +128,6 @@ export class AccountController {
141128
@ApiOkResponse({
142129
type: Boolean
143130
})
144-
@ApiHeader({
145-
name: 'X-Session-Token',
146-
required: true
147-
})
148131
@Authorization()
149132
@Patch('change/email')
150133
@HttpCode(HttpStatus.OK)
@@ -162,10 +145,6 @@ export class AccountController {
162145
@ApiOkResponse({
163146
type: Boolean
164147
})
165-
@ApiHeader({
166-
name: 'X-Session-Token',
167-
required: true
168-
})
169148
@Authorization()
170149
@Patch('change/password')
171150
@HttpCode(HttpStatus.OK)

src/api/auth/mfa/mfa.controller.ts

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import {
1111
} from '@nestjs/common'
1212
import {
1313
ApiBody,
14-
ApiHeader,
1514
ApiOkResponse,
1615
ApiOperation,
1716
ApiTags,
@@ -50,10 +49,6 @@ export class MfaController {
5049
@ApiOkResponse({
5150
type: MfaStatusResponse
5251
})
53-
@ApiHeader({
54-
name: 'X-Session-Token',
55-
required: true
56-
})
5752
@Authorization()
5853
@Get()
5954
@HttpCode(HttpStatus.OK)
@@ -68,10 +63,6 @@ export class MfaController {
6863
@ApiOkResponse({
6964
type: [String]
7065
})
71-
@ApiHeader({
72-
name: 'X-Session-Token',
73-
required: true
74-
})
7566
@Authorization()
7667
@Get('recovery')
7768
@HttpCode(HttpStatus.OK)
@@ -86,10 +77,6 @@ export class MfaController {
8677
@ApiOkResponse({
8778
type: [String]
8879
})
89-
@ApiHeader({
90-
name: 'X-Session-Token',
91-
required: true
92-
})
9380
@Authorization()
9481
@Patch('recovery')
9582
@HttpCode(HttpStatus.OK)
@@ -104,10 +91,6 @@ export class MfaController {
10491
@ApiOkResponse({
10592
type: Boolean
10693
})
107-
@ApiHeader({
108-
name: 'X-Session-Token',
109-
required: true
110-
})
11194
@Authorization()
11295
@Put('totp')
11396
@HttpCode(HttpStatus.OK)
@@ -125,10 +108,6 @@ export class MfaController {
125108
@ApiOkResponse({
126109
type: TotpGenerateSecretResponse
127110
})
128-
@ApiHeader({
129-
name: 'X-Session-Token',
130-
required: true
131-
})
132111
@Authorization()
133112
@Post('totp')
134113
@HttpCode(HttpStatus.OK)
@@ -143,10 +122,6 @@ export class MfaController {
143122
@ApiOkResponse({
144123
type: Boolean
145124
})
146-
@ApiHeader({
147-
name: 'X-Session-Token',
148-
required: true
149-
})
150125
@Authorization()
151126
@Delete('totp')
152127
@HttpCode(HttpStatus.OK)

src/api/auth/passkey/passkey.controller.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import {
88
Param,
99
Post
1010
} from '@nestjs/common'
11-
import { ApiHeader, ApiOkResponse, ApiOperation } from '@nestjs/swagger'
11+
import { ApiOkResponse, ApiOperation } from '@nestjs/swagger'
1212
import { User } from '@prisma/generated'
1313

1414
import {
@@ -36,7 +36,6 @@ export class PasskeyController {
3636
'Retrieve the list of registered passkeys for the authenticated user.'
3737
})
3838
@ApiOkResponse({ type: [PasskeyResponse] })
39-
@ApiHeader({ name: 'X-Session-Token', required: true })
4039
@Authorization()
4140
@Get()
4241
@HttpCode(HttpStatus.OK)
@@ -49,7 +48,6 @@ export class PasskeyController {
4948
description: 'Register a passkey for an account.'
5049
})
5150
@ApiOkResponse({ type: RegisterPasskeyResponse })
52-
@ApiHeader({ name: 'X-Session-Token', required: true })
5351
@Authorization()
5452
@Post()
5553
@HttpCode(HttpStatus.OK)
@@ -80,7 +78,6 @@ export class PasskeyController {
8078
'Generate options required to initiate WebAuthn registration.'
8179
})
8280
@ApiOkResponse({ type: GeneratePasskeyOptionsResponse })
83-
@ApiHeader({ name: 'X-Session-Token', required: true })
8481
@Authorization()
8582
@Post('register-options')
8683
@HttpCode(HttpStatus.OK)
@@ -93,7 +90,6 @@ export class PasskeyController {
9390
description: 'Delete a registered passkey by its ID.'
9491
})
9592
@ApiOkResponse({ type: Boolean })
96-
@ApiHeader({ name: 'X-Session-Token', required: true })
9793
@Authorization()
9894
@Delete(':id')
9995
@HttpCode(HttpStatus.OK)

src/api/auth/sso/sso.controller.ts

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,7 @@ import {
1212
UseGuards
1313
} from '@nestjs/common'
1414
import { ConfigService } from '@nestjs/config'
15-
import {
16-
ApiHeader,
17-
ApiOkResponse,
18-
ApiOperation,
19-
ApiTags
20-
} from '@nestjs/swagger'
15+
import { ApiOkResponse, ApiOperation, ApiTags } from '@nestjs/swagger'
2116
import type { User } from '@prisma/generated'
2217
import { Response } from 'express'
2318

src/api/course/course.controller.ts

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import {
1010
Res
1111
} from '@nestjs/common'
1212
import {
13-
ApiHeader,
1413
ApiOkResponse,
1514
ApiOperation,
1615
ApiResponse,
@@ -34,7 +33,8 @@ import {
3433
CourseResponse,
3534
CoursesResponse,
3635
CreateCourseRequest,
37-
CreateCourseResponse
36+
CreateCourseResponse,
37+
GenerateDownloadLinkResponse
3838
} from './dto'
3939

4040
@ApiTags('Course')
@@ -108,8 +108,12 @@ export class CourseController {
108108
await this.courseService.incrementViews(id)
109109
}
110110

111-
@ApiHeader({
112-
name: 'X-Session-Token'
111+
@ApiOperation({
112+
summary: 'Generate download link',
113+
description: 'Generates a secure download link for a course.'
114+
})
115+
@ApiOkResponse({
116+
type: GenerateDownloadLinkResponse
113117
})
114118
@PremiumOnly()
115119
@Post(':id/download-link')
@@ -121,8 +125,14 @@ export class CourseController {
121125
return await this.courseService.generateDownloadLink(id, user)
122126
}
123127

124-
@ApiHeader({
125-
name: 'X-Session-Token'
128+
@ApiOperation({
129+
summary: 'Resolve download token',
130+
description:
131+
'Resolves a download token to stream the course attachment.'
132+
})
133+
@ApiOkResponse({
134+
description:
135+
'The requested course file is streamed as a ZIP attachment.'
126136
})
127137
@Get('download/:token')
128138
@HttpCode(HttpStatus.OK)
@@ -165,10 +175,6 @@ export class CourseController {
165175
status: HttpStatus.OK,
166176
type: CreateCourseResponse
167177
})
168-
@ApiHeader({
169-
name: 'X-Session-Token',
170-
required: true
171-
})
172178
@Authorization(UserRole.ADMIN)
173179
@Post()
174180
@HttpCode(HttpStatus.OK)
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import { ApiProperty } from '@nestjs/swagger'
2+
3+
export class GenerateDownloadLinkResponse {
4+
@ApiProperty({
5+
description: 'URL to download the course',
6+
example: 'https://example.com/download/abc123'
7+
})
8+
public url: string
9+
}

src/api/course/dto/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
export * from './course.dto'
22
export * from './courses.dto'
33
export * from './create-course.dto'
4+
export * from './generate-download-link.dto'

src/api/lesson/lesson.controller.ts

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,7 @@ import {
1212
UseInterceptors
1313
} from '@nestjs/common'
1414
import { FileInterceptor } from '@nestjs/platform-express'
15-
import {
16-
ApiHeader,
17-
ApiOkResponse,
18-
ApiOperation,
19-
ApiTags
20-
} from '@nestjs/swagger'
15+
import { ApiOkResponse, ApiOperation, ApiTags } from '@nestjs/swagger'
2116
import { type User, UserRole } from '@prisma/generated'
2217

2318
import { Authorization, Authorized } from '@/common/decorators'
@@ -57,10 +52,6 @@ export class LessonController {
5752
@ApiOkResponse({
5853
type: ProgressResponse
5954
})
60-
@ApiHeader({
61-
name: 'X-Session-Token',
62-
required: true
63-
})
6455
@Authorization()
6556
@Get(':id/progress')
6657
@HttpCode(HttpStatus.OK)
@@ -78,10 +69,6 @@ export class LessonController {
7869
@ApiOkResponse({
7970
type: CreateLessonResponse
8071
})
81-
@ApiHeader({
82-
name: 'X-Session-Token',
83-
required: true
84-
})
8572
@Authorization(UserRole.ADMIN)
8673
@Post()
8774
@HttpCode(HttpStatus.OK)
@@ -93,10 +80,6 @@ export class LessonController {
9380
summary: 'Upload Lesson Video',
9481
description: 'Upload a video file associated with the lesson.'
9582
})
96-
@ApiHeader({
97-
name: 'X-Session-Token',
98-
required: true
99-
})
10083
@Authorization(UserRole.ADMIN)
10184
@UseInterceptors(
10285
FileInterceptor('file', {

src/api/payment/dto/init-payment.dto.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,18 @@ import { IsEnum } from 'class-validator'
44

55
export class InitPaymentRequest {
66
@ApiProperty({
7-
enum: PaymentMethod
7+
description: 'Payment method',
8+
enum: PaymentMethod,
9+
example: PaymentMethod.BANK_CARD
810
})
911
@IsEnum(PaymentMethod)
1012
public method: PaymentMethod
1113
}
14+
15+
export class InitPaymentResponse {
16+
@ApiProperty({
17+
description: 'URL to complete the payment',
18+
example: 'https://yookassa.ru/redirect/123456'
19+
})
20+
public url: string
21+
}
Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,23 @@
11
import { Body, Controller, HttpCode, HttpStatus, Post } from '@nestjs/common'
2-
import { ApiHeader } from '@nestjs/swagger'
2+
import { ApiOkResponse, ApiOperation } from '@nestjs/swagger'
33
import type { User } from '@prisma/generated'
44

55
import { Authorization, Authorized } from '@/common/decorators'
66

7-
import { InitPaymentRequest } from './dto'
7+
import { InitPaymentRequest, InitPaymentResponse } from './dto'
88
import { PaymentService } from './payment.service'
99

1010
@Controller('payment')
1111
export class PaymentController {
1212
public constructor(private readonly paymentService: PaymentService) {}
1313

14-
@ApiHeader({
15-
name: 'X-Session-Token'
14+
@ApiOperation({
15+
summary: 'Init Payment',
16+
description:
17+
'Creates a new payment and returns a URL to complete the payment process.'
18+
})
19+
@ApiOkResponse({
20+
type: InitPaymentResponse
1621
})
1722
@Authorization()
1823
@Post('init')
@@ -23,12 +28,4 @@ export class PaymentController {
2328
) {
2429
return await this.paymentService.create(dto, user)
2530
}
26-
27-
@Post('webhook')
28-
@HttpCode(HttpStatus.OK)
29-
public async webhook(@Body() dto: any) {
30-
console.log('PAYMENT WEBHOOK: ', dto)
31-
32-
return dto
33-
}
3431
}

0 commit comments

Comments
 (0)