@jentic/arazzo-parser 1.0.0-alpha.5 → 1.0.0-alpha.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/CHANGELOG.md +6 -0
- package/README.md +272 -43
- package/dist/jentic-arazzo-parser.browser.js +66825 -44042
- package/dist/jentic-arazzo-parser.browser.min.js +1 -1
- package/package.json +11 -10
- package/src/index.cjs +4 -147
- package/src/index.mjs +1 -143
- package/src/parse-arazzo.cjs +213 -0
- package/src/parse-arazzo.mjs +206 -0
- package/src/resolve/resolvers/memory/index.cjs +29 -0
- package/src/resolve/resolvers/memory/index.mjs +25 -0
- package/types/arazzo-parser.d.ts +9 -7
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,12 @@
|
|
|
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
|
+
# [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)
|
|
7
|
+
|
|
8
|
+
### Features
|
|
9
|
+
|
|
10
|
+
- **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))
|
|
11
|
+
|
|
6
12
|
# [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)
|
|
7
13
|
|
|
8
14
|
**Note:** Version bump only for package @jentic/arazzo-parser
|
package/README.md
CHANGED
|
@@ -13,17 +13,21 @@ npm install @jentic/arazzo-parser
|
|
|
13
13
|
|
|
14
14
|
## Usage
|
|
15
15
|
|
|
16
|
-
`@jentic/arazzo-parser` provides a
|
|
16
|
+
`@jentic/arazzo-parser` provides a `parseArazzo` function for parsing Arazzo documents.
|
|
17
17
|
|
|
18
|
-
|
|
19
|
-
|
|
18
|
+
## Parsing Arazzo Documents
|
|
19
|
+
|
|
20
|
+
The `parseArazzo` function accepts multiple input types:
|
|
21
|
+
|
|
22
|
+
1. **Plain JavaScript object** - converts to JSON and parses (source maps supported with `strict: false`)
|
|
23
|
+
2. **String content** - detects Arazzo content and parses inline JSON or YAML
|
|
20
24
|
3. **File system path** - resolves and parses local Arazzo Documents
|
|
21
25
|
4. **HTTP(S) URL** - fetches and parses remote Arazzo Documents
|
|
22
26
|
|
|
23
|
-
###
|
|
27
|
+
### From object
|
|
24
28
|
|
|
25
29
|
```js
|
|
26
|
-
import {
|
|
30
|
+
import { parseArazzo } from '@jentic/arazzo-parser';
|
|
27
31
|
|
|
28
32
|
const arazzoDocument = {
|
|
29
33
|
arazzo: '1.0.1',
|
|
@@ -41,20 +45,20 @@ const arazzoDocument = {
|
|
|
41
45
|
workflows: [],
|
|
42
46
|
};
|
|
43
47
|
|
|
44
|
-
const parseResult = await
|
|
48
|
+
const parseResult = await parseArazzo(arazzoDocument);
|
|
45
49
|
// parseResult is ParseResultElement containing ArazzoSpecification1Element
|
|
46
50
|
```
|
|
47
51
|
|
|
48
|
-
###
|
|
52
|
+
### From string
|
|
49
53
|
|
|
50
54
|
```js
|
|
51
|
-
import {
|
|
55
|
+
import { parseArazzo } from '@jentic/arazzo-parser';
|
|
52
56
|
|
|
53
57
|
// JSON string
|
|
54
|
-
const parseResult = await
|
|
58
|
+
const parseResult = await parseArazzo('{"arazzo": "1.0.1", "info": {...}}');
|
|
55
59
|
|
|
56
60
|
// YAML string
|
|
57
|
-
const parseResult = await
|
|
61
|
+
const parseResult = await parseArazzo(`
|
|
58
62
|
arazzo: '1.0.1'
|
|
59
63
|
info:
|
|
60
64
|
title: My API Workflow
|
|
@@ -62,30 +66,30 @@ info:
|
|
|
62
66
|
`);
|
|
63
67
|
```
|
|
64
68
|
|
|
65
|
-
###
|
|
69
|
+
### From file
|
|
66
70
|
|
|
67
71
|
```js
|
|
68
|
-
import {
|
|
72
|
+
import { parseArazzo } from '@jentic/arazzo-parser';
|
|
69
73
|
|
|
70
|
-
const parseResult = await
|
|
74
|
+
const parseResult = await parseArazzo('/path/to/arazzo.json');
|
|
71
75
|
```
|
|
72
76
|
|
|
73
|
-
###
|
|
77
|
+
### From URL
|
|
74
78
|
|
|
75
79
|
```js
|
|
76
|
-
import {
|
|
80
|
+
import { parseArazzo } from '@jentic/arazzo-parser';
|
|
77
81
|
|
|
78
|
-
const parseResult = await
|
|
82
|
+
const parseResult = await parseArazzo('https://example.com/arazzo.yaml');
|
|
79
83
|
```
|
|
80
84
|
|
|
81
85
|
## Parse options
|
|
82
86
|
|
|
83
|
-
The `
|
|
87
|
+
The `parseArazzo` function accepts an optional second argument with reference options compatible with [SpecLynx ApiDOM Reference Options](https://github.com/speclynx/apidom/blob/main/packages/apidom-reference/src/options/index.ts):
|
|
84
88
|
|
|
85
89
|
```js
|
|
86
|
-
import {
|
|
90
|
+
import { parseArazzo } from '@jentic/arazzo-parser';
|
|
87
91
|
|
|
88
|
-
const parseResult = await
|
|
92
|
+
const parseResult = await parseArazzo(source, {
|
|
89
93
|
parse: {
|
|
90
94
|
parserOpts: {
|
|
91
95
|
strict: true, // Use strict parsing mode (default: true)
|
|
@@ -105,11 +109,16 @@ import { defaultOptions } from '@jentic/arazzo-parser';
|
|
|
105
109
|
console.log(defaultOptions);
|
|
106
110
|
// {
|
|
107
111
|
// parse: {
|
|
108
|
-
// parsers: [
|
|
109
|
-
//
|
|
112
|
+
// parsers: [
|
|
113
|
+
// ArazzoJSON1Parser, ArazzoYAML1Parser,
|
|
114
|
+
// OpenApiJSON2Parser, OpenApiYAML2Parser,
|
|
115
|
+
// OpenApiJSON3_0Parser, OpenApiYAML3_0Parser,
|
|
116
|
+
// OpenApiJSON3_1Parser, OpenApiYAML3_1Parser,
|
|
117
|
+
// ],
|
|
118
|
+
// parserOpts: { sourceMap: false, strict: true, sourceDescriptions: false },
|
|
110
119
|
// },
|
|
111
120
|
// resolve: {
|
|
112
|
-
// resolvers: [
|
|
121
|
+
// resolvers: [MemoryResolver, FileResolver, HTTPResolverAxios],
|
|
113
122
|
// resolverOpts: {},
|
|
114
123
|
// },
|
|
115
124
|
// }
|
|
@@ -120,24 +129,49 @@ console.log(defaultOptions);
|
|
|
120
129
|
When parsing fails, a `ParseError` is thrown. The original error is available via the `cause` property:
|
|
121
130
|
|
|
122
131
|
```js
|
|
123
|
-
import {
|
|
132
|
+
import { parseArazzo } from '@jentic/arazzo-parser';
|
|
124
133
|
|
|
125
134
|
try {
|
|
126
|
-
await
|
|
135
|
+
await parseArazzo('invalid content');
|
|
127
136
|
} catch (error) {
|
|
128
137
|
console.error(error.message); // 'Failed to parse Arazzo Document'
|
|
129
138
|
console.error(error.cause); // Original error from underlying parser
|
|
130
139
|
}
|
|
131
140
|
```
|
|
132
141
|
|
|
142
|
+
### Non-Arazzo documents
|
|
143
|
+
|
|
144
|
+
When a valid document is parsed but it's not an Arazzo specification (e.g., an OpenAPI document), the parser does not throw. Instead, it returns a `ParseResultElement` with:
|
|
145
|
+
|
|
146
|
+
- An error annotation explaining the issue
|
|
147
|
+
- `.api` returns `undefined`
|
|
148
|
+
- The parsed document remains accessible in the parse result
|
|
149
|
+
|
|
150
|
+
```js
|
|
151
|
+
import { parseArazzo } from '@jentic/arazzo-parser';
|
|
152
|
+
|
|
153
|
+
const openApiDoc = {
|
|
154
|
+
openapi: '3.1.0',
|
|
155
|
+
info: { title: 'My API', version: '1.0.0' },
|
|
156
|
+
paths: {},
|
|
157
|
+
};
|
|
158
|
+
|
|
159
|
+
const result = await parseArazzo(openApiDoc);
|
|
160
|
+
|
|
161
|
+
result.api; // undefined
|
|
162
|
+
result.errors.length; // 1
|
|
163
|
+
result.errors.get(0).toValue();
|
|
164
|
+
// 'Document is not a valid Arazzo specification...'
|
|
165
|
+
```
|
|
166
|
+
|
|
133
167
|
## Working with the result
|
|
134
168
|
|
|
135
|
-
The `
|
|
169
|
+
The `parseArazzo` function returns a [ParseResultElement](https://github.com/speclynx/apidom/blob/main/packages/apidom-datamodel/README.md#parseresultelement) representing the result of the parsing operation.
|
|
136
170
|
|
|
137
171
|
```js
|
|
138
|
-
import {
|
|
172
|
+
import { parseArazzo } from '@jentic/arazzo-parser';
|
|
139
173
|
|
|
140
|
-
const parseResult = await
|
|
174
|
+
const parseResult = await parseArazzo(source);
|
|
141
175
|
|
|
142
176
|
// Access the main Arazzo specification element
|
|
143
177
|
const arazzoSpec = parseResult.api;
|
|
@@ -154,10 +188,10 @@ const isEmpty = parseResult.isEmpty;
|
|
|
154
188
|
When parsing from a file system path or HTTP(S) URL, the `retrievalURI` metadata is set on the parse result:
|
|
155
189
|
|
|
156
190
|
```js
|
|
157
|
-
import {
|
|
191
|
+
import { parseArazzo } from '@jentic/arazzo-parser';
|
|
158
192
|
import { toValue } from '@speclynx/apidom-core';
|
|
159
193
|
|
|
160
|
-
const parseResult = await
|
|
194
|
+
const parseResult = await parseArazzo('/path/to/arazzo.json');
|
|
161
195
|
|
|
162
196
|
// Get the URI from which the document was retrieved
|
|
163
197
|
const uri = toValue(parseResult.meta.get('retrievalURI'));
|
|
@@ -170,15 +204,17 @@ Note: `retrievalURI` is not set when parsing from inline content (string) or pla
|
|
|
170
204
|
|
|
171
205
|
Source maps allow you to track the original position (line, column) of each element in the parsed document. This is useful for error reporting, IDE integrations, linting, and any tooling that needs to show precise locations in the original source.
|
|
172
206
|
|
|
173
|
-
|
|
207
|
+
|
|
208
|
+
To enable source maps, set `sourceMap: true` and `strict: false` in the parser options:
|
|
174
209
|
|
|
175
210
|
```js
|
|
176
|
-
import {
|
|
211
|
+
import { parseArazzo } from '@jentic/arazzo-parser';
|
|
177
212
|
|
|
178
|
-
const parseResult = await
|
|
213
|
+
const parseResult = await parseArazzo('/path/to/arazzo.yaml', {
|
|
179
214
|
parse: {
|
|
180
215
|
parserOpts: {
|
|
181
216
|
sourceMap: true,
|
|
217
|
+
strict: false,
|
|
182
218
|
},
|
|
183
219
|
},
|
|
184
220
|
});
|
|
@@ -187,10 +223,10 @@ const parseResult = await parse('/path/to/arazzo.yaml', {
|
|
|
187
223
|
When source maps are enabled, each element in the parsed result contains positional properties stored directly on the element. Position values use UTF-16 code units for compatibility with Language Server Protocol (LSP) and JavaScript string indexing:
|
|
188
224
|
|
|
189
225
|
```js
|
|
190
|
-
import {
|
|
226
|
+
import { parseArazzo } from '@jentic/arazzo-parser';
|
|
191
227
|
|
|
192
|
-
const parseResult = await
|
|
193
|
-
parse: { parserOpts: { sourceMap: true } },
|
|
228
|
+
const parseResult = await parseArazzo('/path/to/arazzo.yaml', {
|
|
229
|
+
parse: { parserOpts: { sourceMap: true, strict: false } },
|
|
194
230
|
});
|
|
195
231
|
|
|
196
232
|
const arazzoSpec = parseResult.api;
|
|
@@ -210,15 +246,208 @@ console.log(`Workflow starts at line ${workflow.startLine}, column ${workflow.st
|
|
|
210
246
|
|
|
211
247
|
For more details about source maps, see the [SpecLynx ApiDOM Data Model documentation](https://github.com/speclynx/apidom/tree/main/packages/apidom-datamodel#source-maps).
|
|
212
248
|
|
|
213
|
-
**Note:** Source maps
|
|
249
|
+
**Note:** Source maps require `strict: false` to be set. When parsing from objects, they are converted to pretty-printed JSON strings internally (2-space indentation), so source map positions refer to this generated JSON representation, not the original object structure:
|
|
214
250
|
|
|
215
251
|
```js
|
|
216
|
-
//
|
|
217
|
-
|
|
218
|
-
|
|
252
|
+
// Source maps with objects (requires strict: false)
|
|
253
|
+
// Positions will reference the internally generated JSON string
|
|
254
|
+
await parseArazzo({ arazzo: '1.0.1', ... }, {
|
|
255
|
+
parse: { parserOpts: { sourceMap: true, strict: false } },
|
|
219
256
|
});
|
|
220
257
|
```
|
|
221
258
|
|
|
259
|
+
## Parsing source descriptions
|
|
260
|
+
|
|
261
|
+
Arazzo documents can reference external API specifications (OpenAPI, Arazzo) through [Source Descriptions](https://spec.openapis.org/arazzo/latest.html#source-description-object). The parser can automatically fetch and parse these referenced documents.
|
|
262
|
+
|
|
263
|
+
**Note:** Source descriptions parsing is disabled by default for performance reasons. Enable it explicitly when you need to resolve and parse referenced API specifications.
|
|
264
|
+
|
|
265
|
+
### Enabling source descriptions parsing
|
|
266
|
+
|
|
267
|
+
To parse source descriptions, enable the `sourceDescriptions` option in `parserOpts`:
|
|
268
|
+
|
|
269
|
+
```js
|
|
270
|
+
import { parseArazzo } from '@jentic/arazzo-parser';
|
|
271
|
+
|
|
272
|
+
const parseResult = await parseArazzo('/path/to/arazzo.json', {
|
|
273
|
+
parse: {
|
|
274
|
+
parserOpts: {
|
|
275
|
+
sourceDescriptions: true,
|
|
276
|
+
},
|
|
277
|
+
},
|
|
278
|
+
});
|
|
279
|
+
```
|
|
280
|
+
|
|
281
|
+
Alternatively, you can configure it per parser for more granular control:
|
|
282
|
+
|
|
283
|
+
```js
|
|
284
|
+
const parseResult = await parseArazzo('/path/to/arazzo.json', {
|
|
285
|
+
parse: {
|
|
286
|
+
parserOpts: {
|
|
287
|
+
'arazzo-json-1': { sourceDescriptions: true },
|
|
288
|
+
'arazzo-yaml-1': { sourceDescriptions: true },
|
|
289
|
+
},
|
|
290
|
+
},
|
|
291
|
+
});
|
|
292
|
+
```
|
|
293
|
+
|
|
294
|
+
### Selective parsing
|
|
295
|
+
|
|
296
|
+
You can selectively parse only specific source descriptions by providing an array of names:
|
|
297
|
+
|
|
298
|
+
```js
|
|
299
|
+
const parseResult = await parseArazzo('/path/to/arazzo.json', {
|
|
300
|
+
parse: {
|
|
301
|
+
parserOpts: {
|
|
302
|
+
sourceDescriptions: ['petStoreApi', 'paymentApi'],
|
|
303
|
+
},
|
|
304
|
+
},
|
|
305
|
+
});
|
|
306
|
+
```
|
|
307
|
+
|
|
308
|
+
### Result structure
|
|
309
|
+
|
|
310
|
+
When source descriptions are parsed, each parsed document that is a *direct* source description of the main Arazzo document is added to the main `ParseResultElement` as an additional top-level element. The first element is always the main Arazzo document, and subsequent top-level elements are these directly parsed source descriptions. When recursive parsing discovers further source descriptions from within an already parsed source description, those recursively parsed documents are attached as nested `ParseResultElement` instances beneath the source-description element that referenced them (they are not duplicated at the top level). Consumers that need to see all documents should traverse both the top-level elements and any nested `ParseResultElement`s reachable from source-description elements.
|
|
311
|
+
|
|
312
|
+
Source descriptions are parsed into their appropriate SpecLynx ApiDOM namespace data models based on document type:
|
|
313
|
+
|
|
314
|
+
- **Arazzo** → [@speclynx/apidom-ns-arazzo-1](https://github.com/speclynx/apidom/tree/main/packages/apidom-ns-arazzo-1)
|
|
315
|
+
- **OpenAPI 2.0** → [@speclynx/apidom-ns-openapi-2](https://github.com/speclynx/apidom/tree/main/packages/apidom-ns-openapi-2)
|
|
316
|
+
- **OpenAPI 3.0.x** → [@speclynx/apidom-ns-openapi-3-0](https://github.com/speclynx/apidom/tree/main/packages/apidom-ns-openapi-3-0)
|
|
317
|
+
- **OpenAPI 3.1.x** → [@speclynx/apidom-ns-openapi-3-1](https://github.com/speclynx/apidom/tree/main/packages/apidom-ns-openapi-3-1)
|
|
318
|
+
|
|
319
|
+
```mermaid
|
|
320
|
+
graph TD
|
|
321
|
+
PR["ParseResultElement"] --> API[".api: ArazzoSpecification1Element"]
|
|
322
|
+
PR --> SD1
|
|
323
|
+
PR --> SD2
|
|
324
|
+
|
|
325
|
+
subgraph source-descriptions [source descriptions]
|
|
326
|
+
SD1["ParseResultElement<br/>(petStoreApi)"] --> SD1_API[".api: OpenApi3_1Element"]
|
|
327
|
+
SD2["ParseResultElement<br/>(legacyApi)"] --> SD2_ERR[".errors"]
|
|
328
|
+
SD2 --> SD2_WARN[".warnings"]
|
|
329
|
+
end
|
|
330
|
+
|
|
331
|
+
style PR fill:#e7f1ff,stroke:#0366d6,stroke-width:2px
|
|
332
|
+
style SD1 fill:#f6f8fa,stroke:#586069
|
|
333
|
+
style SD2 fill:#f6f8fa,stroke:#586069
|
|
334
|
+
style API fill:#d4edda,stroke:#28a745
|
|
335
|
+
style SD1_API fill:#d4edda,stroke:#28a745
|
|
336
|
+
style SD2_ERR fill:#f8d7da,stroke:#dc3545
|
|
337
|
+
style SD2_WARN fill:#fff3cd,stroke:#ffc107
|
|
338
|
+
```
|
|
339
|
+
|
|
340
|
+
```js
|
|
341
|
+
import { parseArazzo } from '@jentic/arazzo-parser';
|
|
342
|
+
|
|
343
|
+
const parseResult = await parseArazzo('/path/to/arazzo.json', {
|
|
344
|
+
parse: {
|
|
345
|
+
parserOpts: {
|
|
346
|
+
sourceDescriptions: true,
|
|
347
|
+
},
|
|
348
|
+
},
|
|
349
|
+
});
|
|
350
|
+
|
|
351
|
+
// Main Arazzo document
|
|
352
|
+
const arazzoSpec = parseResult.api;
|
|
353
|
+
|
|
354
|
+
// Number of elements (1 main + N source descriptions)
|
|
355
|
+
console.log(parseResult.length);
|
|
356
|
+
|
|
357
|
+
// Access parsed source descriptions (filter by 'source-description' class)
|
|
358
|
+
for (let i = 0; i < parseResult.length; i++) {
|
|
359
|
+
const element = parseResult.get(i);
|
|
360
|
+
|
|
361
|
+
if (element.classes.includes('source-description')) {
|
|
362
|
+
// Source description metadata
|
|
363
|
+
const name = element.meta.get('name')?.toValue();
|
|
364
|
+
const type = element.meta.get('type')?.toValue();
|
|
365
|
+
|
|
366
|
+
console.log(`Source description "${name}" (${type})`);
|
|
367
|
+
|
|
368
|
+
// The parsed API document
|
|
369
|
+
const api = element.api;
|
|
370
|
+
}
|
|
371
|
+
}
|
|
372
|
+
```
|
|
373
|
+
|
|
374
|
+
### Recursive parsing
|
|
375
|
+
|
|
376
|
+
When a source description is of type `arazzo`, the parser recursively parses that document's source descriptions as well. This allows you to parse entire dependency trees of Arazzo documents.
|
|
377
|
+
|
|
378
|
+
### Limiting recursion depth
|
|
379
|
+
|
|
380
|
+
To prevent excessive recursion or handle deeply nested documents, use the `sourceDescriptionsMaxDepth` option:
|
|
381
|
+
|
|
382
|
+
```js
|
|
383
|
+
const parseResult = await parseArazzo('/path/to/arazzo.json', {
|
|
384
|
+
parse: {
|
|
385
|
+
parserOpts: {
|
|
386
|
+
sourceDescriptions: true,
|
|
387
|
+
sourceDescriptionsMaxDepth: 2, // Only parse 2 levels deep
|
|
388
|
+
},
|
|
389
|
+
},
|
|
390
|
+
});
|
|
391
|
+
```
|
|
392
|
+
|
|
393
|
+
The default value is `+Infinity` (no limit). Setting it to `0` will create error annotations instead of parsing any source descriptions.
|
|
394
|
+
|
|
395
|
+
### Cycle detection
|
|
396
|
+
|
|
397
|
+
The parser automatically detects circular references between Arazzo documents. When a cycle is detected, a warning annotation is added instead of causing infinite recursion:
|
|
398
|
+
|
|
399
|
+
```js
|
|
400
|
+
// arazzo-a.json references arazzo-b.json
|
|
401
|
+
// arazzo-b.json references arazzo-a.json (cycle!)
|
|
402
|
+
|
|
403
|
+
const parseResult = await parseArazzo('/path/to/arazzo-a.json', {
|
|
404
|
+
parse: {
|
|
405
|
+
parserOpts: {
|
|
406
|
+
sourceDescriptions: true,
|
|
407
|
+
},
|
|
408
|
+
},
|
|
409
|
+
});
|
|
410
|
+
|
|
411
|
+
// The cycle is handled gracefully - check for warning annotations
|
|
412
|
+
```
|
|
413
|
+
|
|
414
|
+
### Error and warning handling
|
|
415
|
+
|
|
416
|
+
When issues occur during source description parsing, the parser does not throw errors. Instead, it adds annotation elements to the source description's parse result:
|
|
417
|
+
|
|
418
|
+
- **`error`** class - Parsing failed (e.g., file not found, invalid document, max depth exceeded)
|
|
419
|
+
- **`warning`** class - Non-fatal issues (e.g., cycle detected, type mismatch between declared and actual)
|
|
420
|
+
|
|
421
|
+
This allows partial parsing to succeed even if some source descriptions have issues:
|
|
422
|
+
|
|
423
|
+
```js
|
|
424
|
+
const parseResult = await parseArazzo('/path/to/arazzo.json', {
|
|
425
|
+
parse: {
|
|
426
|
+
parserOpts: {
|
|
427
|
+
sourceDescriptions: true,
|
|
428
|
+
},
|
|
429
|
+
},
|
|
430
|
+
});
|
|
431
|
+
|
|
432
|
+
// Check each source description for errors and warnings
|
|
433
|
+
for (let i = 0; i < parseResult.length; i++) {
|
|
434
|
+
const element = parseResult.get(i);
|
|
435
|
+
|
|
436
|
+
if (element.classes.includes('source-description')) {
|
|
437
|
+
const name = element.meta.get('name')?.toValue();
|
|
438
|
+
|
|
439
|
+
// Use built-in accessors for errors and warnings
|
|
440
|
+
element.errors.forEach((error) => {
|
|
441
|
+
console.error(`Error in "${name}": ${error.toValue()}`);
|
|
442
|
+
});
|
|
443
|
+
|
|
444
|
+
element.warnings.forEach((warning) => {
|
|
445
|
+
console.warn(`Warning in "${name}": ${warning.toValue()}`);
|
|
446
|
+
});
|
|
447
|
+
}
|
|
448
|
+
}
|
|
449
|
+
```
|
|
450
|
+
|
|
222
451
|
## SpecLynx ApiDOM tooling
|
|
223
452
|
|
|
224
453
|
Since `@jentic/arazzo-parser` produces a SpecLynx ApiDOM data model, you have access to the full suite of ApiDOM tools for manipulating, traversing, and transforming the parsed document.
|
|
@@ -228,11 +457,11 @@ Since `@jentic/arazzo-parser` produces a SpecLynx ApiDOM data model, you have ac
|
|
|
228
457
|
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:
|
|
229
458
|
|
|
230
459
|
```js
|
|
231
|
-
import {
|
|
460
|
+
import { parseArazzo } from '@jentic/arazzo-parser';
|
|
232
461
|
import { cloneDeep, cloneShallow } from '@speclynx/apidom-datamodel';
|
|
233
462
|
import { toValue, toJSON, toYAML, sexprs } from '@speclynx/apidom-core';
|
|
234
463
|
|
|
235
|
-
const parseResult = await
|
|
464
|
+
const parseResult = await parseArazzo(source);
|
|
236
465
|
const arazzoSpec = parseResult.api;
|
|
237
466
|
|
|
238
467
|
// Convert to plain JavaScript object
|
|
@@ -257,10 +486,10 @@ const sexpr = sexprs(arazzoSpec);
|
|
|
257
486
|
The [@speclynx/apidom-traverse](https://github.com/speclynx/apidom/tree/main/packages/apidom-traverse) package provides powerful traversal capabilities. Here is a basic example:
|
|
258
487
|
|
|
259
488
|
```js
|
|
260
|
-
import {
|
|
489
|
+
import { parseArazzo } from '@jentic/arazzo-parser';
|
|
261
490
|
import { traverse } from '@speclynx/apidom-traverse';
|
|
262
491
|
|
|
263
|
-
const parseResult = await
|
|
492
|
+
const parseResult = await parseArazzo(source);
|
|
264
493
|
|
|
265
494
|
// Traverse and collect steps using semantic visitor hook
|
|
266
495
|
const steps = [];
|