nest-scramble 2.1.0 → 2.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +105 -5
- package/build-and-publish.sh +9 -0
- package/dist/NestScrambleModule.d.ts +8 -1
- package/dist/NestScrambleModule.d.ts.map +1 -1
- package/dist/NestScrambleModule.js +42 -9
- package/dist/NestScrambleModule.js.map +1 -1
- package/package.json +4 -4
- package/test-dto-generation.ts +0 -103
package/README.md
CHANGED
|
@@ -6,6 +6,27 @@
|
|
|
6
6
|
[](https://opensource.org/licenses/MIT)
|
|
7
7
|
[](https://github.com/Eng-MMustafa/nest-scramble)
|
|
8
8
|
[](https://github.com/Eng-MMustafa)
|
|
9
|
+
[](https://docs.nestjs.com)
|
|
10
|
+
|
|
11
|
+
## 📋 What's New in v2.1.2
|
|
12
|
+
|
|
13
|
+
### ✅ Recent Fixes & Improvements
|
|
14
|
+
- **🔧 Fixed**: baseUrl configuration now properly displays in dashboard URLs
|
|
15
|
+
- **🔧 Updated**: Enhanced NestJS compatibility (>=9.0.0)
|
|
16
|
+
- **🔧 Improved**: Simplified reflect-metadata dependency
|
|
17
|
+
- **🎯 Feature**: Full baseUrl customization support
|
|
18
|
+
|
|
19
|
+
**Dashboard URLs now respect your configuration:**
|
|
20
|
+
```typescript
|
|
21
|
+
NestScrambleModule.forRoot({
|
|
22
|
+
baseUrl: 'http://127.0.0.1:4444' // ✅ Now works perfectly!
|
|
23
|
+
})
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
### 📖 Full Changelog
|
|
27
|
+
Check out the [CHANGELOG.md](CHANGELOG.md) for complete version history.
|
|
28
|
+
|
|
29
|
+
---
|
|
9
30
|
|
|
10
31
|
## 🚀 Why Nest-Scramble?
|
|
11
32
|
|
|
@@ -160,6 +181,34 @@ Then open your browser:
|
|
|
160
181
|
- 🎨 Serves beautiful documentation
|
|
161
182
|
- 🎭 Provides mock endpoints
|
|
162
183
|
|
|
184
|
+
## 🔧 Compatibility & Requirements
|
|
185
|
+
|
|
186
|
+
### Supported Versions
|
|
187
|
+
- **NestJS**: `>=9.0.0` (v9.x, v10.x, and future versions)
|
|
188
|
+
- **Node.js**: `>=16.0.0`
|
|
189
|
+
- **TypeScript**: `>=4.5.0`
|
|
190
|
+
- **reflect-metadata**: `>=0.1.13` (optional)
|
|
191
|
+
|
|
192
|
+
### Package Managers
|
|
193
|
+
```bash
|
|
194
|
+
# npm
|
|
195
|
+
npm install nest-scramble
|
|
196
|
+
|
|
197
|
+
# yarn
|
|
198
|
+
yarn add nest-scramble
|
|
199
|
+
|
|
200
|
+
# pnpm
|
|
201
|
+
pnpm add nest-scramble
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
### Auto-Detection Features
|
|
205
|
+
Nest-Scramble automatically detects:
|
|
206
|
+
- ✅ Project structure and source directories
|
|
207
|
+
- ✅ API title and version from `package.json`
|
|
208
|
+
- ✅ Base URL from `PORT` and `HOST` environment variables
|
|
209
|
+
- ✅ TypeScript configuration and controller locations
|
|
210
|
+
- ✅ Dependencies and module relationships
|
|
211
|
+
|
|
163
212
|
## ⚙️ Configuration Options
|
|
164
213
|
|
|
165
214
|
```typescript
|
|
@@ -167,8 +216,11 @@ NestScrambleModule.forRoot({
|
|
|
167
216
|
// Source directory to scan for controllers
|
|
168
217
|
sourcePath: 'src', // default: 'src'
|
|
169
218
|
|
|
170
|
-
// API base URL for OpenAPI spec
|
|
171
|
-
baseUrl: 'http://localhost:3000', // default:
|
|
219
|
+
// API base URL for OpenAPI spec and dashboard display
|
|
220
|
+
baseUrl: 'http://localhost:3000', // default: auto-detected from PORT/HOST env
|
|
221
|
+
|
|
222
|
+
// Documentation path (customizable)
|
|
223
|
+
path: '/docs', // default: '/docs'
|
|
172
224
|
|
|
173
225
|
// Enable live mocking middleware
|
|
174
226
|
enableMock: true, // default: true
|
|
@@ -178,6 +230,20 @@ NestScrambleModule.forRoot({
|
|
|
178
230
|
|
|
179
231
|
// Postman collection output path
|
|
180
232
|
postmanOutputPath: 'collection.json', // default: 'collection.json'
|
|
233
|
+
|
|
234
|
+
// UI Theme options
|
|
235
|
+
theme: 'futuristic', // 'classic' | 'futuristic' (default: 'futuristic')
|
|
236
|
+
primaryColor: '#00f2ff', // default: '#00f2ff'
|
|
237
|
+
customDomainIcon: '', // default: ''
|
|
238
|
+
|
|
239
|
+
// API metadata (auto-detected from package.json)
|
|
240
|
+
apiTitle: 'My API', // default: auto-detected
|
|
241
|
+
apiVersion: '1.0.0', // default: auto-detected
|
|
242
|
+
|
|
243
|
+
// 🆕 Advanced Features
|
|
244
|
+
useIncrementalScanning: false, // Enable caching for faster startups
|
|
245
|
+
enableWatchMode: false, // Auto-regenerate on file changes
|
|
246
|
+
cacheTtl: 24 * 60 * 60 * 1000, // Cache TTL in milliseconds (24 hours)
|
|
181
247
|
})
|
|
182
248
|
```
|
|
183
249
|
|
|
@@ -186,10 +252,44 @@ NestScrambleModule.forRoot({
|
|
|
186
252
|
| Option | Type | Default | Description |
|
|
187
253
|
|--------|------|---------|-------------|
|
|
188
254
|
| `sourcePath` | `string` | `'src'` | Directory where your NestJS controllers are located |
|
|
189
|
-
| `baseUrl` | `string` | `
|
|
255
|
+
| `baseUrl` | `string` | `auto-detected` | Base URL for your API (used in OpenAPI spec and dashboard URLs) |
|
|
256
|
+
| `path` | `string` | `'/docs'` | Documentation endpoint path |
|
|
190
257
|
| `enableMock` | `boolean` | `true` | Enable `/scramble-mock/*` endpoints for testing |
|
|
191
258
|
| `autoExportPostman` | `boolean` | `false` | Automatically generate Postman collection file |
|
|
192
259
|
| `postmanOutputPath` | `string` | `'collection.json'` | Output path for Postman collection |
|
|
260
|
+
| `theme` | `string` | `'futuristic'` | UI theme: 'classic' or 'futuristic' |
|
|
261
|
+
| `primaryColor` | `string` | `'#00f2ff'` | Primary accent color for UI |
|
|
262
|
+
| `apiTitle` | `string` | `auto-detected` | API title (auto-detected from package.json) |
|
|
263
|
+
| `apiVersion` | `string` | `auto-detected` | API version (auto-detected from package.json) |
|
|
264
|
+
| `useIncrementalScanning` | `boolean` | `false` | Enable caching for faster startup times |
|
|
265
|
+
| `enableWatchMode` | `boolean` | `false` | Auto-regenerate docs on file changes |
|
|
266
|
+
| `cacheTtl` | `number` | `24h` | Cache time-to-live in milliseconds |
|
|
267
|
+
|
|
268
|
+
### 🎯 baseUrl Configuration
|
|
269
|
+
|
|
270
|
+
The `baseUrl` option is now properly respected in the dashboard display:
|
|
271
|
+
|
|
272
|
+
```typescript
|
|
273
|
+
// Example with custom baseUrl
|
|
274
|
+
NestScrambleModule.forRoot({
|
|
275
|
+
baseUrl: 'http://127.0.0.1:4444',
|
|
276
|
+
path: '/api-docs'
|
|
277
|
+
})
|
|
278
|
+
```
|
|
279
|
+
|
|
280
|
+
**Dashboard Output:**
|
|
281
|
+
```
|
|
282
|
+
┌──────────────────────────────────────────────────────────┐
|
|
283
|
+
│ ✨ NEST-SCRAMBLE by Mohamed Mustafa │
|
|
284
|
+
├──────────────────────────────────────────────────────────┤
|
|
285
|
+
│ ● Documentation │
|
|
286
|
+
│ → http://127.0.0.1:4444/api-docs │
|
|
287
|
+
│ ● OpenAPI Spec │
|
|
288
|
+
│ → http://127.0.0.1:4444/api-docs-json │
|
|
289
|
+
│ ● Mock Server │
|
|
290
|
+
│ → http://127.0.0.1:4444/scramble-mock │
|
|
291
|
+
└──────────────────────────────────────────────────────────┘
|
|
292
|
+
```
|
|
193
293
|
|
|
194
294
|
## 🎭 Live Mocking Guide
|
|
195
295
|
|
|
@@ -809,7 +909,7 @@ NestScrambleModule.forRoot({
|
|
|
809
909
|
- Clear your browser cache and hard refresh (Ctrl+Shift+R / Cmd+Shift+R)
|
|
810
910
|
- Check browser console for errors
|
|
811
911
|
- Verify the `/docs-json` endpoint returns valid JSON
|
|
812
|
-
- Ensure you're using version
|
|
912
|
+
- Ensure you're using version 2.1.2 or higher: `npm list nest-scramble`
|
|
813
913
|
|
|
814
914
|
#### 3. **TypeScript Compilation Errors**
|
|
815
915
|
|
|
@@ -951,7 +1051,7 @@ getUser(@Param('id') id: string) {
|
|
|
951
1051
|
If you're still experiencing issues:
|
|
952
1052
|
|
|
953
1053
|
1. **Check the logs** - Nest-Scramble provides detailed diagnostic output on startup
|
|
954
|
-
2. **Verify your version** - Run `npm list nest-scramble` (should be
|
|
1054
|
+
2. **Verify your version** - Run `npm list nest-scramble` (should be 2.1.2+)
|
|
955
1055
|
3. **Open an issue** - [GitHub Issues](https://github.com/Eng-MMustafa/nest-scramble/issues)
|
|
956
1056
|
|
|
957
1057
|
When reporting issues, please include:
|
|
@@ -12,10 +12,17 @@ export interface NestScrambleOptions {
|
|
|
12
12
|
customDomainIcon?: string;
|
|
13
13
|
primaryColor?: string;
|
|
14
14
|
theme?: 'classic' | 'futuristic';
|
|
15
|
+
useIncrementalScanning?: boolean;
|
|
16
|
+
cacheFilePath?: string;
|
|
17
|
+
hashAlgorithm?: 'md5' | 'sha256';
|
|
18
|
+
cacheTtl?: number;
|
|
19
|
+
enableWatchMode?: boolean;
|
|
20
|
+
watchDebounce?: number;
|
|
21
|
+
skipDependencyTracking?: boolean;
|
|
22
|
+
enableHashCollisionDetection?: boolean;
|
|
15
23
|
}
|
|
16
24
|
export declare class NestScrambleModule implements OnModuleInit {
|
|
17
25
|
private static moduleOptions;
|
|
18
|
-
private static detectedPort;
|
|
19
26
|
onModuleInit(): void;
|
|
20
27
|
private displayDashboard;
|
|
21
28
|
static forRoot(options?: NestScrambleOptions): DynamicModule;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NestScrambleModule.d.ts","sourceRoot":"","sources":["../src/NestScrambleModule.ts"],"names":[],"mappings":"AAAA,kEAAkE;AAClE,OAAO,EAAE,aAAa,EAAE,kBAAkB,EAAU,YAAY,EAAiB,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"NestScrambleModule.d.ts","sourceRoot":"","sources":["../src/NestScrambleModule.ts"],"names":[],"mappings":"AAAA,kEAAkE;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anCollectionGenerator");
|
|
14
14
|
const MockMiddleware_1 = require("./middleware/MockMiddleware");
|
|
15
15
|
const ScannerService_1 = require("./scanner/ScannerService");
|
|
16
|
+
const IncrementalScannerService_1 = require("./scanner/IncrementalScannerService");
|
|
16
17
|
const MockGenerator_1 = require("./utils/MockGenerator");
|
|
17
18
|
const OpenApiTransformer_1 = require("./utils/OpenApiTransformer");
|
|
18
19
|
const DocsController_1 = require("./controllers/DocsController");
|
|
@@ -22,9 +23,9 @@ let NestScrambleModule = NestScrambleModule_1 = class NestScrambleModule {
|
|
|
22
23
|
this.displayDashboard();
|
|
23
24
|
}
|
|
24
25
|
displayDashboard() {
|
|
25
|
-
const port = NestScrambleModule_1.detectedPort;
|
|
26
26
|
const options = NestScrambleModule_1.moduleOptions;
|
|
27
27
|
const projectStructure = AutoDetector_1.AutoDetector.detectProjectStructure();
|
|
28
|
+
const baseUrl = options.baseUrl;
|
|
28
29
|
const cyan = '\x1b[36m';
|
|
29
30
|
const purple = '\x1b[35m';
|
|
30
31
|
const green = '\x1b[32m';
|
|
@@ -39,14 +40,14 @@ let NestScrambleModule = NestScrambleModule_1 = class NestScrambleModule {
|
|
|
39
40
|
console.log(`${gradient}║${reset} ${purple}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${reset} ${gradient}║${reset}`);
|
|
40
41
|
console.log(`${gradient}║${reset} ${gradient}║${reset}`);
|
|
41
42
|
console.log(`${gradient}║${reset} ${green}●${reset} ${bold}Documentation${reset} ${gradient}║${reset}`);
|
|
42
|
-
console.log(`${gradient}║${reset} ${cyan}→${reset}
|
|
43
|
+
console.log(`${gradient}║${reset} ${cyan}→${reset} ${baseUrl}${options.path || '/docs'} ${gradient}║${reset}`);
|
|
43
44
|
console.log(`${gradient}║${reset} ${gradient}║${reset}`);
|
|
44
45
|
console.log(`${gradient}║${reset} ${green}●${reset} ${bold}OpenAPI Spec${reset} ${gradient}║${reset}`);
|
|
45
|
-
console.log(`${gradient}║${reset} ${cyan}→${reset}
|
|
46
|
+
console.log(`${gradient}║${reset} ${cyan}→${reset} ${baseUrl}${options.path || '/docs'}-json ${gradient}║${reset}`);
|
|
46
47
|
if (options.enableMock !== false) {
|
|
47
48
|
console.log(`${gradient}║${reset} ${gradient}║${reset}`);
|
|
48
49
|
console.log(`${gradient}║${reset} ${green}●${reset} ${bold}Mock Server${reset} ${gradient}║${reset}`);
|
|
49
|
-
console.log(`${gradient}║${reset} ${cyan}→${reset}
|
|
50
|
+
console.log(`${gradient}║${reset} ${cyan}→${reset} ${baseUrl}/scramble-mock ${gradient}║${reset}`);
|
|
50
51
|
}
|
|
51
52
|
console.log(`${gradient}║${reset} ${gradient}║${reset}`);
|
|
52
53
|
console.log(`${gradient}║${reset} ${purple}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${reset} ${gradient}║${reset}`);
|
|
@@ -72,10 +73,20 @@ let NestScrambleModule = NestScrambleModule_1 = class NestScrambleModule {
|
|
|
72
73
|
customDomainIcon: options.customDomainIcon || '',
|
|
73
74
|
primaryColor: options.primaryColor || '#00f2ff',
|
|
74
75
|
theme: options.theme || 'futuristic',
|
|
76
|
+
// 🆕 Incremental Scanning Options
|
|
77
|
+
useIncrementalScanning: options.useIncrementalScanning || false,
|
|
78
|
+
cacheFilePath: options.cacheFilePath || 'scramble-cache.json',
|
|
79
|
+
hashAlgorithm: options.hashAlgorithm || 'md5',
|
|
80
|
+
cacheTtl: options.cacheTtl || 24 * 60 * 60 * 1000, // 24 hours
|
|
81
|
+
// 🆕 Watch Mode Options
|
|
82
|
+
enableWatchMode: options.enableWatchMode || false,
|
|
83
|
+
watchDebounce: options.watchDebounce || 300,
|
|
84
|
+
// 🆕 Advanced Options
|
|
85
|
+
skipDependencyTracking: options.skipDependencyTracking || false,
|
|
86
|
+
enableHashCollisionDetection: options.enableHashCollisionDetection !== false,
|
|
75
87
|
};
|
|
76
88
|
// Store for dashboard display
|
|
77
89
|
NestScrambleModule_1.moduleOptions = config;
|
|
78
|
-
NestScrambleModule_1.detectedPort = AutoDetector_1.AutoDetector.detectPort();
|
|
79
90
|
console.log(`\n${'='.repeat(60)}`);
|
|
80
91
|
console.log(`🚀 [Nest-Scramble] Zero-Config Auto-Detection Engine`);
|
|
81
92
|
console.log(` Developed by Mohamed Mustafa | MIT License`);
|
|
@@ -84,8 +95,30 @@ let NestScrambleModule = NestScrambleModule_1 = class NestScrambleModule {
|
|
|
84
95
|
console.log(` Root: ${projectStructure.rootPath}`);
|
|
85
96
|
console.log(` Source: ${config.sourcePath}`);
|
|
86
97
|
console.log(` Config: ${projectStructure.tsConfigPath}`);
|
|
87
|
-
|
|
88
|
-
|
|
98
|
+
// Use IncrementalScannerService if enabled
|
|
99
|
+
let scanner;
|
|
100
|
+
let controllers;
|
|
101
|
+
if (config.useIncrementalScanning) {
|
|
102
|
+
console.log(`[Nest-Scramble] 🚀 Using Incremental Scanner with caching...`);
|
|
103
|
+
scanner = new IncrementalScannerService_1.IncrementalScannerService({
|
|
104
|
+
useCache: true,
|
|
105
|
+
cacheFilePath: config.cacheFilePath,
|
|
106
|
+
hashAlgorithm: config.hashAlgorithm || 'md5',
|
|
107
|
+
cacheTtl: config.cacheTtl,
|
|
108
|
+
skipDependencyTracking: config.skipDependencyTracking,
|
|
109
|
+
});
|
|
110
|
+
// Initialize and scan
|
|
111
|
+
scanner.initialize(config.sourcePath);
|
|
112
|
+
controllers = scanner.scanControllers(config.sourcePath);
|
|
113
|
+
// Show cache stats
|
|
114
|
+
const cacheStats = scanner.getCacheManager().getStats();
|
|
115
|
+
console.log(`[Nest-Scramble] 📊 Cache: ${cacheStats.controllerCount} controllers, ${cacheStats.hashAlgorithm} algorithm`);
|
|
116
|
+
}
|
|
117
|
+
else {
|
|
118
|
+
console.log(`[Nest-Scramble] 📦 Using Traditional Scanner...`);
|
|
119
|
+
scanner = new ScannerService_1.ScannerService();
|
|
120
|
+
controllers = scanner.scanControllers(config.sourcePath);
|
|
121
|
+
}
|
|
89
122
|
console.log(`\n[Nest-Scramble] 📦 Generating OpenAPI specification...`);
|
|
90
123
|
const transformer = new OpenApiTransformer_1.OpenApiTransformer(config.baseUrl);
|
|
91
124
|
const openApiSpec = transformer.transform(controllers, config.apiTitle, config.apiVersion, config.baseUrl);
|
|
@@ -101,6 +134,7 @@ let NestScrambleModule = NestScrambleModule_1 = class NestScrambleModule {
|
|
|
101
134
|
module: NestScrambleModule_1,
|
|
102
135
|
providers: [
|
|
103
136
|
ScannerService_1.ScannerService,
|
|
137
|
+
IncrementalScannerService_1.IncrementalScannerService,
|
|
104
138
|
PostmanCollectionGenerator_1.PostmanCollectionGenerator,
|
|
105
139
|
OpenApiTransformer_1.OpenApiTransformer,
|
|
106
140
|
MockGenerator_1.MockGenerator,
|
|
@@ -117,7 +151,7 @@ let NestScrambleModule = NestScrambleModule_1 = class NestScrambleModule {
|
|
|
117
151
|
useValue: config,
|
|
118
152
|
},
|
|
119
153
|
],
|
|
120
|
-
exports: [ScannerService_1.ScannerService, PostmanCollectionGenerator_1.PostmanCollectionGenerator, OpenApiTransformer_1.OpenApiTransformer],
|
|
154
|
+
exports: [ScannerService_1.ScannerService, IncrementalScannerService_1.IncrementalScannerService, PostmanCollectionGenerator_1.PostmanCollectionGenerator, OpenApiTransformer_1.OpenApiTransformer],
|
|
121
155
|
controllers: [DocsController_1.DocsController],
|
|
122
156
|
imports: [],
|
|
123
157
|
};
|
|
@@ -135,7 +169,6 @@ let NestScrambleModule = NestScrambleModule_1 = class NestScrambleModule {
|
|
|
135
169
|
};
|
|
136
170
|
exports.NestScrambleModule = NestScrambleModule;
|
|
137
171
|
NestScrambleModule.moduleOptions = {};
|
|
138
|
-
NestScrambleModule.detectedPort = 3000;
|
|
139
172
|
exports.NestScrambleModule = NestScrambleModule = NestScrambleModule_1 = __decorate([
|
|
140
173
|
(0, common_1.Module)({})
|
|
141
174
|
], NestScrambleModule);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NestScrambleModule.js","sourceRoot":"","sources":["../src/NestScrambleModule.ts"],"names":[],"mappings":";;;;;;;;;;AAAA,kEAAkE;AAClE,2CAAwG;AACxG,wFAAqF;AACrF,gEAA6D;AAC7D,6DAA0D;AAC1D,yDAAsD;AACtD,mEAAgE;AAChE,iEAA8D;AAC9D,uDAAoD;
|
|
1
|
+
{"version":3,"file":"NestScrambleModule.js","sourceRoot":"","sources":["../src/NestScrambleModule.ts"],"names":[],"mappings":";;;;;;;;;;AAAA,kEAAkE;AAClE,2CAAwG;AACxG,wFAAqF;AACrF,gEAA6D;AAC7D,6DAA0D;AAC1D,mFAAgF;AAChF,yDAAsD;AACtD,mEAAgE;AAChE,iEAA8D;AAC9D,uDAAoD;AA4B7C,IAAM,kBAAkB,0BAAxB,MAAM,kBAAkB;IAG7B,YAAY;QACV,IAAI,CAAC,gBAAgB,EAAE,CAAC;IAC1B,CAAC;IAEO,gBAAgB;QACtB,MAAM,OAAO,GAAG,oBAAkB,CAAC,aAAa,CAAC;QACjD,MAAM,gBAAgB,GAAG,2BAAY,CAAC,sBAAsB,EAAE,CAAC;QAC/D,MAAM,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC;QAEhC,MAAM,IAAI,GAAG,UAAU,CAAC;QACxB,MAAM,MAAM,GAAG,UAAU,CAAC;QAC1B,MAAM,KAAK,GAAG,UAAU,CAAC;QACzB,MAAM,MAAM,GAAG,UAAU,CAAC;QAC1B,MAAM,IAAI,GAAG,SAAS,CAAC;QACvB,MAAM,KAAK,GAAG,SAAS,CAAC;QACxB,MAAM,GAAG,GAAG,SAAS,CAAC;QACtB,MAAM,QAAQ,GAAG,GAAG,IAAI,GAAG,IAAI,EAAE,CAAC;QAElC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QAClB,OAAO,CAAC,GAAG,CAAC,GAAG,QAAQ,oEAAoE,KAAK,EAAE,CAAC,CAAC;QACpG,OAAO,CAAC,GAAG,CAAC,GAAG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|
3
|
+
"version": "2.1.2",
|
|
4
4
|
"description": "A next-generation, decorator-free API documentation engine and intelligent mock server for NestJS, engineered by Mohamed Mustafa",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -46,9 +46,9 @@
|
|
|
46
46
|
"@typescript-eslint/parser": "^6.15.0"
|
|
47
47
|
},
|
|
48
48
|
"peerDependencies": {
|
|
49
|
-
"@nestjs/common": "
|
|
50
|
-
"@nestjs/core": "
|
|
51
|
-
"reflect-metadata": "
|
|
49
|
+
"@nestjs/common": ">=9.0.0",
|
|
50
|
+
"@nestjs/core": ">=9.0.0",
|
|
51
|
+
"reflect-metadata": ">=0.1.13"
|
|
52
52
|
},
|
|
53
53
|
"peerDependenciesMeta": {
|
|
54
54
|
"reflect-metadata": {
|
package/test-dto-generation.ts
DELETED
|
@@ -1,103 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Test file to verify DTO schema generation
|
|
3
|
-
* This file demonstrates the expected behavior
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
// Simple DTO with basic types
|
|
7
|
-
class CreateProductDto {
|
|
8
|
-
name: string;
|
|
9
|
-
price: number;
|
|
10
|
-
description: string;
|
|
11
|
-
inStock: boolean;
|
|
12
|
-
category?: string;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
// Response DTO
|
|
16
|
-
class ProductResponseDto {
|
|
17
|
-
id: number;
|
|
18
|
-
name: string;
|
|
19
|
-
price: number;
|
|
20
|
-
description: string;
|
|
21
|
-
inStock: boolean;
|
|
22
|
-
category?: string;
|
|
23
|
-
createdAt: Date;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
// Expected OpenAPI Schema Output:
|
|
27
|
-
const expectedSchema = {
|
|
28
|
-
components: {
|
|
29
|
-
schemas: {
|
|
30
|
-
CreateProductDto: {
|
|
31
|
-
type: 'object',
|
|
32
|
-
properties: {
|
|
33
|
-
name: { type: 'string', example: 'John Doe' },
|
|
34
|
-
price: { type: 'number', example: 99.99 },
|
|
35
|
-
description: { type: 'string', example: 'Sample description text' },
|
|
36
|
-
inStock: { type: 'boolean', example: true },
|
|
37
|
-
category: { type: 'string', example: 'sample value' },
|
|
38
|
-
},
|
|
39
|
-
required: ['name', 'price', 'description', 'inStock'],
|
|
40
|
-
example: {
|
|
41
|
-
name: 'John Doe',
|
|
42
|
-
price: 99.99,
|
|
43
|
-
description: 'Sample description text',
|
|
44
|
-
inStock: true,
|
|
45
|
-
},
|
|
46
|
-
},
|
|
47
|
-
ProductResponseDto: {
|
|
48
|
-
type: 'object',
|
|
49
|
-
properties: {
|
|
50
|
-
id: { type: 'number', example: 1 },
|
|
51
|
-
name: { type: 'string', example: 'John Doe' },
|
|
52
|
-
price: { type: 'number', example: 99.99 },
|
|
53
|
-
description: { type: 'string', example: 'Sample description text' },
|
|
54
|
-
inStock: { type: 'boolean', example: true },
|
|
55
|
-
category: { type: 'string', example: 'sample value' },
|
|
56
|
-
createdAt: { type: 'string', format: 'date-time', example: '2024-01-01T00:00:00.000Z' },
|
|
57
|
-
},
|
|
58
|
-
required: ['id', 'name', 'price', 'description', 'inStock', 'createdAt'],
|
|
59
|
-
example: {
|
|
60
|
-
id: 1,
|
|
61
|
-
name: 'John Doe',
|
|
62
|
-
price: 99.99,
|
|
63
|
-
description: 'Sample description text',
|
|
64
|
-
inStock: true,
|
|
65
|
-
createdAt: '2024-01-01T00:00:00.000Z',
|
|
66
|
-
},
|
|
67
|
-
},
|
|
68
|
-
},
|
|
69
|
-
},
|
|
70
|
-
};
|
|
71
|
-
|
|
72
|
-
// Expected endpoint with request body:
|
|
73
|
-
const expectedEndpoint = {
|
|
74
|
-
'/products': {
|
|
75
|
-
post: {
|
|
76
|
-
summary: 'create',
|
|
77
|
-
requestBody: {
|
|
78
|
-
required: true,
|
|
79
|
-
content: {
|
|
80
|
-
'application/json': {
|
|
81
|
-
schema: {
|
|
82
|
-
$ref: '#/components/schemas/CreateProductDto',
|
|
83
|
-
},
|
|
84
|
-
},
|
|
85
|
-
},
|
|
86
|
-
},
|
|
87
|
-
responses: {
|
|
88
|
-
'201': {
|
|
89
|
-
description: 'Created',
|
|
90
|
-
content: {
|
|
91
|
-
'application/json': {
|
|
92
|
-
schema: {
|
|
93
|
-
$ref: '#/components/schemas/ProductResponseDto',
|
|
94
|
-
},
|
|
95
|
-
},
|
|
96
|
-
},
|
|
97
|
-
},
|
|
98
|
-
},
|
|
99
|
-
},
|
|
100
|
-
},
|
|
101
|
-
};
|
|
102
|
-
|
|
103
|
-
export { CreateProductDto, ProductResponseDto, expectedSchema, expectedEndpoint };
|