Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/config/env.validation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ export const envValidationSchema = Joi.object({
REDIS_PORT: Joi.number().required(),

JWT_SECRET: Joi.string().min(10).required(),
});
});
39 changes: 39 additions & 0 deletions src/config/swagger.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import { INestApplication } from '@nestjs/common';
import { SwaggerModule, DocumentBuilder } from '@nestjs/swagger';

export function setupSwagger(app: INestApplication): void {
const config = new DocumentBuilder()
.setTitle('TeachLink API')
.setDescription('TeachLink backend API documentation')
.setVersion('1.0')
.addBearerAuth(
{
type: 'http',
scheme: 'bearer',
bearerFormat: 'JWT',
name: 'Authorization',
description: 'Enter JWT token',
in: 'header',
},
'access-token',
)
.addTag('Auth', 'Authentication and authorization endpoints')
.addTag('Users', 'User management endpoints')
.addTag('Courses', 'Course management endpoints')
.addTag('Payments', 'Payment processing endpoints')
.addTag('Subscriptions', 'Subscription management endpoints')
.addServer('http://localhost:3000', 'Local Development')
.addServer('https://api.teachlink.com', 'Production')
.build();

const document = SwaggerModule.createDocument(app, config);

SwaggerModule.setup('api/docs', app, document, {
swaggerOptions: {
persistAuthorization: true,
tagsSorter: 'alpha',
operationsSorter: 'alpha',
},
customSiteTitle: 'TeachLink API Docs',
});
}
Loading