@speclynx/apidom-reference 2.5.0 → 2.6.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 +13 -0
- package/README.md +109 -6
- package/dist/apidom-reference.browser.js +287 -69
- package/dist/apidom-reference.browser.min.js +1 -1
- package/package.json +25 -25
- package/src/configuration/saturated.cjs +4 -2
- package/src/configuration/saturated.mjs +5 -3
- package/src/dereference/strategies/arazzo-1/index.cjs +1 -1
- package/src/dereference/strategies/arazzo-1/index.mjs +1 -1
- package/src/dereference/strategies/asyncapi-2/index.cjs +1 -1
- package/src/dereference/strategies/asyncapi-2/index.mjs +1 -1
- package/src/dereference/strategies/openapi-2/index.cjs +1 -1
- package/src/dereference/strategies/openapi-2/index.mjs +1 -1
- package/src/dereference/strategies/openapi-3-0/index.cjs +1 -1
- package/src/dereference/strategies/openapi-3-0/index.mjs +1 -1
- package/src/parse/parsers/arazzo-json-1/index.cjs +12 -2
- package/src/parse/parsers/arazzo-json-1/index.mjs +14 -4
- package/src/parse/parsers/arazzo-json-1/source-description.cjs +177 -0
- package/src/parse/parsers/arazzo-json-1/source-description.mjs +171 -0
- package/src/parse/parsers/arazzo-yaml-1/index.cjs +12 -2
- package/src/parse/parsers/arazzo-yaml-1/index.mjs +12 -2
- package/src/resolve/util.cjs +1 -1
- package/src/resolve/util.mjs +1 -1
- package/types/apidom-reference.d.ts +4 -4
- package/types/parse/parsers/Parser.d.ts +3 -2
- package/types/parse/parsers/arazzo-json-1/index.d.ts +5 -1
- package/types/parse/parsers/arazzo-json-1/source-description.d.ts +13 -0
- package/types/parse/parsers/arazzo-yaml-1/index.d.ts +5 -1
- package/types/resolve/resolvers/Resolver.d.ts +3 -2
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.6.0](https://github.com/speclynx/apidom/compare/v2.5.1...v2.6.0) (2026-02-03)
|
|
7
|
+
|
|
8
|
+
### Features
|
|
9
|
+
|
|
10
|
+
- **reference:** add support for Arazzo Source Description parsing ([#63](https://github.com/speclynx/apidom/issues/63)) ([6df480a](https://github.com/speclynx/apidom/commit/6df480a10bb72b2207d37e0239d2ef9b73e49d08))
|
|
11
|
+
- **reference:** pass options objects to resolve methods ([#64](https://github.com/speclynx/apidom/issues/64)) ([be9ca2d](https://github.com/speclynx/apidom/commit/be9ca2de33ae7a2fa9b677a8521873bcdd6781be))
|
|
12
|
+
|
|
13
|
+
## [2.5.1](https://github.com/speclynx/apidom/compare/v2.5.0...v2.5.1) (2026-01-31)
|
|
14
|
+
|
|
15
|
+
### Bug Fixes
|
|
16
|
+
|
|
17
|
+
- **reference:** make accessing parse result consistent ([#58](https://github.com/speclynx/apidom/issues/58)) ([8789ed7](https://github.com/speclynx/apidom/commit/8789ed77051082036838d2d51ef9f8ae29ae02e4))
|
|
18
|
+
|
|
6
19
|
# [2.5.0](https://github.com/speclynx/apidom/compare/v2.4.0...v2.5.0) (2026-01-30)
|
|
7
20
|
|
|
8
21
|
### Features
|
package/README.md
CHANGED
|
@@ -292,6 +292,84 @@ 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
|
+
##### Parser options
|
|
315
|
+
|
|
316
|
+
The following options can be passed via `parse.parserOpts` (globally) or `parse.parserOpts['arazzo-json-1']` (parser-specific).
|
|
317
|
+
Parser-specific options take precedence over global options.
|
|
318
|
+
|
|
319
|
+
- **sourceDescriptions** - Controls which external source descriptions are parsed and included in the `ParseResultElement`.
|
|
320
|
+
- `true` - parse all source descriptions
|
|
321
|
+
- `string[]` - parse only source descriptions with matching names (e.g., `['petStore', 'paymentApi']`)
|
|
322
|
+
|
|
323
|
+
Each parsed source description is added with a `'source-description'` class and metadata (`name`, `type`).
|
|
324
|
+
Only OpenAPI 2.0, OpenAPI 3.0.x, OpenAPI 3.1.x, and Arazzo 1.x documents are accepted as source descriptions.
|
|
325
|
+
- **sourceDescriptionsMaxDepth** - Maximum recursion depth for parsing nested Arazzo source descriptions.
|
|
326
|
+
Defaults to `+Infinity`. Circular references are automatically detected and skipped.
|
|
327
|
+
|
|
328
|
+
##### Error handling
|
|
329
|
+
|
|
330
|
+
The source descriptions parsing uses annotations instead of throwing errors, allowing parsing to continue
|
|
331
|
+
even when individual source descriptions fail. Errors are reported as `AnnotationElement` instances
|
|
332
|
+
with an `'error'` class within the parse result:
|
|
333
|
+
|
|
334
|
+
- **Max depth exceeded** - When `sourceDescriptionsMaxDepth` is reached, an error annotation is returned
|
|
335
|
+
instead of the nested source descriptions
|
|
336
|
+
- **Parse failures** - If a source description file cannot be parsed (e.g., file not found, invalid syntax),
|
|
337
|
+
an error annotation is returned for that specific source description while other source descriptions
|
|
338
|
+
continue to be processed
|
|
339
|
+
- **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)
|
|
341
|
+
|
|
342
|
+
```js
|
|
343
|
+
import { parse } from '@speclynx/apidom-reference';
|
|
344
|
+
|
|
345
|
+
// Parse all source descriptions
|
|
346
|
+
const parseResult = await parse('/path/to/arazzo.json', {
|
|
347
|
+
parse: {
|
|
348
|
+
parserOpts: {
|
|
349
|
+
sourceDescriptions: true,
|
|
350
|
+
sourceDescriptionsMaxDepth: 10,
|
|
351
|
+
},
|
|
352
|
+
},
|
|
353
|
+
});
|
|
354
|
+
|
|
355
|
+
// Parse only specific source descriptions by name
|
|
356
|
+
const parseResultFiltered = await parse('/path/to/arazzo.json', {
|
|
357
|
+
parse: {
|
|
358
|
+
parserOpts: {
|
|
359
|
+
sourceDescriptions: ['petStore', 'paymentApi'],
|
|
360
|
+
},
|
|
361
|
+
},
|
|
362
|
+
});
|
|
363
|
+
|
|
364
|
+
// Access parsed source descriptions
|
|
365
|
+
for (const element of parseResult) {
|
|
366
|
+
if (element.classes.includes('source-description')) {
|
|
367
|
+
console.log(element.meta.get('name').toValue()); // e.g., 'petStore'
|
|
368
|
+
console.log(element.meta.get('type').toValue()); // e.g., 'openapi'
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
```
|
|
372
|
+
|
|
295
373
|
#### [arazzo-yaml-1](https://github.com/speclynx/apidom/tree/main/packages/apidom-reference/src/parse/parsers/arazzo-yaml-1)
|
|
296
374
|
|
|
297
375
|
Wraps [@speclynx/apidom-parser-adapter-arazzo-yaml-1](https://github.com/speclynx/apidom/tree/main/packages/apidom-parser-adapter-arazzo-yaml-1) package
|
|
@@ -308,6 +386,31 @@ Supported media types are:
|
|
|
308
386
|
]
|
|
309
387
|
```
|
|
310
388
|
|
|
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
|
+
##### Parser options
|
|
397
|
+
|
|
398
|
+
The following options can be passed via `parse.parserOpts` (globally) or `parse.parserOpts['arazzo-yaml-1']` (parser-specific).
|
|
399
|
+
Parser-specific options take precedence over global options. See [arazzo-json-1](#arazzo-json-1) for usage examples.
|
|
400
|
+
|
|
401
|
+
- **sourceDescriptions** - Controls which external source descriptions are parsed and included in the `ParseResultElement`.
|
|
402
|
+
- `true` - parse all source descriptions
|
|
403
|
+
- `string[]` - parse only source descriptions with matching names (e.g., `['petStore', 'paymentApi']`)
|
|
404
|
+
|
|
405
|
+
Each parsed source description is added with a `'source-description'` class and metadata (`name`, `type`).
|
|
406
|
+
Only OpenAPI 2.0, OpenAPI 3.0.x, OpenAPI 3.1.x, and Arazzo 1.x documents are accepted as source descriptions.
|
|
407
|
+
- **sourceDescriptionsMaxDepth** - Maximum recursion depth for parsing nested Arazzo source descriptions.
|
|
408
|
+
Defaults to `+Infinity`. Circular references are automatically detected and skipped.
|
|
409
|
+
|
|
410
|
+
##### Error handling
|
|
411
|
+
|
|
412
|
+
See [arazzo-json-1 Error handling](#error-handling) - the behavior is identical for both JSON and YAML parsers.
|
|
413
|
+
|
|
311
414
|
#### [json](https://github.com/speclynx/apidom/tree/main/packages/apidom-reference/src/parse/parsers/json)
|
|
312
415
|
|
|
313
416
|
Wraps [@speclynx/apidom-parser-adapter-json](https://github.com/speclynx/apidom/tree/main/packages/apidom-parser-adapter-json) package
|
|
@@ -365,8 +468,8 @@ returns `true` or until entire list of parser plugins is exhausted (throws error
|
|
|
365
468
|
new OpenAPIYAML3_1Parser({ allowEmpty: true, sourceMap: false }),
|
|
366
469
|
new AsyncAPIJSON2Parser({ allowEmpty: true, sourceMap: false }),
|
|
367
470
|
new AsyncAPIYAML2Parser({ allowEmpty: true, sourceMap: false }),
|
|
368
|
-
new ArazzoJSON1Parser({ allowEmpty: true, sourceMap: false }),
|
|
369
|
-
new ArazzoYAML1Parser({ allowEmpty: true, sourceMap: false }),
|
|
471
|
+
new ArazzoJSON1Parser({ allowEmpty: true, sourceMap: false, parseFn: parse }),
|
|
472
|
+
new ArazzoYAML1Parser({ allowEmpty: true, sourceMap: false, parseFn: parse }),
|
|
370
473
|
new APIDesignSystemsJSONParser({ allowEmpty: true, sourceMap: false }),
|
|
371
474
|
new APIDesignSystemsYAMLParser({ allowEmpty: true, sourceMap: false }),
|
|
372
475
|
new APIDOMJSONParser({ allowEmpty: true, sourceMap: false }),
|
|
@@ -406,8 +509,8 @@ options.parse.parsers = [
|
|
|
406
509
|
new OpenAPIYAML3_1Parser({ allowEmpty: true, sourceMap: false }),
|
|
407
510
|
new AsyncAPIJSON2Parser({ allowEmpty: true, sourceMap: false }),
|
|
408
511
|
new AsyncAPIYAML2Parser({ allowEmpty: true, sourceMap: false }),
|
|
409
|
-
new ArazzoJSON1Parser({ allowEmpty: true, sourceMap: false }),
|
|
410
|
-
new ArazzoYAML1Parser({ allowEmpty: true, sourceMap: false }),
|
|
512
|
+
new ArazzoJSON1Parser({ allowEmpty: true, sourceMap: false, parseFn: parse }),
|
|
513
|
+
new ArazzoYAML1Parser({ allowEmpty: true, sourceMap: false, parseFn: parse }),
|
|
411
514
|
new APIDesignSystemsJSONParser({ allowEmpty: true, sourceMap: false }),
|
|
412
515
|
new APIDesignSystemsYAMLParser({ allowEmpty: true, sourceMap: false }),
|
|
413
516
|
new APIDOMJSONParser({ allowEmpty: true, sourceMap: false }),
|
|
@@ -448,8 +551,8 @@ await parse('/home/user/oas.json', {
|
|
|
448
551
|
new OpenAPIYAML3_1Parser({ allowEmpty: true, sourceMap: false }),
|
|
449
552
|
new AsyncAPIJSON2Parser({ allowEmpty: true, sourceMap: false }),
|
|
450
553
|
new AsyncAPIYAML2Parser({ allowEmpty: true, sourceMap: false }),
|
|
451
|
-
new ArazzoJSON1Parser({ allowEmpty: true, sourceMap: false }),
|
|
452
|
-
new ArazzoYAML1Parser({ allowEmpty: true, sourceMap: false }),
|
|
554
|
+
new ArazzoJSON1Parser({ allowEmpty: true, sourceMap: false, parseFn: parse }),
|
|
555
|
+
new ArazzoYAML1Parser({ allowEmpty: true, sourceMap: false, parseFn: parse }),
|
|
453
556
|
new APIDesignSystemsJSONParser({ allowEmpty: true, sourceMap: false }),
|
|
454
557
|
new APIDesignSystemsYAMLParser({ allowEmpty: true, sourceMap: false }),
|
|
455
558
|
new APIDOMJSONParser({ allowEmpty: true, sourceMap: false }),
|