@speclynx/apidom-reference 2.8.0 → 2.10.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 +14 -0
- package/README.md +208 -5
- package/dist/apidom-reference.browser.js +167 -77
- package/dist/apidom-reference.browser.min.js +1 -1
- package/package.json +25 -25
- package/src/dereference/strategies/arazzo-1/index.cjs +3 -2
- package/src/dereference/strategies/arazzo-1/index.mjs +3 -2
- package/src/dereference/strategies/arazzo-1/{source-description.cjs → source-descriptions.cjs} +98 -29
- package/src/dereference/strategies/arazzo-1/{source-description.mjs → source-descriptions.mjs} +99 -28
- package/src/parse/parsers/arazzo-json-1/source-descriptions.cjs +33 -15
- package/src/parse/parsers/arazzo-json-1/source-descriptions.mjs +33 -15
- package/types/dereference/strategies/arazzo-1/index.d.ts +1 -0
- package/types/dereference/strategies/arazzo-1/source-descriptions.d.ts +44 -0
- package/types/parse/parsers/arazzo-json-1/source-descriptions.d.ts +23 -8
- package/types/dereference/strategies/arazzo-1/source-description.d.ts +0 -8
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,20 @@
|
|
|
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.10.0](https://github.com/speclynx/apidom/compare/v2.9.0...v2.10.0) (2026-02-08)
|
|
7
|
+
|
|
8
|
+
### Features
|
|
9
|
+
|
|
10
|
+
- **reference:** add retrievalURI metadata for Arazzo Source Descriptions ([#79](https://github.com/speclynx/apidom/issues/79)) ([df78cb3](https://github.com/speclynx/apidom/commit/df78cb3226521e6f7097b85cccdbc6b0b39e7a7b))
|
|
11
|
+
|
|
12
|
+
# [2.9.0](https://github.com/speclynx/apidom/compare/v2.8.0...v2.9.0) (2026-02-08)
|
|
13
|
+
|
|
14
|
+
### Features
|
|
15
|
+
|
|
16
|
+
- **reference:** attach parse result as meta to Arazzo source descriptions ([#76](https://github.com/speclynx/apidom/issues/76)) ([448a099](https://github.com/speclynx/apidom/commit/448a099fc6af8189302346efdcc117c95c9b6e3b))
|
|
17
|
+
- **reference:** avoid re-resolving Arazzo source descriptions during dereferencing ([#77](https://github.com/speclynx/apidom/issues/77)) ([0ad63e8](https://github.com/speclynx/apidom/commit/0ad63e8d204d991a0de47b486ad391d506eb66dc))
|
|
18
|
+
- **reference:** expose low level API for dereferencing Arazzo source descriptions ([#75](https://github.com/speclynx/apidom/issues/75)) ([3b1e343](https://github.com/speclynx/apidom/commit/3b1e343c58ff983201ac0509bf841845bbf7eb83))
|
|
19
|
+
|
|
6
20
|
# [2.8.0](https://github.com/speclynx/apidom/compare/v2.7.0...v2.8.0) (2026-02-06)
|
|
7
21
|
|
|
8
22
|
### Features
|
package/README.md
CHANGED
|
@@ -301,7 +301,7 @@ Parser-specific options take precedence over global options.
|
|
|
301
301
|
- `true` - parse all source descriptions
|
|
302
302
|
- `string[]` - parse only source descriptions with matching names (e.g., `['petStore', 'paymentApi']`)
|
|
303
303
|
|
|
304
|
-
Each parsed source description is added with a `'source-description'` class and metadata (`name`, `type`).
|
|
304
|
+
Each parsed source description is added with a `'source-description'` class and metadata (`name`, `type`, `retrievalURI`).
|
|
305
305
|
Only OpenAPI 2.0, OpenAPI 3.0.x, OpenAPI 3.1.x, and Arazzo 1.x documents are accepted as source descriptions.
|
|
306
306
|
- **sourceDescriptionsMaxDepth** - Maximum recursion depth for parsing nested Arazzo source descriptions.
|
|
307
307
|
Defaults to `+Infinity`. Circular references are automatically detected and skipped.
|
|
@@ -321,6 +321,7 @@ with an `'error'` class within the parse result:
|
|
|
321
321
|
for parsing are not met (e.g., API is not an Arazzo specification)
|
|
322
322
|
|
|
323
323
|
```js
|
|
324
|
+
import { toValue } from '@speclynx/apidom-core';
|
|
324
325
|
import { parse } from '@speclynx/apidom-reference';
|
|
325
326
|
|
|
326
327
|
// Parse all source descriptions
|
|
@@ -345,12 +346,89 @@ const parseResultFiltered = await parse('/path/to/arazzo.json', {
|
|
|
345
346
|
// Access parsed source descriptions
|
|
346
347
|
for (const element of parseResult) {
|
|
347
348
|
if (element.classes.includes('source-description')) {
|
|
348
|
-
console.log(element.meta.get('name')
|
|
349
|
-
console.log(element.meta.get('type')
|
|
349
|
+
console.log(toValue(element.meta.get('name'))); // e.g., 'petStore'
|
|
350
|
+
console.log(toValue(element.meta.get('type'))); // e.g., 'openapi'
|
|
351
|
+
console.log(toValue(element.meta.get('retrievalURI'))); // e.g., '/path/to/petstore.json'
|
|
350
352
|
}
|
|
351
353
|
}
|
|
352
354
|
```
|
|
353
355
|
|
|
356
|
+
##### Accessing parsed documents via SourceDescriptionElement
|
|
357
|
+
|
|
358
|
+
When source descriptions parsing is enabled, a `ParseResultElement` is attached to each
|
|
359
|
+
`SourceDescriptionElement`'s meta as `'parseResult'`. This attachment always happens,
|
|
360
|
+
regardless of success or failure:
|
|
361
|
+
|
|
362
|
+
- **On success**: The parseResult contains the parsed API document
|
|
363
|
+
- **On failure**: The parseResult contains error/warning annotations explaining what went wrong
|
|
364
|
+
|
|
365
|
+
```js
|
|
366
|
+
import { toValue } from '@speclynx/apidom-core';
|
|
367
|
+
import { parse } from '@speclynx/apidom-reference';
|
|
368
|
+
|
|
369
|
+
const parseResult = await parse('/path/to/arazzo.json', {
|
|
370
|
+
parse: { parserOpts: { sourceDescriptions: true } },
|
|
371
|
+
});
|
|
372
|
+
|
|
373
|
+
// Access parsed document from source description element
|
|
374
|
+
const api = parseResult.api;
|
|
375
|
+
const sourceDesc = api.sourceDescriptions.get(0);
|
|
376
|
+
const parsedDoc = sourceDesc.meta.get('parseResult');
|
|
377
|
+
|
|
378
|
+
// Check for errors before using
|
|
379
|
+
if (parsedDoc.errors.length > 0) {
|
|
380
|
+
console.log('Parsing failed:', parsedDoc.errors);
|
|
381
|
+
} else {
|
|
382
|
+
console.log(parsedDoc.api.element); // e.g., 'openApi3_1'
|
|
383
|
+
console.log(toValue(parsedDoc.meta.get('retrievalURI'))); // URI where it was fetched from
|
|
384
|
+
}
|
|
385
|
+
```
|
|
386
|
+
|
|
387
|
+
##### Low-level API
|
|
388
|
+
|
|
389
|
+
For advanced use cases where you need to parse source descriptions from an already-parsed Arazzo document
|
|
390
|
+
(e.g., when using naked parser adapters directly), the `parseSourceDescriptions` function is exported.
|
|
391
|
+
|
|
392
|
+
When called directly, this function always parses source descriptions (no need to pass `sourceDescriptions: true`).
|
|
393
|
+
Use an array to filter by name:
|
|
394
|
+
|
|
395
|
+
```js
|
|
396
|
+
import { parse } from '@speclynx/apidom-parser-adapter-arazzo-json-1';
|
|
397
|
+
import { parseSourceDescriptions } from '@speclynx/apidom-reference/parse/parsers/arazzo-json-1';
|
|
398
|
+
import { options, mergeOptions } from '@speclynx/apidom-reference';
|
|
399
|
+
|
|
400
|
+
// Parse using naked parser adapter
|
|
401
|
+
const parseResult = await parse(arazzoJsonString);
|
|
402
|
+
|
|
403
|
+
// Parse all source descriptions
|
|
404
|
+
const sourceDescriptions = await parseSourceDescriptions(
|
|
405
|
+
parseResult,
|
|
406
|
+
'/path/to/arazzo.json',
|
|
407
|
+
options,
|
|
408
|
+
);
|
|
409
|
+
|
|
410
|
+
// Or filter by name
|
|
411
|
+
const filtered = await parseSourceDescriptions(
|
|
412
|
+
parseResult,
|
|
413
|
+
'/path/to/arazzo.json',
|
|
414
|
+
mergeOptions(options, { parse: { parserOpts: { sourceDescriptions: ['petStore'] } } }),
|
|
415
|
+
);
|
|
416
|
+
|
|
417
|
+
// Access parsed document from source description element
|
|
418
|
+
const sourceDesc = parseResult.api.sourceDescriptions.get(0);
|
|
419
|
+
const parsedDoc = sourceDesc.meta.get('parseResult');
|
|
420
|
+
```
|
|
421
|
+
|
|
422
|
+
The function signature is:
|
|
423
|
+
```typescript
|
|
424
|
+
parseSourceDescriptions(
|
|
425
|
+
parseResult: ParseResultElement,
|
|
426
|
+
parseResultRetrievalURI: string,
|
|
427
|
+
options: ReferenceOptions,
|
|
428
|
+
parserName?: string, // defaults to 'arazzo-json-1'
|
|
429
|
+
): Promise<ParseResultElement[]>
|
|
430
|
+
```
|
|
431
|
+
|
|
354
432
|
#### [arazzo-yaml-1](https://github.com/speclynx/apidom/tree/main/packages/apidom-reference/src/parse/parsers/arazzo-yaml-1)
|
|
355
433
|
|
|
356
434
|
Wraps [@speclynx/apidom-parser-adapter-arazzo-yaml-1](https://github.com/speclynx/apidom/tree/main/packages/apidom-parser-adapter-arazzo-yaml-1) package
|
|
@@ -376,7 +454,7 @@ Parser-specific options take precedence over global options. See [arazzo-json-1]
|
|
|
376
454
|
- `true` - parse all source descriptions
|
|
377
455
|
- `string[]` - parse only source descriptions with matching names (e.g., `['petStore', 'paymentApi']`)
|
|
378
456
|
|
|
379
|
-
Each parsed source description is added with a `'source-description'` class and metadata (`name`, `type`).
|
|
457
|
+
Each parsed source description is added with a `'source-description'` class and metadata (`name`, `type`, `retrievalURI`).
|
|
380
458
|
Only OpenAPI 2.0, OpenAPI 3.0.x, OpenAPI 3.1.x, and Arazzo 1.x documents are accepted as source descriptions.
|
|
381
459
|
- **sourceDescriptionsMaxDepth** - Maximum recursion depth for parsing nested Arazzo source descriptions.
|
|
382
460
|
Defaults to `+Infinity`. Circular references are automatically detected and skipped.
|
|
@@ -385,6 +463,55 @@ Parser-specific options take precedence over global options. See [arazzo-json-1]
|
|
|
385
463
|
|
|
386
464
|
See [arazzo-json-1 Error handling](#error-handling) - the behavior is identical for both JSON and YAML parsers.
|
|
387
465
|
|
|
466
|
+
##### Accessing parsed documents via SourceDescriptionElement
|
|
467
|
+
|
|
468
|
+
See [arazzo-json-1 Accessing parsed documents](#accessing-parsed-documents-via-sourcedescriptionelement) - the behavior is identical for both JSON and YAML parsers.
|
|
469
|
+
|
|
470
|
+
##### Low-level API
|
|
471
|
+
|
|
472
|
+
For advanced use cases where you need to parse source descriptions from an already-parsed Arazzo document
|
|
473
|
+
(e.g., when using naked parser adapters directly), the `parseSourceDescriptions` function is exported.
|
|
474
|
+
|
|
475
|
+
When called directly, this function always parses source descriptions (no need to pass `sourceDescriptions: true`).
|
|
476
|
+
Use an array to filter by name:
|
|
477
|
+
|
|
478
|
+
```js
|
|
479
|
+
import { parse } from '@speclynx/apidom-parser-adapter-arazzo-yaml-1';
|
|
480
|
+
import { parseSourceDescriptions } from '@speclynx/apidom-reference/parse/parsers/arazzo-yaml-1';
|
|
481
|
+
import { options, mergeOptions } from '@speclynx/apidom-reference';
|
|
482
|
+
|
|
483
|
+
// Parse using naked parser adapter
|
|
484
|
+
const parseResult = await parse(arazzoYamlString);
|
|
485
|
+
|
|
486
|
+
// Parse all source descriptions
|
|
487
|
+
const sourceDescriptions = await parseSourceDescriptions(
|
|
488
|
+
parseResult,
|
|
489
|
+
'/path/to/arazzo.yaml',
|
|
490
|
+
options,
|
|
491
|
+
);
|
|
492
|
+
|
|
493
|
+
// Or filter by name
|
|
494
|
+
const filtered = await parseSourceDescriptions(
|
|
495
|
+
parseResult,
|
|
496
|
+
'/path/to/arazzo.yaml',
|
|
497
|
+
mergeOptions(options, { parse: { parserOpts: { sourceDescriptions: ['petStore'] } } }),
|
|
498
|
+
);
|
|
499
|
+
|
|
500
|
+
// Access parsed document from source description element
|
|
501
|
+
const sourceDesc = parseResult.api.sourceDescriptions.get(0);
|
|
502
|
+
const parsedDoc = sourceDesc.meta.get('parseResult');
|
|
503
|
+
```
|
|
504
|
+
|
|
505
|
+
The function signature is:
|
|
506
|
+
```typescript
|
|
507
|
+
parseSourceDescriptions(
|
|
508
|
+
parseResult: ParseResultElement,
|
|
509
|
+
parseResultRetrievalURI: string,
|
|
510
|
+
options: ReferenceOptions,
|
|
511
|
+
parserName?: string, // defaults to 'arazzo-yaml-1'
|
|
512
|
+
): Promise<ParseResultElement[]>
|
|
513
|
+
```
|
|
514
|
+
|
|
388
515
|
#### [json](https://github.com/speclynx/apidom/tree/main/packages/apidom-reference/src/parse/parsers/json)
|
|
389
516
|
|
|
390
517
|
Wraps [@speclynx/apidom-parser-adapter-json](https://github.com/speclynx/apidom/tree/main/packages/apidom-parser-adapter-json) package
|
|
@@ -1633,7 +1760,7 @@ Strategy-specific options take precedence over global options.
|
|
|
1633
1760
|
- `true` - dereference all source descriptions
|
|
1634
1761
|
- `string[]` - dereference only source descriptions with matching names (e.g., `['petStore', 'paymentApi']`)
|
|
1635
1762
|
|
|
1636
|
-
Each dereferenced source description is added with a `'source-description'` class and metadata (`name`, `type`).
|
|
1763
|
+
Each dereferenced source description is added with a `'source-description'` class and metadata (`name`, `type`, `retrievalURI`).
|
|
1637
1764
|
Only OpenAPI 2.0, OpenAPI 3.0.x, OpenAPI 3.1.x, and Arazzo 1.x documents are accepted as source descriptions.
|
|
1638
1765
|
- **sourceDescriptionsMaxDepth** - Maximum recursion depth for dereferencing nested Arazzo source descriptions.
|
|
1639
1766
|
Defaults to `+Infinity`. Circular references are automatically detected and skipped.
|
|
@@ -1677,6 +1804,82 @@ const resultFiltered = await dereference('/path/to/arazzo.json', {
|
|
|
1677
1804
|
});
|
|
1678
1805
|
```
|
|
1679
1806
|
|
|
1807
|
+
###### Accessing dereferenced documents via SourceDescriptionElement
|
|
1808
|
+
|
|
1809
|
+
When source descriptions dereferencing is enabled, a `ParseResultElement` is attached to each
|
|
1810
|
+
`SourceDescriptionElement`'s meta as `'parseResult'`. This attachment always happens,
|
|
1811
|
+
regardless of success or failure:
|
|
1812
|
+
|
|
1813
|
+
- **On success**: The parseResult contains the dereferenced API document
|
|
1814
|
+
- **On failure**: The parseResult contains error/warning annotations explaining what went wrong
|
|
1815
|
+
|
|
1816
|
+
```js
|
|
1817
|
+
import { toValue } from '@speclynx/apidom-core';
|
|
1818
|
+
import { dereference } from '@speclynx/apidom-reference';
|
|
1819
|
+
|
|
1820
|
+
const parseResult = await dereference('/path/to/arazzo.json', {
|
|
1821
|
+
dereference: { strategyOpts: { sourceDescriptions: true } },
|
|
1822
|
+
});
|
|
1823
|
+
|
|
1824
|
+
// Access dereferenced document from source description element
|
|
1825
|
+
const api = parseResult.api;
|
|
1826
|
+
const sourceDesc = api.sourceDescriptions.get(0);
|
|
1827
|
+
const dereferencedDoc = sourceDesc.meta.get('parseResult');
|
|
1828
|
+
|
|
1829
|
+
// Check for errors before using
|
|
1830
|
+
if (dereferencedDoc.errors.length > 0) {
|
|
1831
|
+
console.log('Dereferencing failed:', dereferencedDoc.errors);
|
|
1832
|
+
} else {
|
|
1833
|
+
console.log(dereferencedDoc.api.element); // e.g., 'openApi3_1'
|
|
1834
|
+
console.log(toValue(dereferencedDoc.meta.get('retrievalURI'))); // URI where it was fetched from
|
|
1835
|
+
}
|
|
1836
|
+
```
|
|
1837
|
+
|
|
1838
|
+
###### Low-level API
|
|
1839
|
+
|
|
1840
|
+
For advanced use cases where you need to dereference source descriptions from an already-parsed (optionally dereferenced)
|
|
1841
|
+
Arazzo document (e.g., when using naked parser adapters directly), the `dereferenceSourceDescriptions` function is exported.
|
|
1842
|
+
|
|
1843
|
+
When called directly, this function always dereferences source descriptions (no need to pass `sourceDescriptions: true`).
|
|
1844
|
+
Use an array to filter by name:
|
|
1845
|
+
|
|
1846
|
+
```js
|
|
1847
|
+
import { parse } from '@speclynx/apidom-parser-adapter-arazzo-json-1';
|
|
1848
|
+
import { dereferenceSourceDescriptions } from '@speclynx/apidom-reference/dereference/strategies/arazzo-1';
|
|
1849
|
+
import { options, mergeOptions } from '@speclynx/apidom-reference';
|
|
1850
|
+
|
|
1851
|
+
// Parse using naked parser adapter
|
|
1852
|
+
const parseResult = await parse(arazzoJsonString);
|
|
1853
|
+
|
|
1854
|
+
// Dereference all source descriptions
|
|
1855
|
+
const sourceDescriptions = await dereferenceSourceDescriptions(
|
|
1856
|
+
parseResult,
|
|
1857
|
+
'/path/to/arazzo.json',
|
|
1858
|
+
options,
|
|
1859
|
+
);
|
|
1860
|
+
|
|
1861
|
+
// Or filter by name
|
|
1862
|
+
const filtered = await dereferenceSourceDescriptions(
|
|
1863
|
+
parseResult,
|
|
1864
|
+
'/path/to/arazzo.json',
|
|
1865
|
+
mergeOptions(options, { dereference: { strategyOpts: { sourceDescriptions: ['petStore'] } } }),
|
|
1866
|
+
);
|
|
1867
|
+
|
|
1868
|
+
// Access dereferenced document from source description element
|
|
1869
|
+
const sourceDesc = parseResult.api.sourceDescriptions.get(0);
|
|
1870
|
+
const dereferencedDoc = sourceDesc.meta.get('parseResult');
|
|
1871
|
+
```
|
|
1872
|
+
|
|
1873
|
+
The function signature is:
|
|
1874
|
+
```typescript
|
|
1875
|
+
dereferenceSourceDescriptions(
|
|
1876
|
+
parseResult: ParseResultElement,
|
|
1877
|
+
parseResultRetrievalURI: string,
|
|
1878
|
+
options: ReferenceOptions,
|
|
1879
|
+
strategyName?: string, // defaults to 'arazzo-1'
|
|
1880
|
+
): Promise<ParseResultElement[]>
|
|
1881
|
+
```
|
|
1882
|
+
|
|
1680
1883
|
##### [openapi-2](https://github.com/speclynx/apidom/tree/main/packages/apidom-reference/src/dereference/strategies/openapi-2)
|
|
1681
1884
|
|
|
1682
1885
|
Dereference strategy for dereferencing [OpenApi 2.0](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/2.0.md) definitions.
|