|
| 1 | +--- |
| 2 | +name: Arazzo Resolver |
| 3 | +description: | |
| 4 | + TypeScript/JavaScript resolver and dereferencer for Arazzo Specification |
| 5 | + and OpenAPI documents. Resolves all internal and external references |
| 6 | + inline, producing self-contained ApiDOM data models. |
| 7 | +categories: |
| 8 | + - parsers |
| 9 | + - misc |
| 10 | +link: https://www.npmjs.com/package/@jentic/arazzo-resolver |
| 11 | +languages: |
| 12 | + typescript: true |
| 13 | + javascript: true |
| 14 | +repo: https://github.com/jentic/jentic-arazzo-tools/tree/main/packages/jentic-arazzo-resolver |
| 15 | +oaiSpecs: |
| 16 | + oas: true |
| 17 | + overlays: false |
| 18 | + arazzo: true |
| 19 | +oasVersions: |
| 20 | + v2: true |
| 21 | + v3: true |
| 22 | + v3_1: true |
| 23 | + v3_2: false |
| 24 | +badges: |
| 25 | + - arazzo-support |
| 26 | +--- |
| 27 | + |
| 28 | +## Overview |
| 29 | + |
| 30 | +`@jentic/arazzo-resolver` is a TypeScript/JavaScript library for resolving and dereferencing Arazzo Specification and OpenAPI documents. It replaces all references (`$ref`, `$components.*`, JSON Schema references) with their actual content, producing self-contained [SpecLynx ApiDOM](https://github.com/speclynx/apidom) data models ready for programmatic processing. |
| 31 | + |
| 32 | +Works standalone from a file path or URL, or in combination with `@jentic/arazzo-parser` to dereference already-parsed elements. |
| 33 | + |
| 34 | +## Installation |
| 35 | + |
| 36 | +```bash |
| 37 | +npm install @jentic/arazzo-resolver |
| 38 | +``` |
| 39 | + |
| 40 | +## Usage |
| 41 | + |
| 42 | +**Dereference from a file path or URL:** |
| 43 | + |
| 44 | +```typescript |
| 45 | +import { dereferenceArazzo } from '@jentic/arazzo-resolver'; |
| 46 | + |
| 47 | +// Local file |
| 48 | +const parseResult = await dereferenceArazzo('/path/to/arazzo.json'); |
| 49 | + |
| 50 | +// Remote URL |
| 51 | +const parseResult = await dereferenceArazzo('https://example.com/arazzo.yaml'); |
| 52 | +// parseResult is a ParseResultElement with all references resolved inline |
| 53 | +``` |
| 54 | + |
| 55 | +**Dereference an already-parsed element (with `@jentic/arazzo-parser`):** |
| 56 | + |
| 57 | +```typescript |
| 58 | +import { parseArazzo } from '@jentic/arazzo-parser'; |
| 59 | +import { dereferenceArazzoElement } from '@jentic/arazzo-resolver'; |
| 60 | + |
| 61 | +const parseResult = await parseArazzo('/path/to/arazzo.json'); |
| 62 | +const dereferenced = await dereferenceArazzoElement(parseResult); |
| 63 | +``` |
| 64 | + |
| 65 | +**Dereference inline content — provide a `baseURI`:** |
| 66 | + |
| 67 | +```typescript |
| 68 | +import { parseArazzo } from '@jentic/arazzo-parser'; |
| 69 | +import { dereferenceArazzoElement } from '@jentic/arazzo-resolver'; |
| 70 | + |
| 71 | +const parseResult = await parseArazzo({ arazzo: '1.0.1', ... }); |
| 72 | +const dereferenced = await dereferenceArazzoElement(parseResult, { |
| 73 | + resolve: { baseURI: 'https://example.com/arazzo.json' }, |
| 74 | +}); |
| 75 | +``` |
| 76 | + |
| 77 | +**Dereference a specific child element (e.g. a single workflow):** |
| 78 | + |
| 79 | +```typescript |
| 80 | +import { parseArazzo } from '@jentic/arazzo-parser'; |
| 81 | +import { dereferenceArazzoElement } from '@jentic/arazzo-resolver'; |
| 82 | + |
| 83 | +const parseResult = await parseArazzo('/path/to/arazzo.json'); |
| 84 | +const workflow = parseResult.api.workflows.get(0); |
| 85 | + |
| 86 | +const dereferencedWorkflow = await dereferenceArazzoElement(workflow, { |
| 87 | + dereference: { strategyOpts: { parseResult } }, |
| 88 | +}); |
| 89 | +``` |
| 90 | + |
| 91 | +**OpenAPI documents:** |
| 92 | + |
| 93 | +```typescript |
| 94 | +import { dereferenceOpenAPI } from '@jentic/arazzo-resolver'; |
| 95 | + |
| 96 | +const parseResult = await dereferenceOpenAPI('/path/to/openapi.yaml'); |
| 97 | +``` |
| 98 | + |
| 99 | +## API |
| 100 | + |
| 101 | +| Function | Description | |
| 102 | +| ------------------------------------------- | ------------------------------------------------------- | |
| 103 | +| `dereferenceArazzo(uri)` | Dereference an Arazzo document from a file path or URL | |
| 104 | +| `dereferenceArazzoElement(element, opts?)` | Dereference a SpecLynx ApiDOM Arazzo element | |
| 105 | +| `dereferenceOpenAPI(uri)` | Dereference an OpenAPI document from a file path or URL | |
| 106 | +| `dereferenceOpenAPIElement(element, opts?)` | Dereference a SpecLynx ApiDOM OpenAPI element | |
| 107 | + |
| 108 | +## What Gets Resolved |
| 109 | + |
| 110 | +**In Arazzo documents:** |
| 111 | + |
| 112 | +- JSON Schema references |
| 113 | +- Reusable object references (`$components.*`) |
| 114 | + |
| 115 | +**In OpenAPI documents:** |
| 116 | + |
| 117 | +- Reference Objects (`$ref`) — components, external files, URLs |
| 118 | +- JSON Schema references |
| 119 | +- Path Item Objects |
| 120 | +- and others |
| 121 | + |
| 122 | +## Supported Versions |
| 123 | + |
| 124 | +| Spec | Versions | |
| 125 | +| ------- | ----------------- | |
| 126 | +| Arazzo | 1.0.0, 1.0.1 | |
| 127 | +| OpenAPI | 2.0, 3.0.x, 3.1.x | |
0 commit comments