@http-forge/core 0.2.15 → 0.2.18
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 +41 -0
- package/dist/index.js +173 -173
- package/dist/index.mjs +173 -173
- package/dist/infrastructure/openapi/openapi-exporter.d.ts +12 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -31,6 +31,8 @@
|
|
|
31
31
|
|
|
32
32
|
## 🎯 Installation
|
|
33
33
|
|
|
34
|
+
Requires Node.js `20+`.
|
|
35
|
+
|
|
34
36
|
```bash
|
|
35
37
|
npm install @http-forge/core
|
|
36
38
|
```
|
|
@@ -518,6 +520,38 @@ interface PathParamEntry {
|
|
|
518
520
|
}
|
|
519
521
|
```
|
|
520
522
|
|
|
523
|
+
### Postman Collection Import / Export
|
|
524
|
+
|
|
525
|
+
`CollectionService` can import and export Postman Collection v2.1 JSON files, preserving all request body types, auth, scripts, and folder structure.
|
|
526
|
+
|
|
527
|
+
**Import** (`importCollection(filePath)`):
|
|
528
|
+
|
|
529
|
+
Detects Postman format by `info._postman_id` and converts all five body modes:
|
|
530
|
+
|
|
531
|
+
| Postman `mode` | HTTP Forge `type` | Notes |
|
|
532
|
+
|---|---|---|
|
|
533
|
+
| `raw` | `raw` | `format` inferred from `options.raw.language` (json/xml/html/javascript/text) |
|
|
534
|
+
| `urlencoded` | `x-www-form-urlencoded` | Fields mapped to `[{key, value, enabled}]` |
|
|
535
|
+
| `formdata` | `form-data` | Fields mapped to `[{key, value, type, enabled}]` |
|
|
536
|
+
| `graphql` | `graphql` | `variables` JSON string parsed to object |
|
|
537
|
+
| `binary` | `binary` | File path not portable; imported with empty content |
|
|
538
|
+
|
|
539
|
+
Auth types `bearer`, `basic`, and `apikey` are converted. Pre-request and test scripts (`prerequest`/`test` events) are imported as `scripts.preRequest`/`scripts.postResponse`. Folder hierarchy and item order are preserved.
|
|
540
|
+
|
|
541
|
+
**Export** (`exportCollection(collectionId, filePath)`):
|
|
542
|
+
|
|
543
|
+
Converts back to Postman v2.1 JSON. All body types round-trip correctly: `x-www-form-urlencoded` exports as `mode: "urlencoded"`, `form-data` as `mode: "formdata"`, `graphql` as `mode: "graphql"`, and `binary` as `mode: "binary"`.
|
|
544
|
+
|
|
545
|
+
```typescript
|
|
546
|
+
const service = container.getCollectionService();
|
|
547
|
+
|
|
548
|
+
// Import
|
|
549
|
+
const collection = await service.importCollection('./my-api.postman_collection.json');
|
|
550
|
+
|
|
551
|
+
// Export
|
|
552
|
+
await service.exportCollection(collection.id, './exported.postman_collection.json');
|
|
553
|
+
```
|
|
554
|
+
|
|
521
555
|
### OpenAPI Import / Export
|
|
522
556
|
|
|
523
557
|
The core library includes full OpenAPI 3.0.3 import and export with constraint preservation.
|
|
@@ -529,6 +563,8 @@ The core library includes full OpenAPI 3.0.3 import and export with constraint p
|
|
|
529
563
|
|
|
530
564
|
**Export** (`OpenApiExporter`):
|
|
531
565
|
- Generates OpenAPI 3.0.3 specs from collections
|
|
566
|
+
- **Host-variable server resolution** — Any `{{varName}}` that prefixes a request URL (e.g. `{{dcqHost}}/api/...`) is stripped from the path and resolved to a server URL entry. If the variable resolves in the active environment(s), a concrete `url` is added to `servers`. If unresolvable, an OAS server-variable entry is emitted: `url: '{varName}', variables: { varName: { default: '' } }`. This handles arbitrary host variables beyond `{{baseUrl}}`.
|
|
567
|
+
- **Environment variable placeholder sanitization** — `{{varName}}` tokens in parameter examples (path, query, header) and request body examples are replaced with `<varName>` so the exported spec contains readable human placeholders rather than raw template syntax.
|
|
532
568
|
- **Collision-aware merging**: When multiple requests normalize to the same path + HTTP method, they are merged into a single operation:
|
|
533
569
|
- Descriptions are appended, tags are unioned
|
|
534
570
|
- Parameters with the **same constraint kind** (both enum, both pattern, etc.) are merged in-place (union enum values, widen numeric ranges, alternation-join patterns)
|
|
@@ -733,6 +769,11 @@ MIT © Henry Huang
|
|
|
733
769
|
- ✅ **`duplicateFolder(collectionId, folderId, newName)`** — Duplicates a folder within a collection, preserving all nested request content
|
|
734
770
|
- ✅ **`getItemPath(collectionId, itemId)`** — Resolves the disk path of a folder or request within a collection
|
|
735
771
|
|
|
772
|
+
### 0.2.6 (OpenAPI Export — Environment Variable Handling)
|
|
773
|
+
|
|
774
|
+
- ✅ **Host-variable URL stripping** — Any leading `{{varName}}` in a request URL (e.g. `{{dcqHost}}/DCQ/templates/GetEpg`) is now correctly stripped from the path. The variable name is resolved via `envConfigService.resolveVariables()` and the resulting URL is added to `servers`. When the variable cannot be resolved, an OAS server-variable entry (`url: '{varName}', variables: { varName: { default: '' } }`) is emitted instead. Previously, unknown host variables were converted to `/{varName}/...` path segments.
|
|
775
|
+
- ✅ **Example sanitization** — `{{varName}}` placeholders in parameter examples (path, query, header) and request body examples are replaced with `<varName>` so they render as readable human placeholders instead of raw template syntax in the exported spec.
|
|
776
|
+
|
|
736
777
|
### 0.2.5 (OpenAPI Constraint Round-Trip & Collision Merging)
|
|
737
778
|
|
|
738
779
|
- ✅ **Full parameter constraint round-trip** — OpenAPI import/export now preserves all schema constraint fields: `pattern`, `minimum`, `maximum`, `exclusiveMinimum`, `exclusiveMaximum`, `minLength`, `maxLength`, and `oneOf` on both `KeyValueEntry` and `PathParamEntry`
|