@speclynx/apidom-reference 2.7.0 → 2.9.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 +197 -0
- package/dist/apidom-reference.browser.js +221 -83
- 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} +94 -29
- package/src/dereference/strategies/arazzo-1/{source-description.mjs → source-descriptions.mjs} +95 -28
- package/src/parse/parsers/arazzo-json-1/index.cjs +3 -2
- package/src/parse/parsers/arazzo-json-1/index.mjs +3 -2
- package/src/parse/parsers/arazzo-json-1/{source-description.cjs → source-descriptions.cjs} +58 -12
- package/src/parse/parsers/arazzo-json-1/{source-description.mjs → source-descriptions.mjs} +57 -11
- package/src/parse/parsers/arazzo-yaml-1/index.cjs +3 -2
- package/src/parse/parsers/arazzo-yaml-1/index.mjs +3 -2
- package/src/parse/parsers/arazzo-yaml-1/source-descriptions.cjs +12 -0
- package/src/parse/parsers/arazzo-yaml-1/source-descriptions.mjs +7 -0
- package/types/dereference/strategies/arazzo-1/index.d.ts +1 -0
- package/types/dereference/strategies/arazzo-1/source-descriptions.d.ts +41 -0
- package/types/parse/parsers/arazzo-json-1/index.d.ts +1 -0
- package/types/parse/parsers/arazzo-json-1/source-descriptions.d.ts +44 -0
- package/types/parse/parsers/arazzo-yaml-1/index.d.ts +1 -0
- package/types/parse/parsers/arazzo-yaml-1/source-descriptions.d.ts +6 -0
- package/types/dereference/strategies/arazzo-1/source-description.d.ts +0 -8
- package/types/parse/parsers/arazzo-json-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.9.0](https://github.com/speclynx/apidom/compare/v2.8.0...v2.9.0) (2026-02-08)
|
|
7
|
+
|
|
8
|
+
### Features
|
|
9
|
+
|
|
10
|
+
- **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))
|
|
11
|
+
- **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))
|
|
12
|
+
- **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))
|
|
13
|
+
|
|
14
|
+
# [2.8.0](https://github.com/speclynx/apidom/compare/v2.7.0...v2.8.0) (2026-02-06)
|
|
15
|
+
|
|
16
|
+
### Features
|
|
17
|
+
|
|
18
|
+
- **reference:** expose low level API for parsing Arazzo source descriptions ([#73](https://github.com/speclynx/apidom/issues/73)) ([1f0d771](https://github.com/speclynx/apidom/commit/1f0d7713f864924e03c601113c0270aeed6e9f81))
|
|
19
|
+
|
|
6
20
|
# [2.7.0](https://github.com/speclynx/apidom/compare/v2.6.1...v2.7.0) (2026-02-05)
|
|
7
21
|
|
|
8
22
|
### Features
|
package/README.md
CHANGED
|
@@ -351,6 +351,80 @@ for (const element of parseResult) {
|
|
|
351
351
|
}
|
|
352
352
|
```
|
|
353
353
|
|
|
354
|
+
##### Accessing parsed documents via SourceDescriptionElement
|
|
355
|
+
|
|
356
|
+
When source descriptions parsing is enabled, a `ParseResultElement` is attached to each
|
|
357
|
+
`SourceDescriptionElement`'s meta as `'parseResult'`. This attachment always happens,
|
|
358
|
+
regardless of success or failure:
|
|
359
|
+
|
|
360
|
+
- **On success**: The parseResult contains the parsed API document
|
|
361
|
+
- **On failure**: The parseResult contains error/warning annotations explaining what went wrong
|
|
362
|
+
|
|
363
|
+
```js
|
|
364
|
+
import { parse } from '@speclynx/apidom-reference';
|
|
365
|
+
|
|
366
|
+
const parseResult = await parse('/path/to/arazzo.json', {
|
|
367
|
+
parse: { parserOpts: { sourceDescriptions: true } },
|
|
368
|
+
});
|
|
369
|
+
|
|
370
|
+
// Access parsed document from source description element
|
|
371
|
+
const api = parseResult.api;
|
|
372
|
+
const sourceDesc = api.sourceDescriptions.get(0);
|
|
373
|
+
const parsedDoc = sourceDesc.meta.get('parseResult');
|
|
374
|
+
|
|
375
|
+
// Check for errors before using
|
|
376
|
+
if (parsedDoc.errors.length > 0) {
|
|
377
|
+
console.log('Parsing failed:', parsedDoc.errors);
|
|
378
|
+
} else {
|
|
379
|
+
console.log(parsedDoc.api.element); // e.g., 'openApi3_1'
|
|
380
|
+
}
|
|
381
|
+
```
|
|
382
|
+
|
|
383
|
+
##### Low-level API
|
|
384
|
+
|
|
385
|
+
For advanced use cases where you need to parse source descriptions from an already-parsed Arazzo document
|
|
386
|
+
(e.g., when using naked parser adapters directly), the `parseSourceDescriptions` function is exported.
|
|
387
|
+
|
|
388
|
+
When called directly, this function always parses source descriptions (no need to pass `sourceDescriptions: true`).
|
|
389
|
+
Use an array to filter by name:
|
|
390
|
+
|
|
391
|
+
```js
|
|
392
|
+
import { parse } from '@speclynx/apidom-parser-adapter-arazzo-json-1';
|
|
393
|
+
import { parseSourceDescriptions } from '@speclynx/apidom-reference/parse/parsers/arazzo-json-1';
|
|
394
|
+
import { options, mergeOptions } from '@speclynx/apidom-reference';
|
|
395
|
+
|
|
396
|
+
// Parse using naked parser adapter
|
|
397
|
+
const parseResult = await parse(arazzoJsonString);
|
|
398
|
+
|
|
399
|
+
// Parse all source descriptions
|
|
400
|
+
const sourceDescriptions = await parseSourceDescriptions(
|
|
401
|
+
parseResult,
|
|
402
|
+
'/path/to/arazzo.json',
|
|
403
|
+
options,
|
|
404
|
+
);
|
|
405
|
+
|
|
406
|
+
// Or filter by name
|
|
407
|
+
const filtered = await parseSourceDescriptions(
|
|
408
|
+
parseResult,
|
|
409
|
+
'/path/to/arazzo.json',
|
|
410
|
+
mergeOptions(options, { parse: { parserOpts: { sourceDescriptions: ['petStore'] } } }),
|
|
411
|
+
);
|
|
412
|
+
|
|
413
|
+
// Access parsed document from source description element
|
|
414
|
+
const sourceDesc = parseResult.api.sourceDescriptions.get(0);
|
|
415
|
+
const parsedDoc = sourceDesc.meta.get('parseResult');
|
|
416
|
+
```
|
|
417
|
+
|
|
418
|
+
The function signature is:
|
|
419
|
+
```typescript
|
|
420
|
+
parseSourceDescriptions(
|
|
421
|
+
parseResult: ParseResultElement,
|
|
422
|
+
parseResultRetrievalURI: string,
|
|
423
|
+
options: ReferenceOptions,
|
|
424
|
+
parserName?: string, // defaults to 'arazzo-json-1'
|
|
425
|
+
): Promise<ParseResultElement[]>
|
|
426
|
+
```
|
|
427
|
+
|
|
354
428
|
#### [arazzo-yaml-1](https://github.com/speclynx/apidom/tree/main/packages/apidom-reference/src/parse/parsers/arazzo-yaml-1)
|
|
355
429
|
|
|
356
430
|
Wraps [@speclynx/apidom-parser-adapter-arazzo-yaml-1](https://github.com/speclynx/apidom/tree/main/packages/apidom-parser-adapter-arazzo-yaml-1) package
|
|
@@ -385,6 +459,55 @@ Parser-specific options take precedence over global options. See [arazzo-json-1]
|
|
|
385
459
|
|
|
386
460
|
See [arazzo-json-1 Error handling](#error-handling) - the behavior is identical for both JSON and YAML parsers.
|
|
387
461
|
|
|
462
|
+
##### Accessing parsed documents via SourceDescriptionElement
|
|
463
|
+
|
|
464
|
+
See [arazzo-json-1 Accessing parsed documents](#accessing-parsed-documents-via-sourcedescriptionelement) - the behavior is identical for both JSON and YAML parsers.
|
|
465
|
+
|
|
466
|
+
##### Low-level API
|
|
467
|
+
|
|
468
|
+
For advanced use cases where you need to parse source descriptions from an already-parsed Arazzo document
|
|
469
|
+
(e.g., when using naked parser adapters directly), the `parseSourceDescriptions` function is exported.
|
|
470
|
+
|
|
471
|
+
When called directly, this function always parses source descriptions (no need to pass `sourceDescriptions: true`).
|
|
472
|
+
Use an array to filter by name:
|
|
473
|
+
|
|
474
|
+
```js
|
|
475
|
+
import { parse } from '@speclynx/apidom-parser-adapter-arazzo-yaml-1';
|
|
476
|
+
import { parseSourceDescriptions } from '@speclynx/apidom-reference/parse/parsers/arazzo-yaml-1';
|
|
477
|
+
import { options, mergeOptions } from '@speclynx/apidom-reference';
|
|
478
|
+
|
|
479
|
+
// Parse using naked parser adapter
|
|
480
|
+
const parseResult = await parse(arazzoYamlString);
|
|
481
|
+
|
|
482
|
+
// Parse all source descriptions
|
|
483
|
+
const sourceDescriptions = await parseSourceDescriptions(
|
|
484
|
+
parseResult,
|
|
485
|
+
'/path/to/arazzo.yaml',
|
|
486
|
+
options,
|
|
487
|
+
);
|
|
488
|
+
|
|
489
|
+
// Or filter by name
|
|
490
|
+
const filtered = await parseSourceDescriptions(
|
|
491
|
+
parseResult,
|
|
492
|
+
'/path/to/arazzo.yaml',
|
|
493
|
+
mergeOptions(options, { parse: { parserOpts: { sourceDescriptions: ['petStore'] } } }),
|
|
494
|
+
);
|
|
495
|
+
|
|
496
|
+
// Access parsed document from source description element
|
|
497
|
+
const sourceDesc = parseResult.api.sourceDescriptions.get(0);
|
|
498
|
+
const parsedDoc = sourceDesc.meta.get('parseResult');
|
|
499
|
+
```
|
|
500
|
+
|
|
501
|
+
The function signature is:
|
|
502
|
+
```typescript
|
|
503
|
+
parseSourceDescriptions(
|
|
504
|
+
parseResult: ParseResultElement,
|
|
505
|
+
parseResultRetrievalURI: string,
|
|
506
|
+
options: ReferenceOptions,
|
|
507
|
+
parserName?: string, // defaults to 'arazzo-yaml-1'
|
|
508
|
+
): Promise<ParseResultElement[]>
|
|
509
|
+
```
|
|
510
|
+
|
|
388
511
|
#### [json](https://github.com/speclynx/apidom/tree/main/packages/apidom-reference/src/parse/parsers/json)
|
|
389
512
|
|
|
390
513
|
Wraps [@speclynx/apidom-parser-adapter-json](https://github.com/speclynx/apidom/tree/main/packages/apidom-parser-adapter-json) package
|
|
@@ -1677,6 +1800,80 @@ const resultFiltered = await dereference('/path/to/arazzo.json', {
|
|
|
1677
1800
|
});
|
|
1678
1801
|
```
|
|
1679
1802
|
|
|
1803
|
+
###### Accessing dereferenced documents via SourceDescriptionElement
|
|
1804
|
+
|
|
1805
|
+
When source descriptions dereferencing is enabled, a `ParseResultElement` is attached to each
|
|
1806
|
+
`SourceDescriptionElement`'s meta as `'parseResult'`. This attachment always happens,
|
|
1807
|
+
regardless of success or failure:
|
|
1808
|
+
|
|
1809
|
+
- **On success**: The parseResult contains the dereferenced API document
|
|
1810
|
+
- **On failure**: The parseResult contains error/warning annotations explaining what went wrong
|
|
1811
|
+
|
|
1812
|
+
```js
|
|
1813
|
+
import { dereference } from '@speclynx/apidom-reference';
|
|
1814
|
+
|
|
1815
|
+
const parseResult = await dereference('/path/to/arazzo.json', {
|
|
1816
|
+
dereference: { strategyOpts: { sourceDescriptions: true } },
|
|
1817
|
+
});
|
|
1818
|
+
|
|
1819
|
+
// Access dereferenced document from source description element
|
|
1820
|
+
const api = parseResult.api;
|
|
1821
|
+
const sourceDesc = api.sourceDescriptions.get(0);
|
|
1822
|
+
const dereferencedDoc = sourceDesc.meta.get('parseResult');
|
|
1823
|
+
|
|
1824
|
+
// Check for errors before using
|
|
1825
|
+
if (dereferencedDoc.errors.length > 0) {
|
|
1826
|
+
console.log('Dereferencing failed:', dereferencedDoc.errors);
|
|
1827
|
+
} else {
|
|
1828
|
+
console.log(dereferencedDoc.api.element); // e.g., 'openApi3_1'
|
|
1829
|
+
}
|
|
1830
|
+
```
|
|
1831
|
+
|
|
1832
|
+
###### Low-level API
|
|
1833
|
+
|
|
1834
|
+
For advanced use cases where you need to dereference source descriptions from an already-parsed (optionally dereferenced)
|
|
1835
|
+
Arazzo document (e.g., when using naked parser adapters directly), the `dereferenceSourceDescriptions` function is exported.
|
|
1836
|
+
|
|
1837
|
+
When called directly, this function always dereferences source descriptions (no need to pass `sourceDescriptions: true`).
|
|
1838
|
+
Use an array to filter by name:
|
|
1839
|
+
|
|
1840
|
+
```js
|
|
1841
|
+
import { parse } from '@speclynx/apidom-parser-adapter-arazzo-json-1';
|
|
1842
|
+
import { dereferenceSourceDescriptions } from '@speclynx/apidom-reference/dereference/strategies/arazzo-1';
|
|
1843
|
+
import { options, mergeOptions } from '@speclynx/apidom-reference';
|
|
1844
|
+
|
|
1845
|
+
// Parse using naked parser adapter
|
|
1846
|
+
const parseResult = await parse(arazzoJsonString);
|
|
1847
|
+
|
|
1848
|
+
// Dereference all source descriptions
|
|
1849
|
+
const sourceDescriptions = await dereferenceSourceDescriptions(
|
|
1850
|
+
parseResult,
|
|
1851
|
+
'/path/to/arazzo.json',
|
|
1852
|
+
options,
|
|
1853
|
+
);
|
|
1854
|
+
|
|
1855
|
+
// Or filter by name
|
|
1856
|
+
const filtered = await dereferenceSourceDescriptions(
|
|
1857
|
+
parseResult,
|
|
1858
|
+
'/path/to/arazzo.json',
|
|
1859
|
+
mergeOptions(options, { dereference: { strategyOpts: { sourceDescriptions: ['petStore'] } } }),
|
|
1860
|
+
);
|
|
1861
|
+
|
|
1862
|
+
// Access dereferenced document from source description element
|
|
1863
|
+
const sourceDesc = parseResult.api.sourceDescriptions.get(0);
|
|
1864
|
+
const dereferencedDoc = sourceDesc.meta.get('parseResult');
|
|
1865
|
+
```
|
|
1866
|
+
|
|
1867
|
+
The function signature is:
|
|
1868
|
+
```typescript
|
|
1869
|
+
dereferenceSourceDescriptions(
|
|
1870
|
+
parseResult: ParseResultElement,
|
|
1871
|
+
parseResultRetrievalURI: string,
|
|
1872
|
+
options: ReferenceOptions,
|
|
1873
|
+
strategyName?: string, // defaults to 'arazzo-1'
|
|
1874
|
+
): Promise<ParseResultElement[]>
|
|
1875
|
+
```
|
|
1876
|
+
|
|
1680
1877
|
##### [openapi-2](https://github.com/speclynx/apidom/tree/main/packages/apidom-reference/src/dereference/strategies/openapi-2)
|
|
1681
1878
|
|
|
1682
1879
|
Dereference strategy for dereferencing [OpenApi 2.0](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/2.0.md) definitions.
|