@mini2/core 2.0.1-beta.2 → 2.0.1-beta.5
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 +37 -13
- package/dist/api-docs/postman.d.ts +123 -0
- package/dist/api-docs/postman.d.ts.map +1 -0
- package/dist/api-docs/postman.js +358 -0
- package/dist/api-docs/postman.js.map +1 -0
- package/dist/{swagger.d.ts → api-docs/swagger.d.ts} +1 -1
- package/dist/api-docs/swagger.d.ts.map +1 -0
- package/dist/{swagger.js → api-docs/swagger.js} +120 -108
- package/dist/api-docs/swagger.js.map +1 -0
- package/dist/app.d.ts.map +1 -1
- package/dist/app.js +17 -1
- package/dist/app.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/interfaces/config.interface.d.ts +1 -0
- package/dist/interfaces/config.interface.d.ts.map +1 -1
- package/dist/local-test-server/local-test-controller.d.ts +7 -0
- package/dist/local-test-server/local-test-controller.d.ts.map +1 -1
- package/dist/local-test-server/local-test-controller.js +99 -10
- package/dist/local-test-server/local-test-controller.js.map +1 -1
- package/dist/notations/controller/rest.types.d.ts +13 -8
- package/dist/notations/controller/rest.types.d.ts.map +1 -1
- package/local-test-server/Local Test Server.postman_collection.json +251 -55
- package/package.json +2 -1
- package/dist/swagger.d.ts.map +0 -1
- package/dist/swagger.js.map +0 -1
package/Readme.MD
CHANGED
|
@@ -921,30 +921,53 @@ const swaggerOptions = {
|
|
|
921
921
|
|
|
922
922
|
You can provide concrete request/response examples per route. If `examples` are present, Swagger generation prefers them to:
|
|
923
923
|
|
|
924
|
-
- Build request body schemas and attach `example`
|
|
924
|
+
- Build request body schemas and attach `example` + `examples`
|
|
925
925
|
- Generate path/query/header parameters (with examples when available)
|
|
926
|
-
- Generate
|
|
926
|
+
- Generate response examples by status code
|
|
927
|
+
|
|
928
|
+
`examples` is an array and each entry represents one scenario.
|
|
929
|
+
For each scenario, `response` must include exactly one status code key:
|
|
930
|
+
|
|
931
|
+
- ✅ `response: { 200: { ... } }`
|
|
932
|
+
- ✅ `response: { 400: { ... } }`
|
|
933
|
+
- ❌ `response: { 200: { ... }, 400: { ... } }`
|
|
927
934
|
|
|
928
935
|
Example (simplified):
|
|
929
936
|
|
|
930
937
|
```typescript
|
|
931
938
|
@post('/create', 'Create', {
|
|
932
|
-
examples: [
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
939
|
+
examples: [
|
|
940
|
+
{
|
|
941
|
+
request: {
|
|
942
|
+
body: { title: 'Test Item', order: 1 },
|
|
943
|
+
query: { page: 1 },
|
|
944
|
+
},
|
|
945
|
+
response: {
|
|
946
|
+
201: { ok: true, id: '123' },
|
|
947
|
+
},
|
|
938
948
|
},
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
949
|
+
{
|
|
950
|
+
request: {
|
|
951
|
+
body: { order: 1 },
|
|
952
|
+
},
|
|
953
|
+
response: {
|
|
954
|
+
400: { error: 'Validation failed' },
|
|
955
|
+
},
|
|
942
956
|
},
|
|
943
|
-
|
|
957
|
+
],
|
|
944
958
|
})
|
|
945
959
|
create() { /* ... */ }
|
|
946
960
|
```
|
|
947
961
|
|
|
962
|
+
#### **📮 Postman Collection Behavior with Examples**
|
|
963
|
+
|
|
964
|
+
When route `examples` are provided:
|
|
965
|
+
|
|
966
|
+
- One Postman request item is generated per route
|
|
967
|
+
- Request body examples are attached to `request.body.options.raw.examples`
|
|
968
|
+
- Route response examples are included in the same request item's `response[]` list
|
|
969
|
+
- Route-level scripts (`@preRequestScript` / `@testScript`) are attached once at item level
|
|
970
|
+
|
|
948
971
|
#### **🧰 Postman Scripts via OpenAPI Vendor Extensions**
|
|
949
972
|
|
|
950
973
|
Attach Postman-compatible scripts to a route:
|
|
@@ -1040,7 +1063,8 @@ This repo includes a runnable demo server and an example Postman collection to q
|
|
|
1040
1063
|
|
|
1041
1064
|
- `local-test-server/index.ts`: starts the server with autoload enabled
|
|
1042
1065
|
- `local-test-server/local-test-controller.ts`: demonstrates `examples`, `@preRequestScript`, and `@testScript`
|
|
1043
|
-
- `
|
|
1066
|
+
- `GET /postman.json`: generated Postman collection endpoint
|
|
1067
|
+
- `local-test-server/Local Test Server.postman_collection.json`: sample exported collection snapshot
|
|
1044
1068
|
|
|
1045
1069
|
### 📝 TypeScript Support
|
|
1046
1070
|
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import 'reflect-metadata';
|
|
2
|
+
import { Express } from 'express';
|
|
3
|
+
import { ISwaggerBasicAuth } from '../interfaces/config.interface';
|
|
4
|
+
type PostmanScript = {
|
|
5
|
+
type: 'text/javascript';
|
|
6
|
+
exec: string[];
|
|
7
|
+
};
|
|
8
|
+
type PostmanEvent = {
|
|
9
|
+
listen: 'prerequest' | 'test';
|
|
10
|
+
script: PostmanScript;
|
|
11
|
+
};
|
|
12
|
+
type PostmanHeader = {
|
|
13
|
+
key: string;
|
|
14
|
+
value: string;
|
|
15
|
+
};
|
|
16
|
+
type PostmanQuery = {
|
|
17
|
+
key: string;
|
|
18
|
+
value: string;
|
|
19
|
+
};
|
|
20
|
+
type PostmanVariable = {
|
|
21
|
+
key: string;
|
|
22
|
+
value: string;
|
|
23
|
+
};
|
|
24
|
+
type PostmanUrl = {
|
|
25
|
+
raw: string;
|
|
26
|
+
host: string[];
|
|
27
|
+
path: string[];
|
|
28
|
+
query?: PostmanQuery[];
|
|
29
|
+
variable?: PostmanVariable[];
|
|
30
|
+
};
|
|
31
|
+
type PostmanRequest = {
|
|
32
|
+
method: string;
|
|
33
|
+
header: PostmanHeader[];
|
|
34
|
+
url: PostmanUrl;
|
|
35
|
+
description?: string;
|
|
36
|
+
body?: {
|
|
37
|
+
mode: 'raw';
|
|
38
|
+
raw: string;
|
|
39
|
+
options: {
|
|
40
|
+
raw: {
|
|
41
|
+
language: 'json';
|
|
42
|
+
examples?: unknown[];
|
|
43
|
+
};
|
|
44
|
+
};
|
|
45
|
+
};
|
|
46
|
+
};
|
|
47
|
+
type PostmanResponse = {
|
|
48
|
+
name: string;
|
|
49
|
+
originalRequest: PostmanRequest;
|
|
50
|
+
status: string;
|
|
51
|
+
code: number;
|
|
52
|
+
_postman_previewlanguage: 'json' | 'text';
|
|
53
|
+
header: PostmanHeader[];
|
|
54
|
+
cookie: unknown[];
|
|
55
|
+
body: string;
|
|
56
|
+
};
|
|
57
|
+
type PostmanRequestItem = {
|
|
58
|
+
name: string;
|
|
59
|
+
event?: PostmanEvent[];
|
|
60
|
+
request: PostmanRequest;
|
|
61
|
+
response: PostmanResponse[];
|
|
62
|
+
};
|
|
63
|
+
type PostmanFolderItem = {
|
|
64
|
+
name: string;
|
|
65
|
+
item: PostmanRequestItem[];
|
|
66
|
+
};
|
|
67
|
+
type PostmanCollection = {
|
|
68
|
+
info: {
|
|
69
|
+
_postman_id: string;
|
|
70
|
+
name: string;
|
|
71
|
+
description: string;
|
|
72
|
+
schema: string;
|
|
73
|
+
};
|
|
74
|
+
item: PostmanFolderItem[];
|
|
75
|
+
variable: Array<{
|
|
76
|
+
key: string;
|
|
77
|
+
value: string;
|
|
78
|
+
}>;
|
|
79
|
+
};
|
|
80
|
+
export interface IPostmanIntegrationOptions {
|
|
81
|
+
title?: string;
|
|
82
|
+
description?: string;
|
|
83
|
+
version?: string;
|
|
84
|
+
servers?: Array<{
|
|
85
|
+
url: string;
|
|
86
|
+
description: string;
|
|
87
|
+
}>;
|
|
88
|
+
jsonPath?: string;
|
|
89
|
+
basicAuth?: ISwaggerBasicAuth;
|
|
90
|
+
baseUrlVariableName?: string;
|
|
91
|
+
}
|
|
92
|
+
export declare class PostmanIntegration {
|
|
93
|
+
private postmanCollection;
|
|
94
|
+
private options;
|
|
95
|
+
constructor(options?: IPostmanIntegrationOptions);
|
|
96
|
+
generatePostmanCollection(controllers: any[]): void;
|
|
97
|
+
setupPostman(app: Express): void;
|
|
98
|
+
getPostmanCollection(): PostmanCollection | null;
|
|
99
|
+
private buildRequestItem;
|
|
100
|
+
private buildRequest;
|
|
101
|
+
private extractBodyExamples;
|
|
102
|
+
private buildResponses;
|
|
103
|
+
private createDefaultResponse;
|
|
104
|
+
private buildEvents;
|
|
105
|
+
private toPostmanScript;
|
|
106
|
+
private buildQuery;
|
|
107
|
+
private buildPathVariables;
|
|
108
|
+
private extractPathVariables;
|
|
109
|
+
private extractPostmanPath;
|
|
110
|
+
private defaultStatusForMethod;
|
|
111
|
+
private stringifyScalar;
|
|
112
|
+
private isRecord;
|
|
113
|
+
private generateSummary;
|
|
114
|
+
private generateDescription;
|
|
115
|
+
private extractControllerFolderName;
|
|
116
|
+
private extractResourceName;
|
|
117
|
+
private getDefaultBaseUrl;
|
|
118
|
+
private buildCollectionDescription;
|
|
119
|
+
private generateCollectionId;
|
|
120
|
+
private basicAuthMiddleware;
|
|
121
|
+
}
|
|
122
|
+
export default PostmanIntegration;
|
|
123
|
+
//# sourceMappingURL=postman.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"postman.d.ts","sourceRoot":"","sources":["../../api-docs/postman.ts"],"names":[],"mappings":"AAAA,OAAO,kBAAkB,CAAC;AAC1B,OAAO,EAAE,OAAO,EAAmC,MAAM,SAAS,CAAC;AACnE,OAAO,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAC;AAQnE,KAAK,aAAa,GAAG;IACpB,IAAI,EAAE,iBAAiB,CAAC;IACxB,IAAI,EAAE,MAAM,EAAE,CAAC;CACf,CAAC;AAEF,KAAK,YAAY,GAAG;IACnB,MAAM,EAAE,YAAY,GAAG,MAAM,CAAC;IAC9B,MAAM,EAAE,aAAa,CAAC;CACtB,CAAC;AAEF,KAAK,aAAa,GAAG;IACpB,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;CACd,CAAC;AAEF,KAAK,YAAY,GAAG;IACnB,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK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;IAQlB,OAAO,CAAC,kBAAkB;IAW1B,OAAO,CAAC,oBAAoB;IAK5B,OAAO,CAAC,kBAAkB;IAS1B,OAAO,CAAC,sBAAsB;IAK9B,OAAO,CAAC,eAAe;IASvB,OAAO,CAAC,QAAQ;IAQhB,OAAO,CAAC,eAAe;IAgBvB,OAAO,CAAC,mBAAmB;IAkB3B,OAAO,CAAC,2BAA2B;IAKnC,OAAO,CAAC,mBAAmB;IAW3B,OAAO,CAAC,iBAAiB;IAMzB,OAAO,CAAC,0BAA0B;IAUlC,OAAO,CAAC,oBAAoB;IAU5B,OAAO,CAAC,mBAAmB;CAsB3B;AAED,eAAe,kBAAkB,CAAC"}
|
|
@@ -0,0 +1,358 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PostmanIntegration = void 0;
|
|
4
|
+
require("reflect-metadata");
|
|
5
|
+
const notations_1 = require("../notations");
|
|
6
|
+
class PostmanIntegration {
|
|
7
|
+
constructor(options = {}) {
|
|
8
|
+
this.postmanCollection = null;
|
|
9
|
+
this.options = {
|
|
10
|
+
title: 'Mini Framework API',
|
|
11
|
+
description: 'API documentation for Mini Framework',
|
|
12
|
+
version: '1.0.0',
|
|
13
|
+
servers: [
|
|
14
|
+
{ url: 'http://localhost:3000', description: 'Development server' },
|
|
15
|
+
],
|
|
16
|
+
jsonPath: '/postman.json',
|
|
17
|
+
baseUrlVariableName: 'baseUrl',
|
|
18
|
+
...options,
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
generatePostmanCollection(controllers) {
|
|
22
|
+
const folders = new Map();
|
|
23
|
+
const defaultBaseUrl = this.getDefaultBaseUrl();
|
|
24
|
+
const baseUrlVariableName = this.options.baseUrlVariableName || 'baseUrl';
|
|
25
|
+
controllers.forEach((controller) => {
|
|
26
|
+
const controllerPrototype = Object.getPrototypeOf(controller);
|
|
27
|
+
const controllerPath = Reflect.getMetadata(notations_1.keyOfPath, controller.constructor);
|
|
28
|
+
if (!controllerPath)
|
|
29
|
+
return;
|
|
30
|
+
const folderName = this.extractControllerFolderName(controllerPath);
|
|
31
|
+
const allProperties = Object.getOwnPropertyNames(controllerPrototype);
|
|
32
|
+
allProperties.forEach((property) => {
|
|
33
|
+
const routeOptions = Reflect.getMetadata(notations_1.keyOfRouteOptions, controllerPrototype, property);
|
|
34
|
+
if (!routeOptions?.path || !routeOptions.method)
|
|
35
|
+
return;
|
|
36
|
+
const fullPath = controllerPath.replace(/\/$/, '') +
|
|
37
|
+
routeOptions.path.replace(/:([a-zA-Z0-9_]+)/g, '{{$1}}');
|
|
38
|
+
const method = routeOptions.method.toUpperCase();
|
|
39
|
+
const requestItem = this.buildRequestItem(method, fullPath, routeOptions, baseUrlVariableName);
|
|
40
|
+
if (!folders.has(folderName)) {
|
|
41
|
+
folders.set(folderName, []);
|
|
42
|
+
}
|
|
43
|
+
folders.get(folderName).push(requestItem);
|
|
44
|
+
});
|
|
45
|
+
});
|
|
46
|
+
this.postmanCollection = {
|
|
47
|
+
info: {
|
|
48
|
+
_postman_id: this.generateCollectionId(),
|
|
49
|
+
name: this.options.title || 'Mini Framework API',
|
|
50
|
+
description: this.buildCollectionDescription(),
|
|
51
|
+
schema: 'https://schema.getpostman.com/json/collection/v2.1.0/collection.json',
|
|
52
|
+
},
|
|
53
|
+
item: Array.from(folders.entries()).map(([name, item]) => ({ name, item })),
|
|
54
|
+
variable: [{ key: baseUrlVariableName, value: defaultBaseUrl }],
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
setupPostman(app) {
|
|
58
|
+
const authMiddleware = this.options.basicAuth
|
|
59
|
+
? this.basicAuthMiddleware.bind(this)
|
|
60
|
+
: (_req, _res, next) => next();
|
|
61
|
+
app.get(this.options.jsonPath, authMiddleware, (_req, res) => {
|
|
62
|
+
if (!this.postmanCollection) {
|
|
63
|
+
res.status(500).json({
|
|
64
|
+
error: 'Postman collection has not been generated yet.',
|
|
65
|
+
});
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
res.setHeader('Content-Type', 'application/json');
|
|
69
|
+
res.send(this.postmanCollection);
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
getPostmanCollection() {
|
|
73
|
+
return this.postmanCollection;
|
|
74
|
+
}
|
|
75
|
+
buildRequestItem(method, fullPath, routeOptions, baseUrlVariableName) {
|
|
76
|
+
const examples = routeOptions.examples ?? [];
|
|
77
|
+
const events = this.buildEvents(routeOptions);
|
|
78
|
+
const baseRequestName = routeOptions.name?.trim() ||
|
|
79
|
+
this.generateSummary(method.toLowerCase(), fullPath);
|
|
80
|
+
const primaryExample = examples[0];
|
|
81
|
+
const request = this.buildRequest(method, fullPath, baseUrlVariableName, routeOptions, primaryExample, examples);
|
|
82
|
+
return {
|
|
83
|
+
name: baseRequestName,
|
|
84
|
+
...(events ? { event: events } : {}),
|
|
85
|
+
request,
|
|
86
|
+
response: this.buildResponses(method, request, routeOptions, examples),
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
buildRequest(method, fullPath, baseUrlVariableName, routeOptions, example, examples) {
|
|
90
|
+
const headers = [
|
|
91
|
+
{ key: 'Content-Type', value: 'application/json' },
|
|
92
|
+
{ key: 'Accept', value: 'application/json' },
|
|
93
|
+
];
|
|
94
|
+
if (example?.request?.headers && this.isRecord(example.request.headers)) {
|
|
95
|
+
Object.entries(example.request.headers).forEach(([key, value]) => {
|
|
96
|
+
headers.push({ key, value: this.stringifyScalar(value) });
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
const query = this.buildQuery(example?.request?.query);
|
|
100
|
+
const variable = this.buildPathVariables(fullPath, example?.request?.params);
|
|
101
|
+
const path = this.extractPostmanPath(fullPath);
|
|
102
|
+
const rawUrl = `{{${baseUrlVariableName}}}${fullPath}`;
|
|
103
|
+
const request = {
|
|
104
|
+
method,
|
|
105
|
+
header: headers,
|
|
106
|
+
url: {
|
|
107
|
+
raw: rawUrl,
|
|
108
|
+
host: [`{{${baseUrlVariableName}}}`],
|
|
109
|
+
path,
|
|
110
|
+
...(query.length ? { query } : {}),
|
|
111
|
+
...(variable.length ? { variable } : {}),
|
|
112
|
+
},
|
|
113
|
+
description: this.generateDescription(method.toLowerCase(), fullPath),
|
|
114
|
+
};
|
|
115
|
+
const bodyPayload = example?.request?.body;
|
|
116
|
+
if (bodyPayload) {
|
|
117
|
+
const bodyExamples = this.extractBodyExamples(examples);
|
|
118
|
+
request.body = {
|
|
119
|
+
mode: 'raw',
|
|
120
|
+
raw: JSON.stringify(bodyPayload, null, 2),
|
|
121
|
+
options: {
|
|
122
|
+
raw: {
|
|
123
|
+
language: 'json',
|
|
124
|
+
...(bodyExamples.length ? { examples: bodyExamples } : {}),
|
|
125
|
+
},
|
|
126
|
+
},
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
else if (['POST', 'PUT', 'PATCH'].includes(method) &&
|
|
130
|
+
(routeOptions.validations?.some((validation) => validation.body) ?? false)) {
|
|
131
|
+
// Swagger tarafindaki body-validation fallback'ina paralel olarak
|
|
132
|
+
// body bolumunu en azindan bos bir JSON payload ile gorunur kil.
|
|
133
|
+
request.body = {
|
|
134
|
+
mode: 'raw',
|
|
135
|
+
raw: JSON.stringify({}, null, 2),
|
|
136
|
+
options: {
|
|
137
|
+
raw: {
|
|
138
|
+
language: 'json',
|
|
139
|
+
},
|
|
140
|
+
},
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
return request;
|
|
144
|
+
}
|
|
145
|
+
extractBodyExamples(examples) {
|
|
146
|
+
return examples
|
|
147
|
+
.map((item) => item.request?.body)
|
|
148
|
+
.filter((body) => body !== undefined)
|
|
149
|
+
.map((body) => JSON.parse(JSON.stringify(body)));
|
|
150
|
+
}
|
|
151
|
+
buildResponses(method, request, routeOptions, examples) {
|
|
152
|
+
const responses = [];
|
|
153
|
+
if (examples.length > 0) {
|
|
154
|
+
examples.forEach((example, exampleIndex) => {
|
|
155
|
+
const response = example.response;
|
|
156
|
+
if (!response || typeof response !== 'object')
|
|
157
|
+
return;
|
|
158
|
+
Object.entries(response).forEach(([statusCode, responseData]) => {
|
|
159
|
+
const code = Number(statusCode);
|
|
160
|
+
const body = typeof responseData === 'string'
|
|
161
|
+
? responseData
|
|
162
|
+
: JSON.stringify(responseData, null, 2);
|
|
163
|
+
responses.push({
|
|
164
|
+
name: examples.length > 1
|
|
165
|
+
? `Status ${statusCode} (Example ${exampleIndex + 1})`
|
|
166
|
+
: `Status ${statusCode}`,
|
|
167
|
+
originalRequest: request,
|
|
168
|
+
status: `Status ${statusCode}`,
|
|
169
|
+
code: Number.isNaN(code) ? 200 : code,
|
|
170
|
+
_postman_previewlanguage: 'json',
|
|
171
|
+
header: [
|
|
172
|
+
{
|
|
173
|
+
key: 'Content-Type',
|
|
174
|
+
value: 'application/json',
|
|
175
|
+
},
|
|
176
|
+
],
|
|
177
|
+
cookie: [],
|
|
178
|
+
body,
|
|
179
|
+
});
|
|
180
|
+
});
|
|
181
|
+
});
|
|
182
|
+
return responses;
|
|
183
|
+
}
|
|
184
|
+
const defaultCode = this.defaultStatusForMethod(method);
|
|
185
|
+
responses.push(this.createDefaultResponse(defaultCode, 'Success', { ok: true }, request));
|
|
186
|
+
responses.push(this.createDefaultResponse(400, 'Bad Request', { message: 'Bad Request' }, request));
|
|
187
|
+
if (routeOptions.permissions && routeOptions.permissions.length > 0) {
|
|
188
|
+
responses.push(this.createDefaultResponse(403, 'Forbidden', { message: 'Forbidden' }, request));
|
|
189
|
+
}
|
|
190
|
+
return responses;
|
|
191
|
+
}
|
|
192
|
+
createDefaultResponse(code, name, payload, request) {
|
|
193
|
+
return {
|
|
194
|
+
name,
|
|
195
|
+
originalRequest: request,
|
|
196
|
+
status: name,
|
|
197
|
+
code,
|
|
198
|
+
_postman_previewlanguage: 'json',
|
|
199
|
+
header: [{ key: 'Content-Type', value: 'application/json' }],
|
|
200
|
+
cookie: [],
|
|
201
|
+
body: JSON.stringify(payload, null, 2),
|
|
202
|
+
};
|
|
203
|
+
}
|
|
204
|
+
buildEvents(routeOptions) {
|
|
205
|
+
const events = [];
|
|
206
|
+
if (routeOptions.preRequestScript) {
|
|
207
|
+
events.push({
|
|
208
|
+
listen: 'prerequest',
|
|
209
|
+
script: this.toPostmanScript(routeOptions.preRequestScript),
|
|
210
|
+
});
|
|
211
|
+
}
|
|
212
|
+
if (routeOptions.testScript) {
|
|
213
|
+
events.push({
|
|
214
|
+
listen: 'test',
|
|
215
|
+
script: this.toPostmanScript(routeOptions.testScript),
|
|
216
|
+
});
|
|
217
|
+
}
|
|
218
|
+
return events.length ? events : undefined;
|
|
219
|
+
}
|
|
220
|
+
toPostmanScript(scriptContent) {
|
|
221
|
+
const exec = scriptContent
|
|
222
|
+
.split('\n')
|
|
223
|
+
.map((line) => line.trimEnd())
|
|
224
|
+
.filter((line) => line.trim().length > 0);
|
|
225
|
+
return { type: 'text/javascript', exec };
|
|
226
|
+
}
|
|
227
|
+
buildQuery(value) {
|
|
228
|
+
if (!this.isRecord(value))
|
|
229
|
+
return [];
|
|
230
|
+
return Object.entries(value).map(([key, item]) => ({
|
|
231
|
+
key,
|
|
232
|
+
value: this.stringifyScalar(item),
|
|
233
|
+
}));
|
|
234
|
+
}
|
|
235
|
+
buildPathVariables(path, params) {
|
|
236
|
+
const names = this.extractPathVariables(path);
|
|
237
|
+
if (!names.length)
|
|
238
|
+
return [];
|
|
239
|
+
const paramsRecord = this.isRecord(params) ? params : {};
|
|
240
|
+
return names.map((name) => ({
|
|
241
|
+
key: name,
|
|
242
|
+
value: this.stringifyScalar(paramsRecord[name]),
|
|
243
|
+
}));
|
|
244
|
+
}
|
|
245
|
+
extractPathVariables(path) {
|
|
246
|
+
const matches = path.match(/\{\{([a-zA-Z_][a-zA-Z0-9_]*)\}\}/g);
|
|
247
|
+
return matches ? matches.map((entry) => entry.replace(/\{\{|\}\}/g, '')) : [];
|
|
248
|
+
}
|
|
249
|
+
extractPostmanPath(fullPath) {
|
|
250
|
+
return fullPath
|
|
251
|
+
.split('/')
|
|
252
|
+
.filter((segment) => segment.length > 0)
|
|
253
|
+
.map((segment) => segment.replace(/\{\{([a-zA-Z_][a-zA-Z0-9_]*)\}\}/g, ':$1'));
|
|
254
|
+
}
|
|
255
|
+
defaultStatusForMethod(method) {
|
|
256
|
+
if (method.toUpperCase() === 'POST')
|
|
257
|
+
return 201;
|
|
258
|
+
return 200;
|
|
259
|
+
}
|
|
260
|
+
stringifyScalar(value) {
|
|
261
|
+
if (value === undefined || value === null)
|
|
262
|
+
return '';
|
|
263
|
+
if (typeof value === 'string')
|
|
264
|
+
return value;
|
|
265
|
+
if (typeof value === 'number' || typeof value === 'boolean') {
|
|
266
|
+
return String(value);
|
|
267
|
+
}
|
|
268
|
+
return JSON.stringify(value);
|
|
269
|
+
}
|
|
270
|
+
isRecord(value) {
|
|
271
|
+
return (value !== null &&
|
|
272
|
+
typeof value === 'object' &&
|
|
273
|
+
Object.getPrototypeOf(value) === Object.prototype);
|
|
274
|
+
}
|
|
275
|
+
generateSummary(method, path) {
|
|
276
|
+
const action = method.toUpperCase();
|
|
277
|
+
const resource = this.extractResourceName(path);
|
|
278
|
+
const hasPathParam = path.includes('{{');
|
|
279
|
+
const actionMap = {
|
|
280
|
+
GET: hasPathParam ? `Get ${resource} by ID` : `Get all ${resource}`,
|
|
281
|
+
POST: `Create ${resource}`,
|
|
282
|
+
PUT: `Update ${resource}`,
|
|
283
|
+
PATCH: `Partially update ${resource}`,
|
|
284
|
+
DELETE: `Delete ${resource}`,
|
|
285
|
+
};
|
|
286
|
+
return actionMap[action] || `${action} ${resource}`;
|
|
287
|
+
}
|
|
288
|
+
generateDescription(method, path) {
|
|
289
|
+
const action = method.toLowerCase();
|
|
290
|
+
const resource = this.extractResourceName(path);
|
|
291
|
+
const hasPathParam = path.includes('{{');
|
|
292
|
+
const descriptions = {
|
|
293
|
+
get: hasPathParam
|
|
294
|
+
? `Retrieve a specific ${resource} by its ID`
|
|
295
|
+
: `Retrieve all ${resource} records`,
|
|
296
|
+
post: `Create a new ${resource} record`,
|
|
297
|
+
put: `Update an existing ${resource} record`,
|
|
298
|
+
patch: `Partially update an existing ${resource} record`,
|
|
299
|
+
delete: `Delete a ${resource} record`,
|
|
300
|
+
};
|
|
301
|
+
return descriptions[action] || `${action} operation on ${resource}`;
|
|
302
|
+
}
|
|
303
|
+
extractControllerFolderName(controllerPath) {
|
|
304
|
+
const cleaned = controllerPath.replace(/^\//, '').replace(/\/$/, '');
|
|
305
|
+
return cleaned || 'root';
|
|
306
|
+
}
|
|
307
|
+
extractResourceName(path) {
|
|
308
|
+
const segments = path.split('/').filter(Boolean);
|
|
309
|
+
let resource = segments[segments.length - 1] || 'Resource';
|
|
310
|
+
if (resource.startsWith('{{')) {
|
|
311
|
+
resource = segments[segments.length - 2] || 'Resource';
|
|
312
|
+
}
|
|
313
|
+
return resource.charAt(0).toUpperCase() + resource.slice(1);
|
|
314
|
+
}
|
|
315
|
+
getDefaultBaseUrl() {
|
|
316
|
+
const serverUrl = this.options.servers?.[0]?.url;
|
|
317
|
+
if (!serverUrl)
|
|
318
|
+
return 'http://localhost:3000';
|
|
319
|
+
return serverUrl.replace(/\/$/, '');
|
|
320
|
+
}
|
|
321
|
+
buildCollectionDescription() {
|
|
322
|
+
return [
|
|
323
|
+
this.options.description || 'API documentation for Mini Framework',
|
|
324
|
+
'',
|
|
325
|
+
'Contact Support:',
|
|
326
|
+
' Name: API Support',
|
|
327
|
+
' Email: support@example.com',
|
|
328
|
+
].join('\n');
|
|
329
|
+
}
|
|
330
|
+
generateCollectionId() {
|
|
331
|
+
if (typeof crypto !== 'undefined' &&
|
|
332
|
+
typeof crypto.randomUUID === 'function') {
|
|
333
|
+
return crypto.randomUUID();
|
|
334
|
+
}
|
|
335
|
+
return `mini-postman-${Date.now()}`;
|
|
336
|
+
}
|
|
337
|
+
basicAuthMiddleware(req, res, next) {
|
|
338
|
+
const auth = req.headers.authorization;
|
|
339
|
+
if (!auth || !auth.startsWith('Basic ')) {
|
|
340
|
+
res.setHeader('WWW-Authenticate', 'Basic realm="Postman Documentation"');
|
|
341
|
+
res.status(401).send('Authentication required');
|
|
342
|
+
return;
|
|
343
|
+
}
|
|
344
|
+
const credentials = Buffer.from(auth.substring(6), 'base64').toString();
|
|
345
|
+
const [username, password] = credentials.split(':');
|
|
346
|
+
if (username === this.options.basicAuth?.username &&
|
|
347
|
+
password === this.options.basicAuth?.password) {
|
|
348
|
+
next();
|
|
349
|
+
}
|
|
350
|
+
else {
|
|
351
|
+
res.setHeader('WWW-Authenticate', 'Basic realm="Postman Documentation"');
|
|
352
|
+
res.status(401).send('Invalid credentials');
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
exports.PostmanIntegration = PostmanIntegration;
|
|
357
|
+
exports.default = PostmanIntegration;
|
|
358
|
+
//# sourceMappingURL=postman.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"postman.js","sourceRoot":"","sources":["../../api-docs/postman.ts"],"names":[],"mappings":";;;AAAA,4BAA0B;AAG1B,4CAKsB;AAgGtB,MAAa,kBAAkB;IAI9B,YAAY,UAAsC,EAAE;QAH5C,sBAAiB,GAA6B,IAAI,CAAC;QAI1D,IAAI,CAAC,OAAO,GAAG;YACd,KAAK,EAAE,oBAAoB;YAC3B,WAAW,EAAE,sCAAsC;YACnD,OAAO,EAAE,OAAO;YAChB,OAAO,EAAE;gBACR,EAAE,GAAG,EAAE,uBAAuB,EAAE,WAAW,EAAE,oBAAoB,EAAE;aACnE;YACD,QAAQ,EAAE,eAAe;YACzB,mBAAmB,EAAE,SAAS;YAC9B,GAAG,OAAO;SACV,CAAC;IACH,CAAC;IAEM,yBAAyB,CAAC,WAAkB;QAClD,MAAM,OAAO,GAAG,IAAI,GAAG,EAAgC,CAAC;QACxD,MAAM,cAAc,GAAG,IAAI,CAAC,iBAAiB,EAAE,CAAC;QAChD,MAAM,mBAAmB,GAAG,IAAI,CAAC,OAAO,CAAC,mBAAmB,I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E,CAAC;QACR,CAAC;aAAM,CAAC;YACP,GAAG,CAAC,SAAS,CAAC,kBAAkB,EAAE,qCAAqC,CAAC,CAAC;YACzE,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,qBAAqB,CAAC,CAAC;QAC7C,CAAC;IACF,CAAC;CACD;AAvdD,gDAudC;AAED,kBAAe,kBAAkB,CAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import 'reflect-metadata';
|
|
2
2
|
import { Express } from 'express';
|
|
3
3
|
import { SwaggerOptions } from 'swagger-ui-express';
|
|
4
|
-
import { ISwaggerBasicAuth } from '
|
|
4
|
+
import { ISwaggerBasicAuth } from '../interfaces/config.interface';
|
|
5
5
|
export interface ISwaggerIntegrationOptions extends SwaggerOptions {
|
|
6
6
|
basicAuth?: ISwaggerBasicAuth;
|
|
7
7
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"swagger.d.ts","sourceRoot":"","sources":["../../api-docs/swagger.ts"],"names":[],"mappings":"AAAA,OAAO,kBAAkB,CAAC;AAE1B,OAAO,EAAE,OAAO,EAAmC,MAAM,SAAS,CAAC;AAGnE,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAC;AAGnE,MAAM,WAAW,0BAA2B,SAAQ,cAAc;IACjE,SAAS,CAAC,EAAE,iBAAiB,CAAC;CAC9B;AAED,qBAAa,kBAAkB;IAC9B,OAAO,CAAC,WAAW,CAAM;IACzB,OAAO,CAAC,OAAO,CAA6B;gBAEhC,OAAO,GAAE,0BAA+B;IAc7C,mBAAmB,CAAC,WAAW,EAAE,GAAG,EAAE;IA2S7C,OAAO,CAAC,eAAe;IAgBvB,OAAO,CAAC,mBAAmB;IAkB3B,OAAO,CAAC,oBAAoB;IAM5B,OAAO,CAAC,mBAAmB;IAY3B,OAAO,CAAC,qBAAqB;IAK7B,OAAO,CAAC,4BAA4B;IAKpC,OAAO,CAAC,mBAAmB;IAuBpB,YAAY,CAAC,GAAG,EAAE,OAAO;IAqCzB,cAAc;CAGrB;AAED,eAAe,kBAAkB,CAAC"}
|