@jentic/arazzo-resolver 1.0.0-alpha.3 → 1.0.0-alpha.30

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 ADDED
@@ -0,0 +1,153 @@
1
+ # Change Log
2
+
3
+ All notable changes to this project will be documented in this file.
4
+ See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
+
6
+ # [1.0.0-alpha.30](https://github.com/jentic/jentic-arazzo-tools/compare/v1.0.0-alpha.29...v1.0.0-alpha.30) (2026-04-04)
7
+
8
+ **Note:** Version bump only for package @jentic/arazzo-resolver
9
+
10
+ # [1.0.0-alpha.29](https://github.com/jentic/jentic-arazzo-tools/compare/v1.0.0-alpha.28...v1.0.0-alpha.29) (2026-03-19)
11
+
12
+ **Note:** Version bump only for package @jentic/arazzo-resolver
13
+
14
+ # [1.0.0-alpha.28](https://github.com/jentic/jentic-arazzo-tools/compare/v1.0.0-alpha.27...v1.0.0-alpha.28) (2026-03-19)
15
+
16
+ **Note:** Version bump only for package @jentic/arazzo-resolver
17
+
18
+ # [1.0.0-alpha.27](https://github.com/jentic/jentic-arazzo-tools/compare/v1.0.0-alpha.26...v1.0.0-alpha.27) (2026-03-12)
19
+
20
+ ### Bug Fixes
21
+
22
+ - **release:** override minimatch 10.2.3 to fix glob pattern regression in lerna publish ([#143](https://github.com/jentic/jentic-arazzo-tools/issues/143)) ([829f1cf](https://github.com/jentic/jentic-arazzo-tools/commit/829f1cf3d4376b407e4ef2391e155f8e60e1a7d4)), closes [lerna/lerna#4305](https://github.com/lerna/lerna/issues/4305) [isaacs/minimatch#284](https://github.com/isaacs/minimatch/issues/284)
23
+
24
+ # [1.0.0-alpha.26](https://github.com/jentic/jentic-arazzo-tools/compare/v1.0.0-alpha.25...v1.0.0-alpha.26) (2026-03-11)
25
+
26
+ ### Bug Fixes
27
+
28
+ - **parser:** add consistent naming for exported options ([#134](https://github.com/jentic/jentic-arazzo-tools/issues/134)) ([cfa2a54](https://github.com/jentic/jentic-arazzo-tools/commit/cfa2a54fad0189da7d26ca4c76b63bfcc3c60eec))
29
+
30
+ # [1.0.0-alpha.25](https://github.com/jentic/jentic-arazzo-tools/compare/v1.0.0-alpha.24...v1.0.0-alpha.25) (2026-03-11)
31
+
32
+ ### Bug Fixes
33
+
34
+ - **release:** fix issue in lerna not publishing _.cjs|_.mjs files ([8982184](https://github.com/jentic/jentic-arazzo-tools/commit/8982184ddae167b6f2a772114f9a9321f3b67d14))
35
+
36
+ # [1.0.0-alpha.24](https://github.com/jentic/jentic-arazzo-tools/compare/v1.0.0-alpha.23...v1.0.0-alpha.24) (2026-03-11)
37
+
38
+ **Note:** Version bump only for package @jentic/arazzo-resolver
39
+
40
+ # [1.0.0-alpha.23](https://github.com/jentic/jentic-arazzo-tools/compare/v1.0.0-alpha.22...v1.0.0-alpha.23) (2026-03-11)
41
+
42
+ ### Features
43
+
44
+ - **resolver:** reuse configuration from parser ([#130](https://github.com/jentic/jentic-arazzo-tools/issues/130)) ([e135be7](https://github.com/jentic/jentic-arazzo-tools/commit/e135be78133ad3957a31716dabd540333d57c0a4))
45
+
46
+ # [1.0.0-alpha.22](https://github.com/jentic/jentic-arazzo-tools/compare/v1.0.0-alpha.21...v1.0.0-alpha.22) (2026-03-10)
47
+
48
+ ### Performance Improvements
49
+
50
+ - address memory issues with SpecLynx data model ([#124](https://github.com/jentic/jentic-arazzo-tools/issues/124)) ([90ee10d](https://github.com/jentic/jentic-arazzo-tools/commit/90ee10d52dbe7314d7dc2e48e0e656fd74a97cff))
51
+
52
+ # [1.0.0-alpha.21](https://github.com/jentic/jentic-arazzo-tools/compare/v1.0.0-alpha.20...v1.0.0-alpha.21) (2026-02-24)
53
+
54
+ ### Bug Fixes
55
+
56
+ - **parser:** parse YAML document larger than 32768 lines ([#111](https://github.com/jentic/jentic-arazzo-tools/issues/111)) ([b155660](https://github.com/jentic/jentic-arazzo-tools/commit/b155660a608f4f5a0614cb5b3496bcd28a27a447))
57
+
58
+ # [1.0.0-alpha.20](https://github.com/jentic/jentic-arazzo-tools/compare/v1.0.0-alpha.19...v1.0.0-alpha.20) (2026-02-24)
59
+
60
+ ### Bug Fixes
61
+
62
+ - loosen parsing constraints to parse URIs without extensions ([#108](https://github.com/jentic/jentic-arazzo-tools/issues/108)) ([3720140](https://github.com/jentic/jentic-arazzo-tools/commit/372014060b7feae9a98e220277c2a5888132bad2))
63
+
64
+ # [1.0.0-alpha.19](https://github.com/jentic/jentic-arazzo-tools/compare/v1.0.0-alpha.18...v1.0.0-alpha.19) (2026-02-23)
65
+
66
+ ### Features
67
+
68
+ - **arazzo-ui:** add CLI for opening any URL from command cli ([#103](https://github.com/jentic/jentic-arazzo-tools/issues/103)) ([6923e7b](https://github.com/jentic/jentic-arazzo-tools/commit/6923e7bdcb62e86266789e18ef6af5dc27459110)), closes [#96](https://github.com/jentic/jentic-arazzo-tools/issues/96)
69
+
70
+ # [1.0.0-alpha.18](https://github.com/jentic/jentic-arazzo-tools/compare/v1.0.0-alpha.17...v1.0.0-alpha.18) (2026-02-20)
71
+
72
+ ### Features
73
+
74
+ - **parser:** add support for lossless roundtrips ([#91](https://github.com/jentic/jentic-arazzo-tools/issues/91)) ([2cffe4f](https://github.com/jentic/jentic-arazzo-tools/commit/2cffe4f142c4a541126a3f5f2e3634195c906f75))
75
+
76
+ # [1.0.0-alpha.17](https://github.com/jentic/jentic-arazzo-tools/compare/v1.0.0-alpha.16...v1.0.0-alpha.17) (2026-02-20)
77
+
78
+ ### Bug Fixes
79
+
80
+ - **deps:** use caret ranges for @speclynx/\* dependencies ([#90](https://github.com/jentic/jentic-arazzo-tools/issues/90)) ([2be9f0b](https://github.com/jentic/jentic-arazzo-tools/commit/2be9f0b06a38ee28d3b2ee344ff9a764d2ed3de4))
81
+
82
+ # [1.0.0-alpha.16](https://github.com/jentic/jentic-arazzo-tools/compare/v1.0.0-alpha.15...v1.0.0-alpha.16) (2026-02-20)
83
+
84
+ ### Bug Fixes
85
+
86
+ - **security:** fix security vulnerability in minimatch ([#89](https://github.com/jentic/jentic-arazzo-tools/issues/89)) ([7e16a0f](https://github.com/jentic/jentic-arazzo-tools/commit/7e16a0ff16aa4e87d09e149dd1bd6cfcf7f23e23))
87
+
88
+ # [1.0.0-alpha.15](https://github.com/jentic/jentic-arazzo-tools/compare/v1.0.0-alpha.14...v1.0.0-alpha.15) (2026-02-20)
89
+
90
+ **Note:** Version bump only for package @jentic/arazzo-resolver
91
+
92
+ # [1.0.0-alpha.14](https://github.com/jentic/jentic-arazzo-tools/compare/v1.0.0-alpha.13...v1.0.0-alpha.14) (2026-02-20)
93
+
94
+ **Note:** Version bump only for package @jentic/arazzo-resolver
95
+
96
+ # [1.0.0-alpha.13](https://github.com/jentic/jentic-arazzo-tools/compare/v1.0.0-alpha.12...v1.0.0-alpha.13) (2026-02-11)
97
+
98
+ **Note:** Version bump only for package @jentic/arazzo-resolver
99
+
100
+ # [1.0.0-alpha.12](https://github.com/jentic/jentic-arazzo-tools/compare/v1.0.0-alpha.11...v1.0.0-alpha.12) (2026-02-11)
101
+
102
+ **Note:** Version bump only for package @jentic/arazzo-resolver
103
+
104
+ # [1.0.0-alpha.11](https://github.com/jentic/jentic-arazzo-tools/compare/v1.0.0-alpha.10...v1.0.0-alpha.11) (2026-02-10)
105
+
106
+ ### Features
107
+
108
+ - add initial validator implementation ([#60](https://github.com/jentic/jentic-arazzo-tools/issues/60)) ([4e9a73d](https://github.com/jentic/jentic-arazzo-tools/commit/4e9a73dd5ca2b2b48ebc32de6b02c93524fabccf))
109
+
110
+ # [1.0.0-alpha.10](https://github.com/jentic/jentic-arazzo-tools/compare/v1.0.0-alpha.9...v1.0.0-alpha.10) (2026-02-08)
111
+
112
+ ### Bug Fixes
113
+
114
+ - **resolver:** add doc for accessing parse result via SourceDescription ([13d43e4](https://github.com/jentic/jentic-arazzo-tools/commit/13d43e45ed3bb02d5771b3adc7a6fb1e5571a393))
115
+
116
+ # [1.0.0-alpha.9](https://github.com/jentic/jentic-arazzo-tools/compare/v1.0.0-alpha.8...v1.0.0-alpha.9) (2026-02-05)
117
+
118
+ ### Features
119
+
120
+ - **resolver:** add dereferencing support for Arazzo Source Descriptions ([#43](https://github.com/jentic/jentic-arazzo-tools/issues/43)) ([091610b](https://github.com/jentic/jentic-arazzo-tools/commit/091610be81b32540845c7f1cb60dd68348ee282b))
121
+
122
+ # [1.0.0-alpha.8](https://github.com/jentic/jentic-arazzo-tools/compare/v1.0.0-alpha.7...v1.0.0-alpha.8) (2026-02-05)
123
+
124
+ ### Features
125
+
126
+ - **resolver:** add dereferencing support for OpenAPI Documents & fragments ([#42](https://github.com/jentic/jentic-arazzo-tools/issues/42)) ([7687c9e](https://github.com/jentic/jentic-arazzo-tools/commit/7687c9eecc50aab508e67ba5d639b31e25154eff))
127
+ - **resolver:** improve API consistency and validation ([#36](https://github.com/jentic/jentic-arazzo-tools/issues/36)) ([aa095cb](https://github.com/jentic/jentic-arazzo-tools/commit/aa095cb19a1543cd675bfa94a6de1651d21a58b5))
128
+
129
+ # [1.0.0-alpha.7](https://github.com/jentic/jentic-arazzo-tools/compare/v1.0.0-alpha.6...v1.0.0-alpha.7) (2026-02-04)
130
+
131
+ ### Features
132
+
133
+ - **parser:** add support for parsing OpenAPI Documents ([#35](https://github.com/jentic/jentic-arazzo-tools/issues/35)) ([4c2615e](https://github.com/jentic/jentic-arazzo-tools/commit/4c2615e07c3b74ea7fe74b91b977c8c7123a2188))
134
+
135
+ # [1.0.0-alpha.6](https://github.com/jentic/jentic-arazzo-tools/compare/v1.0.0-alpha.5...v1.0.0-alpha.6) (2026-02-04)
136
+
137
+ ### Features
138
+
139
+ - **parser:** add support for parsing entire Arazzo Description ([#34](https://github.com/jentic/jentic-arazzo-tools/issues/34)) ([44b2bda](https://github.com/jentic/jentic-arazzo-tools/commit/44b2bda1c7449e1db8145af1dea457f2e09a465b))
140
+
141
+ # [1.0.0-alpha.5](https://github.com/jentic/jentic-arazzo-tools/compare/v1.0.0-alpha.4...v1.0.0-alpha.5) (2026-01-31)
142
+
143
+ ### Bug Fixes
144
+
145
+ - **resolver:** provide documentation in README ([74cabc1](https://github.com/jentic/jentic-arazzo-tools/commit/74cabc102c56eb3cc2640500a513449a64ca52ad))
146
+
147
+ # [1.0.0-alpha.4](https://github.com/jentic/jentic-arazzo-tools/compare/v1.0.0-alpha.3...v1.0.0-alpha.4) (2026-01-31)
148
+
149
+ ### Features
150
+
151
+ - **parser:** add unified options interface & retrievalURI meta ([#16](https://github.com/jentic/jentic-arazzo-tools/issues/16)) ([2d6c3b3](https://github.com/jentic/jentic-arazzo-tools/commit/2d6c3b37f3246bc5ad775c30b508607119c9eb50))
152
+ - **resolver:** add dereferencing support for Arazzo Document fragments ([#21](https://github.com/jentic/jentic-arazzo-tools/issues/21)) ([868dc43](https://github.com/jentic/jentic-arazzo-tools/commit/868dc434b51f6247ca102fae7422a85a0e545d09))
153
+ - **resolver:** add dereferencing support for entry Arazzo Document ([#15](https://github.com/jentic/jentic-arazzo-tools/issues/15)) ([cf016ed](https://github.com/jentic/jentic-arazzo-tools/commit/cf016ed9130f08aac87bbb94b0e45e80c27f8fc3))
package/NOTICE CHANGED
@@ -2,3 +2,11 @@ Jentic Arazzo Tools
2
2
  Copyright (c) 2026 Jentic
3
3
  Jentic Arazzo Tools is licensed under Apache 2.0 license.
4
4
  Copy of the Apache 2.0 license can be found in `LICENSE` file.
5
+
6
+ swagger-js/swagger-client
7
+ Copyright 2020-2021 SmartBear Software Inc.
8
+ swagger-client is being pre-processed by our build process
9
+ and swagger-client build artifact is included in npm distribution.
10
+ It's not dynamically linked via npm dependency management.
11
+ swagger-client is licensed under Apache 2.0 license.
12
+ Copy of the Apache 2.0 license can be found in `LICENSE` file.
package/README.md CHANGED
@@ -1,3 +1,498 @@
1
1
  # @jentic/arazzo-resolver
2
2
 
3
- `@jentic/arazzo-resolver` is a resolver for [Arazzo Specification](https://spec.openapis.org/arazzo/latest.html) documents.
3
+ `@jentic/arazzo-resolver` is a resolver for [Arazzo Specification](https://spec.openapis.org/arazzo/latest.html) and [OpenAPI Specification](https://spec.openapis.org/oas/latest.html) documents.
4
+ It produces [SpecLynx ApiDOM](https://github.com/speclynx/apidom) data models using the appropriate namespace ([Arazzo 1.x](https://github.com/speclynx/apidom/tree/main/packages/apidom-ns-arazzo-1#readme), [OpenAPI 2.0](https://github.com/speclynx/apidom/tree/main/packages/apidom-ns-openapi-2#readme), [OpenAPI 3.0.x](https://github.com/speclynx/apidom/tree/main/packages/apidom-ns-openapi-3-0#readme), [OpenAPI 3.1.x](https://github.com/speclynx/apidom/tree/main/packages/apidom-ns-openapi-3-1#readme)).
5
+
6
+ **Supported Arazzo versions:**
7
+ - [Arazzo 1.0.0](https://spec.openapis.org/arazzo/v1.0.0)
8
+ - [Arazzo 1.0.1](https://spec.openapis.org/arazzo/v1.0.1)
9
+
10
+ **Supported OpenAPI versions (for source descriptions):**
11
+ - [OpenAPI 2.0](https://spec.openapis.org/oas/v2.0)
12
+ - [OpenAPI 3.0.x](https://spec.openapis.org/oas/v3.0.4)
13
+ - [OpenAPI 3.1.x](https://spec.openapis.org/oas/v3.1.2)
14
+
15
+ ## Installation
16
+
17
+ You can install this package via [npm](https://npmjs.org/) CLI by running the following command:
18
+
19
+ ```sh
20
+ npm install @jentic/arazzo-resolver
21
+ ```
22
+
23
+ ## Dereferencing
24
+
25
+ Dereferencing is the process of replacing references with the actual content they point to.
26
+
27
+ **In Arazzo Documents**, this includes:
28
+
29
+ - **JSON Schemas** - resolves references within schemas
30
+ - **Reusable Object references** (`$components.*`) - references to reusable components like parameters and actions
31
+
32
+ **In OpenAPI Documents**, this includes:
33
+
34
+ - **Reference Objects** (`$ref`) - resolves references to components, external files, and URLs
35
+ - **JSON Schemas** - resolves references within schemas
36
+ - **Path Item Object** - resolves references to path items
37
+ - and others
38
+
39
+ After dereferencing, all references are resolved inline, making the document self-contained and easier to process programmatically.
40
+
41
+ ### Functions
42
+
43
+ **Arazzo:**
44
+ - **`dereferenceArazzo(uri)`** - Dereferences from a file system path or HTTP(S) URL
45
+ - **`dereferenceArazzoElement(element)`** - Dereferences a SpecLynx ApiDOM element
46
+
47
+ **OpenAPI:**
48
+ - **`dereferenceOpenAPI(uri)`** - Dereferences from a file system path or HTTP(S) URL
49
+ - **`dereferenceOpenAPIElement(element)`** - Dereferences a SpecLynx ApiDOM element
50
+
51
+ ### Arazzo Documents
52
+
53
+ #### From file
54
+
55
+ ```js
56
+ import { dereferenceArazzo } from '@jentic/arazzo-resolver';
57
+
58
+ const parseResult = await dereferenceArazzo('/path/to/arazzo.json');
59
+ // parseResult is ParseResultElement with all references resolved
60
+ ```
61
+
62
+ #### From URL
63
+
64
+ ```js
65
+ import { dereferenceArazzo } from '@jentic/arazzo-resolver';
66
+
67
+ const parseResult = await dereferenceArazzo('https://example.com/arazzo.yaml');
68
+ ```
69
+
70
+ #### From ApiDOM element
71
+
72
+ When you already have a parsed Arazzo Document (e.g., from `@jentic/arazzo-parser`), you can dereference the element directly:
73
+
74
+ ```js
75
+ import { parseArazzo } from '@jentic/arazzo-parser';
76
+ import { dereferenceArazzoElement } from '@jentic/arazzo-resolver';
77
+
78
+ // Parse first, then dereference
79
+ const parseResult = await parseArazzo('/path/to/arazzo.json');
80
+ const dereferenced = await dereferenceArazzoElement(parseResult);
81
+ ```
82
+
83
+ ##### Without retrievalURI
84
+
85
+ When dereferencing a ParseResultElement that was parsed from inline content (string or object), you must provide a `baseURI`:
86
+
87
+ ```js
88
+ import { parseArazzo } from '@jentic/arazzo-parser';
89
+ import { dereferenceArazzoElement } from '@jentic/arazzo-resolver';
90
+
91
+ const parseResult = await parseArazzo({ arazzo: '1.0.1', ... });
92
+ const dereferenced = await dereferenceArazzoElement(parseResult, {
93
+ resolve: { baseURI: 'https://example.com/arazzo.json' },
94
+ });
95
+ ```
96
+
97
+ ##### Child elements
98
+
99
+ You can dereference individual child elements (e.g., a specific workflow) by providing the parent parseResult in options:
100
+
101
+ ```js
102
+ import { parseArazzo } from '@jentic/arazzo-parser';
103
+ import { dereferenceArazzoElement } from '@jentic/arazzo-resolver';
104
+
105
+ const parseResult = await parseArazzo('/path/to/arazzo.json');
106
+ const workflow = parseResult.api.workflows.get(0);
107
+
108
+ const dereferencedWorkflow = await dereferenceArazzoElement(workflow, {
109
+ dereference: { strategyOpts: { parseResult } },
110
+ });
111
+ ```
112
+
113
+ ##### Source descriptions
114
+
115
+ Source descriptions referenced in the Arazzo Document can optionally be dereferenced using strategy options.
116
+
117
+ The following options can be passed via `dereference.strategyOpts` (globally) or `dereference.strategyOpts['arazzo-1']` (strategy-specific).
118
+ Strategy-specific options take precedence over global options.
119
+
120
+ - **sourceDescriptions** - Controls which external source descriptions are dereferenced and included in the result.
121
+ - `true` - dereference all source descriptions
122
+ - `string[]` - dereference only source descriptions with matching names (e.g., `['petStore', 'paymentApi']`)
123
+
124
+ Each dereferenced source description is added with a `'source-description'` class and metadata (`name`, `type`, `retrievalURI`).
125
+ Only [OpenAPI 2.0](https://spec.openapis.org/oas/v2.0), [OpenAPI 3.0.x](https://spec.openapis.org/oas/v3.0.4), [OpenAPI 3.1.x](https://spec.openapis.org/oas/v3.1.2), and [Arazzo 1.x](https://spec.openapis.org/arazzo/v1.0.1) documents are accepted as source descriptions.
126
+ - **sourceDescriptionsMaxDepth** - Maximum recursion depth for dereferencing nested Arazzo source descriptions.
127
+ Defaults to `+Infinity`. Circular references are automatically detected and skipped.
128
+
129
+ ###### Error handling
130
+
131
+ The source descriptions dereferencing uses annotations instead of throwing errors, allowing dereferencing to continue
132
+ even when individual source descriptions fail. Errors are reported as `AnnotationElement` instances
133
+ with an `'error'` class within the result:
134
+
135
+ - **Max depth exceeded** - When `sourceDescriptionsMaxDepth` is reached, an error annotation is returned
136
+ instead of the nested source descriptions
137
+ - **Dereference failures** - If a source description file cannot be dereferenced (e.g., file not found, invalid syntax),
138
+ an error annotation is returned for that specific source description while other source descriptions
139
+ continue to be processed
140
+ - **Validation warnings** - Warning annotations (with `'warning'` class) are returned when the dereferenced document
141
+ is not an OpenAPI or Arazzo specification
142
+
143
+ ```js
144
+ import { dereferenceArazzo } from '@jentic/arazzo-resolver';
145
+
146
+ // Dereference all source descriptions
147
+ const result = await dereferenceArazzo('/path/to/arazzo.json', {
148
+ dereference: {
149
+ strategyOpts: {
150
+ sourceDescriptions: true,
151
+ sourceDescriptionsMaxDepth: 10,
152
+ },
153
+ },
154
+ });
155
+
156
+ // Dereference only specific source descriptions by name
157
+ const resultFiltered = await dereferenceArazzo('/path/to/arazzo.json', {
158
+ dereference: {
159
+ strategyOpts: {
160
+ 'arazzo-1': {
161
+ sourceDescriptions: ['petStore', 'paymentApi'],
162
+ },
163
+ },
164
+ },
165
+ });
166
+ ```
167
+
168
+ ### OpenAPI Documents
169
+
170
+ Supports [OpenAPI 2.0 (Swagger)](https://spec.openapis.org/oas/v2.0), [OpenAPI 3.0.x](https://spec.openapis.org/oas/v3.0.4), and [OpenAPI 3.1.x](https://spec.openapis.org/oas/v3.1.2).
171
+
172
+ #### From file
173
+
174
+ ```js
175
+ import { dereferenceOpenAPI } from '@jentic/arazzo-resolver';
176
+
177
+ const parseResult = await dereferenceOpenAPI('/path/to/openapi.json');
178
+ // parseResult is ParseResultElement with all references resolved
179
+ ```
180
+
181
+ #### From URL
182
+
183
+ ```js
184
+ import { dereferenceOpenAPI } from '@jentic/arazzo-resolver';
185
+
186
+ const parseResult = await dereferenceOpenAPI('https://example.com/openapi.yaml');
187
+ ```
188
+
189
+ #### From ApiDOM element
190
+
191
+ When you already have a parsed OpenAPI Document (e.g., from `@jentic/arazzo-parser`), you can dereference the element directly:
192
+
193
+ ```js
194
+ import { parseOpenAPI } from '@jentic/arazzo-parser';
195
+ import { dereferenceOpenAPIElement } from '@jentic/arazzo-resolver';
196
+
197
+ // Parse first, then dereference
198
+ const parseResult = await parseOpenAPI('/path/to/openapi.json');
199
+ const dereferenced = await dereferenceOpenAPIElement(parseResult);
200
+ ```
201
+
202
+ ##### Without retrievalURI
203
+
204
+ When dereferencing a ParseResultElement that was parsed from inline content (string or object), you must provide a `baseURI`:
205
+
206
+ ```js
207
+ import { parseOpenAPI } from '@jentic/arazzo-parser';
208
+ import { dereferenceOpenAPIElement } from '@jentic/arazzo-resolver';
209
+
210
+ const parseResult = await parseOpenAPI({ openapi: '3.1.0', ... });
211
+ const dereferenced = await dereferenceOpenAPIElement(parseResult, {
212
+ resolve: { baseURI: 'https://example.com/openapi.json' },
213
+ });
214
+ ```
215
+
216
+ ##### Child elements
217
+
218
+ You can dereference individual child elements (e.g., a specific Operation Object) by providing the parent parseResult in options:
219
+
220
+ ```js
221
+ import { parseOpenAPI } from '@jentic/arazzo-parser';
222
+ import { dereferenceOpenAPIElement } from '@jentic/arazzo-resolver';
223
+
224
+ const parseResult = await parseOpenAPI('/path/to/openapi.json');
225
+ const operation = parseResult.api.paths.get('/users').get;
226
+
227
+ const dereferencedOperation = await dereferenceOpenAPIElement(operation, {
228
+ dereference: { strategyOpts: { parseResult } },
229
+ });
230
+ ```
231
+
232
+ ### Options
233
+
234
+ All dereference functions accept an optional options argument compatible with [SpecLynx ApiDOM Reference Options](https://github.com/speclynx/apidom/blob/main/packages/apidom-reference/src/options/index.ts):
235
+
236
+ ```js
237
+ import { dereferenceArazzo } from '@jentic/arazzo-resolver';
238
+
239
+ const parseResult = await dereferenceArazzo('/path/to/arazzo.json', {
240
+ resolve: {
241
+ baseURI: 'https://example.com/', // Base URI for relative references
242
+ },
243
+ parse: {
244
+ parserOpts: {
245
+ strict: false, // Required for sourceMap and style (default: true)
246
+ sourceMap: true, // Include source maps in parsed documents
247
+ style: true, // Capture format-specific style information for round-trip preservation
248
+ },
249
+ },
250
+ });
251
+ ```
252
+
253
+ #### Default options
254
+
255
+ You can import and inspect the default options:
256
+
257
+ ```js
258
+ import {
259
+ defaultDereferenceArazzoOptions,
260
+ defaultDereferenceOpenAPIOptions,
261
+ } from '@jentic/arazzo-resolver';
262
+
263
+ console.log(defaultDereferenceArazzoOptions);
264
+ // {
265
+ // resolve: {
266
+ // resolvers: [FileResolver, HTTPResolverAxios],
267
+ // },
268
+ // parse: {
269
+ // parsers: [
270
+ // ArazzoJSON1Parser, ArazzoYAML1Parser,
271
+ // OpenApiJSON2Parser, OpenApiYAML2Parser,
272
+ // OpenApiJSON3_0Parser, OpenApiYAML3_0Parser,
273
+ // OpenApiJSON3_1Parser, OpenApiYAML3_1Parser,
274
+ // JSONParser, YAMLParser, BinaryParser
275
+ // ],
276
+ // },
277
+ // dereference: {
278
+ // strategies: [
279
+ // Arazzo1DereferenceStrategy,
280
+ // OpenAPI2DereferenceStrategy, OpenAPI3_0DereferenceStrategy, OpenAPI3_1DereferenceStrategy
281
+ // ],
282
+ // strategyOpts: {
283
+ // sourceDescriptions: false,
284
+ // },
285
+ // },
286
+ // }
287
+
288
+ console.log(defaultDereferenceOpenAPIOptions);
289
+ // {
290
+ // resolve: {
291
+ // resolvers: [FileResolver, HTTPResolverAxios],
292
+ // },
293
+ // parse: {
294
+ // parsers: [
295
+ // OpenApiJSON2Parser, OpenApiYAML2Parser,
296
+ // OpenApiJSON3_0Parser, OpenApiYAML3_0Parser,
297
+ // OpenApiJSON3_1Parser, OpenApiYAML3_1Parser,
298
+ // JSONParser, YAMLParser, BinaryParser
299
+ // ],
300
+ // },
301
+ // dereference: {
302
+ // strategies: [OpenAPI2DereferenceStrategy, OpenAPI3_0DereferenceStrategy, OpenAPI3_1DereferenceStrategy],
303
+ // },
304
+ // }
305
+ ```
306
+
307
+ ### Error handling
308
+
309
+ When dereferencing fails, a `DereferenceError` is thrown. The original error is available via the `cause` property:
310
+
311
+ ```js
312
+ import { dereferenceArazzo, dereferenceOpenAPI, DereferenceError } from '@jentic/arazzo-resolver';
313
+
314
+ try {
315
+ await dereferenceArazzo('/path/to/arazzo.json');
316
+ } catch (error) {
317
+ if (error instanceof DereferenceError) {
318
+ console.error(error.message); // 'Failed to dereference Arazzo Document at "/path/to/arazzo.json"'
319
+ console.error(error.cause); // Original error from underlying resolver
320
+ }
321
+ }
322
+
323
+ try {
324
+ await dereferenceOpenAPI('/path/to/openapi.json');
325
+ } catch (error) {
326
+ if (error instanceof DereferenceError) {
327
+ console.error(error.message); // 'Failed to dereference OpenAPI Document at "/path/to/openapi.json"'
328
+ console.error(error.cause); // Original error from underlying resolver
329
+ }
330
+ }
331
+ ```
332
+
333
+ ### Working with the result
334
+
335
+ Both `dereferenceArazzo` and `dereferenceOpenAPI` functions return a [ParseResultElement](https://github.com/speclynx/apidom/blob/main/packages/apidom-datamodel/README.md#parseresultelement) with all references resolved inline.
336
+
337
+ ```js
338
+ import { dereferenceArazzo } from '@jentic/arazzo-resolver';
339
+
340
+ const parseResult = await dereferenceArazzo('/path/to/arazzo.json');
341
+
342
+ // Access the main Arazzo specification element
343
+ const arazzoSpec = parseResult.api;
344
+
345
+ // Check if parsing produced any errors
346
+ const hasErrors = parseResult.errors.length > 0;
347
+
348
+ // Check if parseResult is empty
349
+ const isEmpty = parseResult.isEmpty;
350
+
351
+ // All references are now resolved inline
352
+ const firstWorkflow = arazzoSpec.workflows.get(0);
353
+ const firstStep = firstWorkflow.steps.get(0);
354
+ ```
355
+
356
+ #### Retrieval URI metadata
357
+
358
+ Both `dereferenceArazzo` and `dereferenceOpenAPI` functions automatically set `retrievalURI` metadata on the parse result:
359
+
360
+ ```js
361
+ import { dereferenceArazzo, dereferenceOpenAPI } from '@jentic/arazzo-resolver';
362
+
363
+ const arazzoResult = await dereferenceArazzo('https://example.com/arazzo.yaml');
364
+ const arazzoUri = arazzoResult.meta.get('retrievalURI');
365
+ // 'https://example.com/arazzo.yaml'
366
+
367
+ const openapiResult = await dereferenceOpenAPI('https://example.com/openapi.yaml');
368
+ const openapiUri = openapiResult.meta.get('retrievalURI');
369
+ // 'https://example.com/openapi.yaml'
370
+ ```
371
+
372
+ Note: `dereferenceArazzoElement` and `dereferenceOpenAPIElement` do not set `retrievalURI` - they preserve whatever metadata was on the original element.
373
+
374
+ #### Source descriptions
375
+
376
+ When dereferencing with `sourceDescriptions` enabled, the result contains the entry Arazzo Document at index 0, followed by any dereferenced source descriptions.
377
+ Each source description is a `ParseResultElement` with `'source-description'` class and metadata.
378
+
379
+ ```js
380
+ import { dereferenceArazzo } from '@jentic/arazzo-resolver';
381
+
382
+ const result = await dereferenceArazzo('/path/to/arazzo.json', {
383
+ dereference: { strategyOpts: { sourceDescriptions: true } },
384
+ });
385
+
386
+ // Access entry Arazzo Document
387
+ const entryArazzo = result.api; // ArazzoSpecification1Element
388
+
389
+ // Iterate over source descriptions (starting at index 1)
390
+ for (let i = 1; i < result.length; i++) {
391
+ const sdParseResult = result.get(i);
392
+
393
+ // Check if it's a source description
394
+ if (sdParseResult.classes.includes('source-description')) {
395
+ const name = sdParseResult.meta.get('name');
396
+ const type = sdParseResult.meta.get('type'); // 'openapi' or 'arazzo'
397
+ const retrievalURI = sdParseResult.meta.get('retrievalURI');
398
+
399
+ // Access the dereferenced API element
400
+ const api = sdParseResult.api; // OpenApi3_1Element, SwaggerElement, ArazzoSpecification1Element, etc.
401
+ console.log(`Source "${name}" (${type}) from ${retrievalURI}:`, api?.element);
402
+ }
403
+ }
404
+ ```
405
+
406
+ ##### Accessing via SourceDescriptionElement
407
+
408
+ An alternative way to access dereferenced source descriptions is through the `SourceDescriptionElement` metadata.
409
+ When source descriptions are dereferenced, a `ParseResultElement` is attached to each `SourceDescriptionElement`'s metadata under the key `'parseResult'`.
410
+
411
+ ```js
412
+ import { dereferenceArazzo } from '@jentic/arazzo-resolver';
413
+
414
+ const result = await dereferenceArazzo('/path/to/arazzo.json', {
415
+ dereference: { strategyOpts: { sourceDescriptions: true } },
416
+ });
417
+
418
+ const arazzoSpec = result.api;
419
+
420
+ // Access dereferenced document via SourceDescriptionElement
421
+ const sourceDesc = arazzoSpec.sourceDescriptions.get(0);
422
+ const sdParseResult = sourceDesc.meta.get('parseResult');
423
+
424
+ // Check for errors before using
425
+ if (sdParseResult.errors.length === 0) {
426
+ // Access the dereferenced API
427
+ const api = sdParseResult.api;
428
+ console.log(`API type: ${api.element}`); // e.g., 'openApi3_1'
429
+
430
+ // Get the retrieval URI
431
+ const retrievalURI = sdParseResult.meta.get('retrievalURI');
432
+ console.log(`Loaded from: ${retrievalURI}`);
433
+ }
434
+ ```
435
+
436
+ This approach is useful when you need to:
437
+ - Access a specific source description by its position in the `sourceDescriptions` array
438
+ - Get the `retrievalURI` metadata indicating where the document was fetched from
439
+ - Correlate dereferenced documents with their source description definitions
440
+
441
+ **Note:** When the `ParseResultElement` already contains parsed source descriptions (from parsing with `sourceDescriptions: true`), the dereferencer reuses them instead of re-fetching. This makes the parse-then-dereference workflow efficient.
442
+
443
+ ## SpecLynx ApiDOM tooling
444
+
445
+ Since `@jentic/arazzo-resolver` produces a SpecLynx ApiDOM data model, you have access to the full suite of ApiDOM tools for manipulating, traversing, and transforming the dereferenced document.
446
+
447
+ ### Core utilities
448
+
449
+ The [@speclynx/apidom-core](https://github.com/speclynx/apidom/tree/main/packages/apidom-core) package provides essential utilities for working with ApiDOM elements. Here are just a few examples:
450
+
451
+ ```js
452
+ import { dereferenceArazzo } from '@jentic/arazzo-resolver';
453
+ import { cloneDeep, cloneShallow } from '@speclynx/apidom-datamodel';
454
+ import { toValue, toJSON, toYAML, sexprs } from '@speclynx/apidom-core';
455
+
456
+ const parseResult = await dereferenceArazzo('/path/to/arazzo.json');
457
+ const arazzoSpec = parseResult.api;
458
+
459
+ // Convert to plain JavaScript object
460
+ const obj = toValue(arazzoSpec);
461
+
462
+ // Serialize to JSON string
463
+ const json = toJSON(arazzoSpec);
464
+
465
+ // Serialize to YAML string
466
+ const yaml = toYAML(arazzoSpec);
467
+
468
+ // Clone the element
469
+ const clonedShallow = cloneShallow(arazzoSpec);
470
+ const clonedDeep = cloneDeep(arazzoSpec);
471
+
472
+ // Get S-expression representation (useful for debugging)
473
+ const sexpr = sexprs(arazzoSpec);
474
+ ```
475
+
476
+ ### Traversal
477
+
478
+ The [@speclynx/apidom-traverse](https://github.com/speclynx/apidom/tree/main/packages/apidom-traverse) package provides powerful traversal capabilities. Here is a basic example:
479
+
480
+ ```js
481
+ import { dereferenceArazzo } from '@jentic/arazzo-resolver';
482
+ import { traverse } from '@speclynx/apidom-traverse';
483
+
484
+ const parseResult = await dereferenceArazzo('/path/to/arazzo.json');
485
+
486
+ // Traverse and collect steps using semantic visitor hook
487
+ const steps = [];
488
+ traverse(parseResult.api, {
489
+ StepElement(path) {
490
+ steps.push(path.node);
491
+ if (steps.length >= 10) {
492
+ path.stop(); // Stop traversal after collecting 10 steps
493
+ }
494
+ },
495
+ });
496
+ ```
497
+
498
+ For more information about available utilities, see the [SpecLynx ApiDOM documentation](https://github.com/speclynx/apidom).