@mini2/core 2.0.1-beta.4 → 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/package.json +1 -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
|
|
package/package.json
CHANGED
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"license": "ISC",
|
|
27
27
|
"description": "Mini Express Framework - Lightweight and modular Express.js framework with TypeScript support",
|
|
28
28
|
"name": "@mini2/core",
|
|
29
|
-
"version": "2.0.1-beta.
|
|
29
|
+
"version": "2.0.1-beta.5",
|
|
30
30
|
"author": "Mustafa Çolakoglu <mustafacolakoglu94@gmail.com> (https://github.com/mustafa-colakoglu)",
|
|
31
31
|
"dependencies": {
|
|
32
32
|
"class-transformer": "^0.5.1",
|