@speclynx/apidom-reference 4.12.1 → 4.14.0

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/CHANGELOG.md CHANGED
@@ -3,6 +3,18 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ # [4.14.0](https://github.com/speclynx/apidom/compare/v4.13.0...v4.14.0) (2026-06-23)
7
+
8
+ ### Features
9
+
10
+ - **reference:** add OpenAPI 3.1 bundle strategy ([#361](https://github.com/speclynx/apidom/issues/361)) ([ab3effb](https://github.com/speclynx/apidom/commit/ab3effb7d1f19ae4d757ba222b194e477e64d6e8)), closes [#351](https://github.com/speclynx/apidom/issues/351)
11
+
12
+ # [4.13.0](https://github.com/speclynx/apidom/compare/v4.12.1...v4.13.0) (2026-06-23)
13
+
14
+ ### Features
15
+
16
+ - **reference:** add OpenAPI 2.0 bundle strategy ([#360](https://github.com/speclynx/apidom/issues/360)) ([29a1b3f](https://github.com/speclynx/apidom/commit/29a1b3f05ecdf12bf9003af96e19c6dedb4e310f)), closes [#351](https://github.com/speclynx/apidom/issues/351)
17
+
6
18
  ## [4.12.1](https://github.com/speclynx/apidom/compare/v4.12.0...v4.12.1) (2026-06-23)
7
19
 
8
20
  **Note:** Version bump only for package @speclynx/apidom-reference
package/README.md CHANGED
@@ -2707,7 +2707,59 @@ await bundle('https://raw.githubusercontent.com/OAI/OpenAPI-Specification/main/e
2707
2707
  #### [Bundle strategies](https://github.com/speclynx/apidom/tree/main/packages/apidom-reference/src/bundle/strategies)
2708
2708
 
2709
2709
  Bundle strategy determines how a document is bundled into a Compound Document. Depending on document `mediaType` option,
2710
- every strategy differs significantly. `Bundle component` comes with two (2) default bundle strategies.
2710
+ every strategy differs significantly. `Bundle component` comes with three (3) default bundle strategies.
2711
+
2712
+ ##### [openapi-2](https://github.com/speclynx/apidom/tree/main/packages/apidom-reference/src/bundle/strategies/openapi-2)
2713
+
2714
+ Bundle strategy for bundling [OpenAPI 2.0](https://spec.openapis.org/oas/v2.0.html) (Swagger) definitions.
2715
+
2716
+ It produces a self-contained, transferable Compound Document: every external reference is resolved and lifted
2717
+ into the matching top-level definition field, and the referencing `$ref` is rewritten to an internal JSON
2718
+ Pointer. Unlike OpenAPI 3.x, OpenAPI 2.0 has no single Components Object — reusable definitions live directly
2719
+ under the document root, so the three hoist targets are:
2720
+
2721
+ - external Schema Objects (JSON References) → `definitions`
2722
+ - external Parameter Objects → `parameters`
2723
+ - external Response Objects → `responses`
2724
+
2725
+ External Path Item Objects have no definition field to hold them, so they are inlined in place (after bundling
2726
+ their own external references); a circular external Path Item retains its cycle-breaking `$ref` rather than
2727
+ collapsing to an empty object. Multiple references to the **same** external target (same document URI and JSON
2728
+ Pointer) are collapsed into a single component; distinct targets each get their own component, even when their
2729
+ content happens to be identical. Internal references are preserved untouched; only a self-file reference (e.g.
2730
+ `./root.json#/definitions/Pet`) is normalized to a bare fragment (`#/definitions/Pet`) so the bundled document
2731
+ remains transferable.
2732
+
2733
+ Supported media types:
2734
+
2735
+ ```js
2736
+ [
2737
+ 'application/vnd.oai.openapi;version=2.0',
2738
+ 'application/vnd.oai.openapi+json;version=2.0',
2739
+ 'application/vnd.oai.openapi+yaml;version=2.0'
2740
+ ]
2741
+ ```
2742
+
2743
+ This strategy's behavior is controlled by the same `bundle` options as the `openapi-3-0` strategy
2744
+ (`componentNamesStrategy`, `onComponentNameCollision`, `immutable`, `maxDepth`, `continueOnError`, `refSet`),
2745
+ documented below. Per-strategy overrides use the `openapi-2` key in `bundle.strategyOpts`:
2746
+
2747
+ ```js
2748
+ import { bundle } from '@speclynx/apidom-reference';
2749
+
2750
+ await bundle('/home/user/swagger.json', {
2751
+ parse: {
2752
+ mediaType: 'application/vnd.oai.openapi+json;version=2.0',
2753
+ },
2754
+ bundle: {
2755
+ strategyOpts: {
2756
+ 'openapi-2': {
2757
+ onComponentNameCollision: 'error',
2758
+ },
2759
+ },
2760
+ },
2761
+ });
2762
+ ```
2711
2763
 
2712
2764
  ##### [openapi-3-0](https://github.com/speclynx/apidom/tree/main/packages/apidom-reference/src/bundle/strategies/openapi-3-0)
2713
2765
 
@@ -2811,9 +2863,27 @@ the original.
2811
2863
 
2812
2864
  Bundle strategy for bundling [OpenApi 3.1.x](https://spec.openapis.org/oas/v3.1.2.html) definitions.
2813
2865
 
2814
- > **Note:** this strategy is **not implemented yet**. It matches OpenAPI 3.1.x
2815
- > documents but currently returns the parse result unchanged (no references are
2816
- > resolved or hoisted). For real bundling, use OpenAPI 3.0.x for now.
2866
+ It produces a self-contained, transferable Compound Document. **Reference Objects** are bundled exactly as
2867
+ in the `openapi-3-0` strategy: every external reference is resolved and lifted into the appropriate
2868
+ `components` field, and the referencing `$ref` is rewritten to an internal JSON Pointer. The one upgrade
2869
+ over 3.0 is **Path Item Objects** — OpenAPI 3.1 adds a `components.pathItems` field, so an external Path
2870
+ Item is hoisted there (and its `$ref` rewritten to `#/components/pathItems/<name>`) instead of being
2871
+ inlined in place. Example Object `externalValue` content is inlined, and an external Link Object
2872
+ `operationRef` is rewritten to an absolute URI so the link stays resolvable.
2873
+
2874
+ **Schema Objects** are a [JSON Schema 2020-12](https://json-schema.org/draft/2020-12) dialect and are
2875
+ bundled per the [JSON Schema Compound Document](https://json-schema.org/blog/posts/bundling-json-schema-compound-documents)
2876
+ rules: the external schema **resource** is embedded verbatim into `components.schemas` carrying its `$id`
2877
+ (one is assigned from the retrieval URI when absent), and the referencing `$ref` is left **unchanged** — it
2878
+ keeps resolving against the embedded resource's `$id`. The whole external resource is embedded once, keyed by
2879
+ its `$id`; references (including `$anchor`, `$dynamicRef`, and `$dynamicAnchor`) are never rewritten. Nested
2880
+ external schema resources are embedded flat into the top-level `components.schemas`, deduplicated by resource
2881
+ URI. Internal Schema Object references are preserved untouched.
2882
+
2883
+ Multiple references to the **same** external target are collapsed into a single component; distinct targets
2884
+ each get their own component, even when their content happens to be identical. Internal Reference Objects are
2885
+ preserved untouched; only a self-file reference (e.g. `./root.json#/components/parameters/userId`) is
2886
+ normalized to a bare fragment (`#/components/parameters/userId`) so the bundled document remains transferable.
2817
2887
 
2818
2888
  Supported media types:
2819
2889
 
@@ -2831,6 +2901,30 @@ Supported media types:
2831
2901
  ]
2832
2902
  ```
2833
2903
 
2904
+ This strategy's behavior is controlled by the same `bundle` options as the `openapi-3-0` strategy
2905
+ (`componentNamesStrategy`, `onComponentNameCollision`, `immutable`, `maxDepth`, `continueOnError`, `refSet`),
2906
+ documented above. Per-strategy overrides use the `openapi-3-1` key in `bundle.strategyOpts`:
2907
+
2908
+ ```js
2909
+ import { bundle } from '@speclynx/apidom-reference';
2910
+
2911
+ await bundle('/home/user/oas.json', {
2912
+ parse: {
2913
+ mediaType: 'application/openapi+json;version=3.1.0',
2914
+ },
2915
+ bundle: {
2916
+ strategyOpts: {
2917
+ 'openapi-3-1': {
2918
+ onComponentNameCollision: 'error',
2919
+ },
2920
+ },
2921
+ },
2922
+ });
2923
+ ```
2924
+
2925
+ Hoisted components and embedded schema resources are annotated with a `ref-origin` meta field pointing at
2926
+ their source document. The bundling process is **immutable** by default (`bundle.immutable: true`).
2927
+
2834
2928
  ##### Bundle strategies execution order
2835
2929
 
2836
2930
  It's important to understand that default bundle strategies are run in specific order. The order is determined
@@ -2843,6 +2937,7 @@ returns `true` or until entire list of strategies is exhausted (throws error).
2843
2937
 
2844
2938
  ```js
2845
2939
  [
2940
+ new OpenAPI2BundleStrategy(),
2846
2941
  new OpenAPI3_0BundleStrategy(),
2847
2942
  new OpenAPI3_1BundleStrategy(),
2848
2943
  ]