@speclynx/apidom-reference 6.2.0 → 7.0.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 (91) hide show
  1. package/CHANGELOG.md +49 -0
  2. package/README.md +45 -0
  3. package/dist/apidom-reference.browser.js +4701 -3478
  4. package/dist/apidom-reference.browser.min.js +1 -1
  5. package/package.json +29 -28
  6. package/src/File.cjs +5 -2
  7. package/src/File.mjs +5 -2
  8. package/src/bundle/strategies/arazzo-1/index.cjs +3 -2
  9. package/src/bundle/strategies/arazzo-1/index.mjs +3 -2
  10. package/src/bundle/strategies/asyncapi-2/index.cjs +3 -2
  11. package/src/bundle/strategies/asyncapi-2/index.mjs +3 -2
  12. package/src/bundle/strategies/openapi-2/index.cjs +3 -2
  13. package/src/bundle/strategies/openapi-2/index.mjs +3 -2
  14. package/src/bundle/strategies/openapi-3-0/index.cjs +3 -2
  15. package/src/bundle/strategies/openapi-3-0/index.mjs +3 -2
  16. package/src/bundle/strategies/openapi-3-1/index.cjs +3 -2
  17. package/src/bundle/strategies/openapi-3-1/index.mjs +3 -2
  18. package/src/dereference/strategies/DereferenceVisitor.cjs +588 -0
  19. package/src/dereference/strategies/DereferenceVisitor.mjs +580 -0
  20. package/src/dereference/strategies/arazzo-1/index.cjs +14 -39
  21. package/src/dereference/strategies/arazzo-1/index.mjs +15 -40
  22. package/src/dereference/strategies/arazzo-1/visitor.cjs +207 -331
  23. package/src/dereference/strategies/arazzo-1/visitor.mjs +215 -338
  24. package/src/dereference/strategies/asyncapi-2/index.cjs +11 -39
  25. package/src/dereference/strategies/asyncapi-2/index.mjs +11 -39
  26. package/src/dereference/strategies/asyncapi-2/visitor.cjs +133 -425
  27. package/src/dereference/strategies/asyncapi-2/visitor.mjs +137 -429
  28. package/src/dereference/strategies/openapi-2/index.cjs +12 -42
  29. package/src/dereference/strategies/openapi-2/index.mjs +12 -42
  30. package/src/dereference/strategies/openapi-2/visitor.cjs +168 -532
  31. package/src/dereference/strategies/openapi-2/visitor.mjs +172 -536
  32. package/src/dereference/strategies/openapi-3-0/index.cjs +12 -42
  33. package/src/dereference/strategies/openapi-3-0/index.mjs +12 -42
  34. package/src/dereference/strategies/openapi-3-0/visitor.cjs +194 -468
  35. package/src/dereference/strategies/openapi-3-0/visitor.mjs +199 -473
  36. package/src/dereference/strategies/openapi-3-1/index.cjs +16 -42
  37. package/src/dereference/strategies/openapi-3-1/index.mjs +16 -42
  38. package/src/dereference/strategies/openapi-3-1/visitor.cjs +350 -602
  39. package/src/dereference/strategies/openapi-3-1/visitor.mjs +357 -608
  40. package/src/dereference/strategies/overlay-1/index.cjs +3 -2
  41. package/src/dereference/strategies/overlay-1/index.mjs +3 -2
  42. package/src/index.cjs +0 -7
  43. package/src/index.mjs +0 -1
  44. package/src/parse/index.cjs +9 -1
  45. package/src/parse/index.mjs +9 -1
  46. package/src/parse/parsers/apidom-json/index.cjs +2 -1
  47. package/src/parse/parsers/apidom-json/index.mjs +2 -1
  48. package/src/parse/parsers/arazzo-json-1/index.cjs +2 -1
  49. package/src/parse/parsers/arazzo-json-1/index.mjs +2 -1
  50. package/src/parse/parsers/arazzo-yaml-1/index.cjs +2 -1
  51. package/src/parse/parsers/arazzo-yaml-1/index.mjs +2 -1
  52. package/src/parse/parsers/asyncapi-json-2/index.cjs +2 -1
  53. package/src/parse/parsers/asyncapi-json-2/index.mjs +2 -1
  54. package/src/parse/parsers/asyncapi-yaml-2/index.cjs +2 -1
  55. package/src/parse/parsers/asyncapi-yaml-2/index.mjs +2 -1
  56. package/src/parse/parsers/json/index.cjs +2 -1
  57. package/src/parse/parsers/json/index.mjs +2 -1
  58. package/src/parse/parsers/openapi-json-2/index.cjs +2 -1
  59. package/src/parse/parsers/openapi-json-2/index.mjs +2 -1
  60. package/src/parse/parsers/openapi-json-3-0/index.cjs +2 -1
  61. package/src/parse/parsers/openapi-json-3-0/index.mjs +2 -1
  62. package/src/parse/parsers/openapi-json-3-1/index.cjs +2 -1
  63. package/src/parse/parsers/openapi-json-3-1/index.mjs +2 -1
  64. package/src/parse/parsers/openapi-yaml-2/index.cjs +2 -1
  65. package/src/parse/parsers/openapi-yaml-2/index.mjs +2 -1
  66. package/src/parse/parsers/openapi-yaml-3-0/index.cjs +2 -1
  67. package/src/parse/parsers/openapi-yaml-3-0/index.mjs +2 -1
  68. package/src/parse/parsers/openapi-yaml-3-1/index.cjs +2 -1
  69. package/src/parse/parsers/openapi-yaml-3-1/index.mjs +2 -1
  70. package/src/parse/parsers/overlay-json-1/index.cjs +2 -1
  71. package/src/parse/parsers/overlay-json-1/index.mjs +2 -1
  72. package/src/parse/parsers/overlay-yaml-1/index.cjs +2 -1
  73. package/src/parse/parsers/overlay-yaml-1/index.mjs +2 -1
  74. package/src/parse/parsers/yaml-1-2/index.cjs +2 -1
  75. package/src/parse/parsers/yaml-1-2/index.mjs +2 -1
  76. package/types/apidom-reference.d.ts +0 -9
  77. package/types/dereference/strategies/DereferenceVisitor.d.ts +224 -0
  78. package/types/dereference/strategies/arazzo-1/index.d.ts +0 -1
  79. package/types/dereference/strategies/arazzo-1/visitor.d.ts +38 -38
  80. package/types/dereference/strategies/asyncapi-2/index.d.ts +0 -1
  81. package/types/dereference/strategies/asyncapi-2/visitor.d.ts +13 -29
  82. package/types/dereference/strategies/openapi-2/index.d.ts +0 -1
  83. package/types/dereference/strategies/openapi-2/visitor.d.ts +14 -29
  84. package/types/dereference/strategies/openapi-3-0/index.d.ts +0 -1
  85. package/types/dereference/strategies/openapi-3-0/visitor.d.ts +13 -28
  86. package/types/dereference/strategies/openapi-3-1/index.d.ts +0 -1
  87. package/types/dereference/strategies/openapi-3-1/visitor.d.ts +37 -33
  88. package/types/index.d.ts +0 -1
  89. package/src/dereference/util.cjs +0 -33
  90. package/src/dereference/util.mjs +0 -27
  91. package/types/dereference/util.d.ts +0 -9
package/CHANGELOG.md CHANGED
@@ -3,6 +3,55 @@
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
+ # [7.0.0](https://github.com/speclynx/apidom/compare/v6.2.0...v7.0.0) (2026-11-08)
7
+
8
+ ### Bug Fixes
9
+
10
+ - **reference:** address arazzo-1 dereference review findings ([319775e](https://github.com/speclynx/apidom/commit/319775e226c65e9dd123f1b0f08618f9e003ded6)), closes [#757](https://github.com/speclynx/apidom/issues/757)
11
+ - **reference:** address dereference by expected type review findings ([d08052d](https://github.com/speclynx/apidom/commit/d08052dd65470057fe0fb49ccb9c22826aa080a3)), closes [#757](https://github.com/speclynx/apidom/issues/757)
12
+ - **reference:** dereference arazzo-1 references by expected type ([76570ce](https://github.com/speclynx/apidom/commit/76570ce6f5aacf61038c0474d10ba816b8fa486d)), closes [#751](https://github.com/speclynx/apidom/issues/751) [#757](https://github.com/speclynx/apidom/issues/757)
13
+ - **reference:** dereference asyncapi-2 references by expected type ([0ea89fd](https://github.com/speclynx/apidom/commit/0ea89fdd7a7c6e2329336980c805050cf1b8ad80)), closes [#753](https://github.com/speclynx/apidom/issues/753) [#756](https://github.com/speclynx/apidom/issues/756)
14
+ - **reference:** dereference each shared reusable component once ([cc26ac4](https://github.com/speclynx/apidom/commit/cc26ac4fb5573913155383624e86da6213febd04)), closes [#751](https://github.com/speclynx/apidom/issues/751)
15
+ - **reference:** dereference frozen elements without editing them ([98917c0](https://github.com/speclynx/apidom/commit/98917c0d636517c338533316a5ee793810f647e9)), closes [#766](https://github.com/speclynx/apidom/issues/766)
16
+ - **reference:** dereference openapi-2 references by expected type ([b1bbe37](https://github.com/speclynx/apidom/commit/b1bbe37156714e0e837a52c83aac17bed96dbe98)), closes [#753](https://github.com/speclynx/apidom/issues/753) [#756](https://github.com/speclynx/apidom/issues/756)
17
+ - **reference:** dereference openapi-3-0 references by expected type ([d570b0c](https://github.com/speclynx/apidom/commit/d570b0c1c35a826b7c2372c4deb807c15af4d6bb)), closes [#753](https://github.com/speclynx/apidom/issues/753) [#756](https://github.com/speclynx/apidom/issues/756)
18
+ - **reference:** dereference openapi-3-1 references by expected type ([70c7f94](https://github.com/speclynx/apidom/commit/70c7f94632185dba21cfa1aa5eafeaaaa786e27f)), closes [#754](https://github.com/speclynx/apidom/issues/754) [#756](https://github.com/speclynx/apidom/issues/756)
19
+ - **reference:** dereference reusable objects nested in components ([64dff81](https://github.com/speclynx/apidom/commit/64dff81cc9d62a3b518db2b9b95f0335d529fdc3)), closes [#751](https://github.com/speclynx/apidom/issues/751)
20
+ - **reference:** detect generic targets by class in DereferenceVisitor ([5baea86](https://github.com/speclynx/apidom/commit/5baea86a9d8ac2d479380a3e12c8abaa84981e48)), closes [#757](https://github.com/speclynx/apidom/issues/757)
21
+ - **reference:** report error locations in external documents once ([a24358b](https://github.com/speclynx/apidom/commit/a24358b4e668ec6860798058a5a0210568211cde)), closes [#555](https://github.com/speclynx/apidom/issues/555)
22
+ - **reference:** select parsers by the given media type first ([5b490c7](https://github.com/speclynx/apidom/commit/5b490c7c16517b373fc985c3ec3fb42efb7ad454)), closes [#620](https://github.com/speclynx/apidom/issues/620)
23
+ - **reference:** skip only dereferenced elements in arazzo-1 deref ([4789960](https://github.com/speclynx/apidom/commit/47899604d0796932d127f14f2419facdefeee8e6)), closes [#751](https://github.com/speclynx/apidom/issues/751)
24
+ - **reference:** skip parsed source descriptions in arazzo-1 deref ([45f4484](https://github.com/speclynx/apidom/commit/45f448474ac0db8ad08f580f2e50df74db6bb96f)), closes [#757](https://github.com/speclynx/apidom/issues/757)
25
+ - **traverse:** use the leaving node's own key on leave ([a44ef46](https://github.com/speclynx/apidom/commit/a44ef467872a2b0e724b4cbd37187374f14f3ea2)), closes [#16](https://github.com/speclynx/apidom/issues/16)
26
+
27
+ ### Code Refactoring
28
+
29
+ - **reference:** remove AncestorLineage ([e9e62c2](https://github.com/speclynx/apidom/commit/e9e62c2da1dcb5526eafd75e1898db8a1f1ed157)), closes [#757](https://github.com/speclynx/apidom/issues/757)
30
+
31
+ ### BREAKING CHANGES
32
+
33
+ - **reference:** Arazzo1DereferenceVisitor no longer dereferences when
34
+ traversed directly: its dereference(element) method does, and its
35
+ handlers only record transclusions. Arazzo1DereferenceVisitorOptions no
36
+ longer accepts indirections, ancestors and visited. A Reusable Object
37
+ referencing a component of another type yields that component refracted
38
+ to the expected type, and a JSON Schema $ref to a non-schema element
39
+ yields a JSON Schema. A ReferenceSet passed to the arazzo-1 strategy
40
+ is no longer cloned with immutable=true: documents loaded during
41
+ dereference are added to it as parsed, and its circular flag is set.
42
+ - **reference:** DereferenceAncestorLineage is no longer exported, nor
43
+ is the AncestorLineage type from the dereference strategies.
44
+ OpenAPI3_1DereferenceVisitor, OpenAPI3_0DereferenceVisitor,
45
+ OpenAPI2DereferenceVisitor and AsyncAPI2DereferenceVisitor extend
46
+ - **reference:** when parse.mediaType is listed by a parser, that parser
47
+ parses the file even if the file's contents are detected as another
48
+ specification or version by an earlier configured parser. Media types
49
+ differing from the listed ones only in case, whitespace or additional
50
+ parameters, or listed with wildcards, now select the parsers and
51
+ strategies listing them instead of falling back to detection or
52
+ matching no strategy. File.mediaType is trimmed, and text/plain for a
53
+ blank media type or one that isn't a string.
54
+
6
55
  # [6.2.0](https://github.com/speclynx/apidom/compare/v6.1.2...v6.2.0) (2026-11-07)
7
56
 
8
57
  ### Bug Fixes
package/README.md CHANGED
@@ -79,6 +79,15 @@ await parse('https://raw.githubusercontent.com/OAI/OpenAPI-Specification/main/ex
79
79
  Notice how we explicitly pass a `mediaType` parse option. This option is actually **not required**,
80
80
  but if not provided, the Parse component will try to identify appropriate parser plugin by file contents, and it's extension (`.json`).
81
81
 
82
+ When provided, the parser plugins listing the `mediaType` parse the file first, before the ones detecting it by its contents,
83
+ which are only used when the listing ones fail. A media type of a serialization format only (`application/json`, `application/yaml`,
84
+ `text/yaml`) names no specification, so for it the parser plugins keep their configured order, which puts the specific ones
85
+ (e.g. OpenAPI JSON) before the generic ones (JSON). Media types are compared as defined by [RFC 9110](https://www.rfc-editor.org/rfc/rfc9110#section-8.3.1):
86
+ type, subtype and parameter names ignore case, whitespace around the media type and its parameters doesn't matter, and the given media type
87
+ may carry additional parameters, so a `Content-Type` value like `application/openapi+yaml; version=3.1.2; charset=utf-8`
88
+ selects the OpenAPI 3.1 YAML parser. Resolve, dereference and bundle strategies compare the `mediaType` with the media types
89
+ they list the same way.
90
+
82
91
  What actually happens if you don't provide `mediaType` parse option?
83
92
 
84
93
  ```js
@@ -1999,6 +2008,13 @@ const dereferenced = await dereferenceApiDOM(apidom, {
1999
2008
  Dereference strategy determines how a document is internally or externally dereferenced. Depending on document `mediaType` option,
2000
2009
  every strategy differs significantly. `Dereference component` comes with six (6) default dereference strategies.
2001
2010
 
2011
+ The `arazzo-1`, `asyncapi-2`, `openapi-2`, `openapi-3-0` and `openapi-3-1` strategies read a referenced structure
2012
+ as the type its reference expects (a structure referenced as a Parameter Object and as a Header Object is read as both),
2013
+ and dereference it once per type. Elements transcluded in place of references carry the `ref-type` meta.
2014
+ Frozen elements aren't edited: when the dereferenced element, a document of the `dereference.refSet` or its parsed
2015
+ result is frozen, `dereference.immutable: false` dereferences as `dereference.immutable: true` does, for the whole run.
2016
+ Only these are checked: a frozen element within an unfrozen document is dereferenced in place.
2017
+
2002
2018
  #### [apidom](https://github.com/speclynx/apidom/tree/main/packages/apidom-reference/src/dereference/strategies/apidom)
2003
2019
 
2004
2020
  Dereference strategy for dereferencing ApiDOM using [Ref Element](https://apielements.org/en/latest/element-definitions.html?highlight=referencing#ref-element).
@@ -2055,6 +2071,35 @@ base URI. Per Arazzo 1.1.0, the base URI is the Arazzo Object's `$self` field wh
2055
2071
  against the retrieval URI when relative), otherwise the retrieval URI. A reference whose URI matches the `$self`
2056
2072
  of an already loaded Arazzo document resolves to that document by identity, without fetching it again.
2057
2073
 
2074
+ With `dereference.immutable` (the default) the dereferenced documents aren't edited: the result is a new tree.
2075
+ With `dereference.immutable: false` the documents are dereferenced in place and the dereferenced
2076
+ ParseResultElement itself is returned. Elements transcluded in place of references carry the `ref-type` meta
2077
+ and aren't traversed again, so dereferencing a document dereferenced in place earlier leaves those parts as they are.
2078
+
2079
+ The **reference decides the type of what it points at**. A Reusable Object (`reference` field holding
2080
+ a `$components.*` runtime expression) reads its target as the type it expects in its position: a Parameter in
2081
+ `parameters`, a Success Action in `onSuccess` / `successActions`, a Failure Action in `onFailure` / `failureActions`.
2082
+ A JSON Schema `$ref` reads its target as a JSON Schema, whatever object it is otherwise (e.g. a Parameter
2083
+ component), keeping the keywords next to the `$ref`. A target of a different type is refracted to the expected type
2084
+ from the target dereferenced as its own type, so the result doesn't depend on which reference reaches it first;
2085
+ the component itself keeps its own type. Reusable Objects and `$ref`s nested within the target are dereferenced too
2086
+ (e.g. Parameter references in the `parameters` of a component Success or Failure Action), and the `value` field
2087
+ of a Reusable Object overrides the `value` of the Parameter it references.
2088
+
2089
+ Every referenced structure is dereferenced once per type and shared by all the references reading it as that type,
2090
+ and each unresolvable reference is reported once. `dereference.maxDepth` limits the number of references followed
2091
+ in a row, Reusable Objects and `$ref`s alike. A reference leading back to a structure that's still being
2092
+ dereferenced is a circular reference and is handled per the `dereference.circular` option: `ignore` creates
2093
+ a cyclic structure, `error` fails with an `UnresolvableReferenceError` and `replace` substitutes a `RefElement`
2094
+ processed by the `circularReplacer` (`dereference.strategyOpts['arazzo-1'].circularReplacer` takes precedence over
2095
+ `dereference.circularReplacer`). Parsed Arazzo documents form circular references through JSON Schema `$ref`s;
2096
+ Reusable Objects, read as their expected types, don't lead back to the components holding them, but are handled
2097
+ the same way when they do.
2098
+
2099
+ Source Descriptions parsed into the document (`parse.parserOpts.sourceDescriptions`) are never dereferenced in
2100
+ the context of the document referencing them: they're left as parsed, or dereferenced in their own context when
2101
+ the `sourceDescriptions` strategy option is set.
2102
+
2058
2103
  Supported media types:
2059
2104
 
2060
2105
  ```js