-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathgenerate-spec.ts
More file actions
46 lines (39 loc) · 1.6 KB
/
Copy pathgenerate-spec.ts
File metadata and controls
46 lines (39 loc) · 1.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import { NestFactory } from "@nestjs/core";
import { DocumentBuilder, SwaggerModule } from "@nestjs/swagger";
import { AppModule } from "./src/app.module";
import * as fs from "fs";
import { User } from "./src/modules/users/entities/user.entity";
import { Budget } from "./src/modules/budgets/entities/budget.entity";
import { Category } from "./src/modules/categories/entities/category.entity";
import { Transaction } from "./src/modules/transactions/entities/transaction.entity";
import { Wallet } from "./src/modules/wallets/entities/wallet.entity";
import { Milestone } from "./src/modules/milestones/entities/milestone.entity";
async function generateSwaggerSpec() {
console.log("=== Start Swagger Generation ===");
const app = await NestFactory.create(AppModule, {
logger: ["log", "error", "warn", "debug"],
});
console.log("NestJS AppModule initialized");
const config = new DocumentBuilder()
.setTitle("Wallport API")
.setDescription("API for Personal Finance Tracker Application")
.setVersion("1.0")
.addBearerAuth()
.build();
console.log("Swagger config built");
const document = SwaggerModule.createDocument(app, config, {
extraModels: [User, Budget, Category, Transaction, Wallet, Milestone],
});
console.log("Swagger document created");
fs.writeFileSync("./swagger.json", JSON.stringify(document, null, 2));
console.log("Swagger file written to swagger.json");
await app.close();
console.log("NestJS application closed");
}
generateSwaggerSpec()
.then(() => {
console.log("Swagger spec generated.");
})
.catch((e: any) => {
console.log(e);
});