@http-forge/core 0.2.5 → 0.2.6

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 CHANGED
@@ -470,6 +470,97 @@ interface HttpResponse {
470
470
  }
471
471
  ```
472
472
 
473
+ ### KeyValueEntry
474
+
475
+ Used for headers and query parameters in `CollectionRequest`. Supports OpenAPI metadata for generation and validation.
476
+
477
+ ```typescript
478
+ interface KeyValueEntry {
479
+ key: string;
480
+ value: string;
481
+ enabled?: boolean;
482
+ // OpenAPI metadata (all optional, backward-compatible)
483
+ type?: 'string' | 'integer' | 'number' | 'boolean' | 'array';
484
+ required?: boolean;
485
+ description?: string;
486
+ format?: string; // Semantic hint (e.g. "uuid", "date-time")
487
+ enum?: string[]; // Allowed values
488
+ deprecated?: boolean;
489
+ // Extended constraint fields for full OpenAPI 3.0 round-trip
490
+ // String constraints
491
+ pattern?: string; // Regex validation pattern
492
+ minLength?: number;
493
+ maxLength?: number;
494
+ // Numeric constraints (integer / number)
495
+ minimum?: number;
496
+ maximum?: number;
497
+ exclusiveMinimum?: boolean; // OpenAPI 3.0: boolean modifier on minimum (strict >)
498
+ exclusiveMaximum?: boolean; // OpenAPI 3.0: boolean modifier on maximum (strict <)
499
+ multipleOf?: number;
500
+ // Array constraints
501
+ minItems?: number;
502
+ maxItems?: number;
503
+ uniqueItems?: boolean;
504
+ // Common
505
+ nullable?: boolean;
506
+ oneOf?: Array<Record<string, any>>; // Merged constraint variants
507
+ }
508
+ ```
509
+
510
+ ### PathParamEntry
511
+
512
+ Used for path parameters (`:param` in URLs). Same constraint fields as `KeyValueEntry` minus `key`/`enabled`.
513
+
514
+ ```typescript
515
+ interface PathParamEntry {
516
+ value: string;
517
+ type?: 'string' | 'integer' | 'number' | 'boolean';
518
+ description?: string;
519
+ format?: string;
520
+ enum?: string[];
521
+ deprecated?: boolean;
522
+ // String constraints
523
+ pattern?: string;
524
+ minLength?: number;
525
+ maxLength?: number;
526
+ // Numeric constraints
527
+ minimum?: number;
528
+ maximum?: number;
529
+ exclusiveMinimum?: boolean; // OpenAPI 3.0: boolean modifier (strict >)
530
+ exclusiveMaximum?: boolean; // OpenAPI 3.0: boolean modifier (strict <)
531
+ multipleOf?: number;
532
+ // Array constraints
533
+ minItems?: number;
534
+ maxItems?: number;
535
+ uniqueItems?: boolean;
536
+ // Common
537
+ nullable?: boolean;
538
+ oneOf?: Array<Record<string, any>>;
539
+ }
540
+ ```
541
+
542
+ ### OpenAPI Import / Export
543
+
544
+ The core library includes full OpenAPI 3.0.3 import and export with constraint preservation.
545
+
546
+ **Import** (`OpenApiImporter`):
547
+ - Parses OpenAPI 3.0 YAML/JSON specs into `UnifiedCollection`
548
+ - Extracts all parameter schema constraints: `type`, `format`, `pattern`, `enum`, `minimum`, `maximum`, `exclusiveMinimum`, `exclusiveMaximum` (booleans), `multipleOf`, `minLength`, `maxLength`, `minItems`, `maxItems`, `uniqueItems`, `nullable`
549
+ - Preserves `oneOf` schemas from merged parameters, deriving combined enum hints for UI display
550
+ - Sets `hasMetadata` flag when any constraint or description field is present
551
+
552
+ **Export** (`OpenApiExporter`):
553
+ - Generates OpenAPI 3.0.3 specs from collections
554
+ - `exclusiveMinimum`/`exclusiveMaximum` exported as booleans (OpenAPI 3.0 semantics)
555
+ - **Collision-aware merging** via `mergeParameterSchema()`: When multiple requests normalize to the same path + HTTP method, they are merged into a single operation:
556
+ - Descriptions are appended, tags are unioned
557
+ - **Existing has `oneOf`** → incoming constraints appended as a new variant
558
+ - **Incoming has `oneOf`** → existing schema wrapped as single variant, incoming variants flattened in
559
+ - **Both simple, same constraint kind** (both enum, both pattern, etc.) → merged in-place (union enum values, widen numeric ranges, alternation-join patterns)
560
+ - **Both simple, different constraint kinds** → wrapped in `oneOf` — each variant keeps its self-consistent schema
561
+ - `stripConstraints()` called after **all** merge branches to prevent stale fields (e.g. `enum`) leaking alongside `oneOf`
562
+ - All constraint fields round-trip without data loss
563
+
473
564
  ## 🛠️ Use Cases
474
565
 
475
566
  ### CLI Tool
@@ -662,6 +753,13 @@ MIT © Henry Huang
662
753
 
663
754
  ## 📝 Changelog
664
755
 
756
+ ### 0.2.5 (OpenAPI Constraint Round-Trip & Collision Merging)
757
+
758
+ - ✅ **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`
759
+ - ✅ **Collision-aware OpenAPI export** — When multiple requests normalize to the same path + HTTP method, the exporter merges them into a single operation with intelligent parameter schema merging (same-kind merge in-place, different-kind wraps in `oneOf`)
760
+ - ✅ **`oneOf` import with UI hints** — `applyOneOfHints()` derives combined enum arrays and type hints from `oneOf` variants for downstream UI rendering (combobox vs strict dropdown)
761
+ - ✅ **`format` vs `pattern` separation** — `format` is a semantic hint (e.g. `"uuid"`), `pattern` is an enforced regex. Both stored and round-tripped independently
762
+
665
763
  ### 0.2.4 (File Watching & Request Documentation)
666
764
 
667
765
  - ✅ **File watching for CollectionService** - Automatic reload and `onCollectionsChanged` callback when collection files change on disk