Skip to content
Open
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
3 changes: 3 additions & 0 deletions src/main.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { NestFactory } from '@nestjs/core';
import { AppModule } from './app.module';
import { ConfigService } from '@nestjs/config';
import * as fs from 'fs';
import { SwaggerModule, DocumentBuilder } from '@nestjs/swagger';
import { RequestIdMiddleware } from './shared/middleware/request-id/request-id.middleware';
import { AppLogger } from './shared/logger/logger.service';
Expand All @@ -20,6 +21,8 @@ async function bootstrap() {
.build();

const document = SwaggerModule.createDocument(app, options);
fs.writeFileSync('./swagger.json', JSON.stringify(document, null, 2));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@asad-mlbd do you want to move this file generation to a separate step?
If I remember it right, serverless environments don't give the app a write access to the file system.
So our backend will not be able to run in that environment due to that constraint. 🤔


SwaggerModule.setup('api', app, document);

const configService = app.get(ConfigService);
Expand Down
25 changes: 25 additions & 0 deletions swagger.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"openapi": "3.0.0",
"info": {
"title": "Nestjs API starter",
"description": "Nestjs API description",
"version": "1.0",
"contact": {}
},
"tags": [],
"servers": [],
"components": {},
"paths": {
"/": {
"get": {
"operationId": "AppController_getHello",
"parameters": [],
"responses": {
"200": {
"description": ""
}
}
}
}
}
}