@speclynx/apidom-reference 2.6.0 → 2.7.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.
Files changed (56) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/README.md +60 -33
  3. package/dist/apidom-reference.browser.js +79395 -79177
  4. package/dist/apidom-reference.browser.min.js +1 -1
  5. package/package.json +25 -25
  6. package/src/bundle/index.cjs +1 -1
  7. package/src/bundle/index.mjs +1 -1
  8. package/src/configuration/saturated.cjs +2 -4
  9. package/src/configuration/saturated.mjs +3 -5
  10. package/src/dereference/index.cjs +1 -1
  11. package/src/dereference/index.mjs +1 -1
  12. package/src/dereference/strategies/arazzo-1/index.cjs +10 -0
  13. package/src/dereference/strategies/arazzo-1/index.mjs +10 -0
  14. package/src/dereference/strategies/arazzo-1/source-description.cjs +179 -0
  15. package/src/dereference/strategies/arazzo-1/source-description.mjs +172 -0
  16. package/src/dereference/strategies/openapi-3-0/visitor.cjs +3 -3
  17. package/src/dereference/strategies/openapi-3-0/visitor.mjs +3 -3
  18. package/src/dereference/strategies/openapi-3-1/visitor.cjs +3 -3
  19. package/src/dereference/strategies/openapi-3-1/visitor.mjs +3 -3
  20. package/src/errors/InvalidJsonSchema$anchorError.cjs +1 -1
  21. package/src/errors/InvalidJsonSchema$anchorError.mjs +1 -1
  22. package/src/errors/UnmatchedParserError.cjs +11 -0
  23. package/src/errors/UnmatchedParserError.mjs +6 -0
  24. package/src/index.cjs +3 -1
  25. package/src/index.mjs +1 -0
  26. package/src/parse/index.cjs +3 -3
  27. package/src/parse/index.mjs +3 -3
  28. package/src/parse/parsers/arazzo-json-1/index.cjs +1 -4
  29. package/src/parse/parsers/arazzo-json-1/index.mjs +1 -4
  30. package/src/parse/parsers/arazzo-json-1/source-description.cjs +14 -19
  31. package/src/parse/parsers/arazzo-json-1/source-description.mjs +14 -20
  32. package/src/parse/parsers/arazzo-yaml-1/index.cjs +1 -4
  33. package/src/parse/parsers/arazzo-yaml-1/index.mjs +1 -4
  34. package/src/resolve/index.cjs +2 -2
  35. package/src/resolve/index.mjs +2 -2
  36. package/src/resolve/resolvers/file/index-browser.cjs +1 -1
  37. package/src/resolve/resolvers/file/index-browser.mjs +1 -1
  38. package/src/resolve/strategies/apidom/index.cjs +1 -1
  39. package/src/resolve/strategies/apidom/index.mjs +1 -1
  40. package/src/resolve/strategies/asyncapi-2/index.cjs +1 -1
  41. package/src/resolve/strategies/asyncapi-2/index.mjs +1 -1
  42. package/src/resolve/strategies/openapi-2/index.cjs +1 -1
  43. package/src/resolve/strategies/openapi-2/index.mjs +1 -1
  44. package/src/resolve/strategies/openapi-3-0/index.cjs +1 -1
  45. package/src/resolve/strategies/openapi-3-0/index.mjs +1 -1
  46. package/src/resolve/strategies/openapi-3-1/index.cjs +1 -1
  47. package/src/resolve/strategies/openapi-3-1/index.mjs +1 -1
  48. package/src/resolve/util.cjs +1 -1
  49. package/src/resolve/util.mjs +1 -1
  50. package/types/apidom-reference.d.ts +6 -0
  51. package/types/dereference/strategies/arazzo-1/source-description.d.ts +8 -0
  52. package/types/errors/UnmatchedParserError.d.ts +7 -0
  53. package/types/index.d.ts +1 -0
  54. package/types/parse/parsers/arazzo-json-1/index.d.ts +0 -3
  55. package/types/parse/parsers/arazzo-json-1/source-description.d.ts +1 -6
  56. package/types/parse/parsers/arazzo-yaml-1/index.d.ts +0 -3
package/CHANGELOG.md CHANGED
@@ -3,6 +3,19 @@
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
+ # [2.7.0](https://github.com/speclynx/apidom/compare/v2.6.1...v2.7.0) (2026-02-05)
7
+
8
+ ### Features
9
+
10
+ - **reference:** add support for Arazzo Source Description dereferencing ([#69](https://github.com/speclynx/apidom/issues/69)) ([87efee9](https://github.com/speclynx/apidom/commit/87efee95b86ab6f947ef908db6225b9bb60d7a40))
11
+
12
+ ## [2.6.1](https://github.com/speclynx/apidom/compare/v2.6.0...v2.6.1) (2026-02-04)
13
+
14
+ ### Bug Fixes
15
+
16
+ - **reference:** enhance error messages ([#67](https://github.com/speclynx/apidom/issues/67)) ([4d73e5f](https://github.com/speclynx/apidom/commit/4d73e5fd4dbff6bfd222d4ba821c004250e82662))
17
+ - **reference:** throw UnmatchedParserError on empty parser match ([#66](https://github.com/speclynx/apidom/issues/66)) ([ce99b42](https://github.com/speclynx/apidom/commit/ce99b421fb8dfc91541ca74aefb06cd3bcfd777c))
18
+
6
19
  # [2.6.0](https://github.com/speclynx/apidom/compare/v2.5.1...v2.6.0) (2026-02-03)
7
20
 
8
21
  ### Features
package/README.md CHANGED
@@ -292,25 +292,6 @@ Supported media types are:
292
292
  ]
293
293
  ```
294
294
 
295
- ##### Constructor options
296
-
297
- In addition to standard parser plugin options (`allowEmpty`, `sourceMap`, etc.), this parser accepts:
298
-
299
- - **parseFn** - A function used to parse source descriptions. When provided, enables the `sourceDescriptions` feature.
300
- In saturated configuration, this is automatically set to the `parse` function.
301
-
302
- ```js
303
- import { parse } from '@speclynx/apidom-reference';
304
- import ArazzoJSON1Parser from '@speclynx/apidom-reference/parse/parsers/arazzo-json-1';
305
-
306
- // Create parser with parseFn to enable source descriptions feature
307
- const parser = new ArazzoJSON1Parser({
308
- allowEmpty: true,
309
- sourceMap: false,
310
- parseFn: parse, // pass the parse function to enable recursive parsing
311
- });
312
- ```
313
-
314
295
  ##### Parser options
315
296
 
316
297
  The following options can be passed via `parse.parserOpts` (globally) or `parse.parserOpts['arazzo-json-1']` (parser-specific).
@@ -337,7 +318,7 @@ with an `'error'` class within the parse result:
337
318
  an error annotation is returned for that specific source description while other source descriptions
338
319
  continue to be processed
339
320
  - **Validation warnings** - Warning annotations (with `'warning'` class) are returned when prerequisites
340
- for parsing are not met (e.g., API is not an Arazzo specification, `parseFn` not configured)
321
+ for parsing are not met (e.g., API is not an Arazzo specification)
341
322
 
342
323
  ```js
343
324
  import { parse } from '@speclynx/apidom-reference';
@@ -386,13 +367,6 @@ Supported media types are:
386
367
  ]
387
368
  ```
388
369
 
389
- ##### Constructor options
390
-
391
- In addition to standard parser plugin options (`allowEmpty`, `sourceMap`, etc.), this parser accepts:
392
-
393
- - **parseFn** - A function used to parse source descriptions. When provided, enables the `sourceDescriptions` feature.
394
- In saturated configuration, this is automatically set to the `parse` function.
395
-
396
370
  ##### Parser options
397
371
 
398
372
  The following options can be passed via `parse.parserOpts` (globally) or `parse.parserOpts['arazzo-yaml-1']` (parser-specific).
@@ -468,8 +442,8 @@ returns `true` or until entire list of parser plugins is exhausted (throws error
468
442
  new OpenAPIYAML3_1Parser({ allowEmpty: true, sourceMap: false }),
469
443
  new AsyncAPIJSON2Parser({ allowEmpty: true, sourceMap: false }),
470
444
  new AsyncAPIYAML2Parser({ allowEmpty: true, sourceMap: false }),
471
- new ArazzoJSON1Parser({ allowEmpty: true, sourceMap: false, parseFn: parse }),
472
- new ArazzoYAML1Parser({ allowEmpty: true, sourceMap: false, parseFn: parse }),
445
+ new ArazzoJSON1Parser({ allowEmpty: true, sourceMap: false }),
446
+ new ArazzoYAML1Parser({ allowEmpty: true, sourceMap: false }),
473
447
  new APIDesignSystemsJSONParser({ allowEmpty: true, sourceMap: false }),
474
448
  new APIDesignSystemsYAMLParser({ allowEmpty: true, sourceMap: false }),
475
449
  new APIDOMJSONParser({ allowEmpty: true, sourceMap: false }),
@@ -509,8 +483,8 @@ options.parse.parsers = [
509
483
  new OpenAPIYAML3_1Parser({ allowEmpty: true, sourceMap: false }),
510
484
  new AsyncAPIJSON2Parser({ allowEmpty: true, sourceMap: false }),
511
485
  new AsyncAPIYAML2Parser({ allowEmpty: true, sourceMap: false }),
512
- new ArazzoJSON1Parser({ allowEmpty: true, sourceMap: false, parseFn: parse }),
513
- new ArazzoYAML1Parser({ allowEmpty: true, sourceMap: false, parseFn: parse }),
486
+ new ArazzoJSON1Parser({ allowEmpty: true, sourceMap: false }),
487
+ new ArazzoYAML1Parser({ allowEmpty: true, sourceMap: false }),
514
488
  new APIDesignSystemsJSONParser({ allowEmpty: true, sourceMap: false }),
515
489
  new APIDesignSystemsYAMLParser({ allowEmpty: true, sourceMap: false }),
516
490
  new APIDOMJSONParser({ allowEmpty: true, sourceMap: false }),
@@ -551,8 +525,8 @@ await parse('/home/user/oas.json', {
551
525
  new OpenAPIYAML3_1Parser({ allowEmpty: true, sourceMap: false }),
552
526
  new AsyncAPIJSON2Parser({ allowEmpty: true, sourceMap: false }),
553
527
  new AsyncAPIYAML2Parser({ allowEmpty: true, sourceMap: false }),
554
- new ArazzoJSON1Parser({ allowEmpty: true, sourceMap: false, parseFn: parse }),
555
- new ArazzoYAML1Parser({ allowEmpty: true, sourceMap: false, parseFn: parse }),
528
+ new ArazzoJSON1Parser({ allowEmpty: true, sourceMap: false }),
529
+ new ArazzoYAML1Parser({ allowEmpty: true, sourceMap: false }),
556
530
  new APIDesignSystemsJSONParser({ allowEmpty: true, sourceMap: false }),
557
531
  new APIDesignSystemsYAMLParser({ allowEmpty: true, sourceMap: false }),
558
532
  new APIDOMJSONParser({ allowEmpty: true, sourceMap: false }),
@@ -1650,6 +1624,59 @@ Supported media types:
1650
1624
  ]
1651
1625
  ```
1652
1626
 
1627
+ ###### Strategy options
1628
+
1629
+ The following options can be passed via `dereference.strategyOpts` (globally) or `dereference.strategyOpts['arazzo-1']` (strategy-specific).
1630
+ Strategy-specific options take precedence over global options.
1631
+
1632
+ - **sourceDescriptions** - Controls which external source descriptions are dereferenced and included in the result.
1633
+ - `true` - dereference all source descriptions
1634
+ - `string[]` - dereference only source descriptions with matching names (e.g., `['petStore', 'paymentApi']`)
1635
+
1636
+ Each dereferenced source description is added with a `'source-description'` class and metadata (`name`, `type`).
1637
+ Only OpenAPI 2.0, OpenAPI 3.0.x, OpenAPI 3.1.x, and Arazzo 1.x documents are accepted as source descriptions.
1638
+ - **sourceDescriptionsMaxDepth** - Maximum recursion depth for dereferencing nested Arazzo source descriptions.
1639
+ Defaults to `+Infinity`. Circular references are automatically detected and skipped.
1640
+
1641
+ ###### Error handling
1642
+
1643
+ The source descriptions dereferencing uses annotations instead of throwing errors, allowing dereferencing to continue
1644
+ even when individual source descriptions fail. Errors are reported as `AnnotationElement` instances
1645
+ with an `'error'` class within the result:
1646
+
1647
+ - **Max depth exceeded** - When `sourceDescriptionsMaxDepth` is reached, an error annotation is returned
1648
+ instead of the nested source descriptions
1649
+ - **Dereference failures** - If a source description file cannot be dereferenced (e.g., file not found, invalid syntax),
1650
+ an error annotation is returned for that specific source description while other source descriptions
1651
+ continue to be processed
1652
+ - **Validation warnings** - Warning annotations (with `'warning'` class) are returned when the dereferenced document
1653
+ is not an OpenAPI or Arazzo specification
1654
+
1655
+ ```js
1656
+ import { dereference } from '@speclynx/apidom-reference';
1657
+
1658
+ // Dereference all source descriptions
1659
+ const result = await dereference('/path/to/arazzo.json', {
1660
+ dereference: {
1661
+ strategyOpts: {
1662
+ sourceDescriptions: true,
1663
+ sourceDescriptionsMaxDepth: 10,
1664
+ },
1665
+ },
1666
+ });
1667
+
1668
+ // Dereference only specific source descriptions by name
1669
+ const resultFiltered = await dereference('/path/to/arazzo.json', {
1670
+ dereference: {
1671
+ strategyOpts: {
1672
+ 'arazzo-1': {
1673
+ sourceDescriptions: ['petStore', 'paymentApi'],
1674
+ },
1675
+ },
1676
+ },
1677
+ });
1678
+ ```
1679
+
1653
1680
  ##### [openapi-2](https://github.com/speclynx/apidom/tree/main/packages/apidom-reference/src/dereference/strategies/openapi-2)
1654
1681
 
1655
1682
  Dereference strategy for dereferencing [OpenApi 2.0](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/2.0.md) definitions.