# @swagger-api/apidom-parser-adapter-asyncapi-yaml-2

> Parser adapter for parsing YAML documents into AsyncAPI 2.x.y namespace.

Latest version **1.14.0** (published 2026-11-04) · Apache-2.0 license · 0 weekly downloads

## Install

```sh
npm install @swagger-api/apidom-parser-adapter-asyncapi-yaml-2
pnpm add @swagger-api/apidom-parser-adapter-asyncapi-yaml-2
yarn add @swagger-api/apidom-parser-adapter-asyncapi-yaml-2
bun add @swagger-api/apidom-parser-adapter-asyncapi-yaml-2
```

## Health

**Score 55/100 (C)** — status: active.

Positive: no vulnerabilities; recently updated; high maintenance score.

Warnings: low downloads; no types; no esm support.

## Facts

| | |
|---|---|
| Version | 1.14.0 |
| Published | 2026-11-04 |
| First published | 2023-02-28 |
| Weekly downloads | 0 |
| License | Apache-2.0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 101 |
| Author | Vladimir Gorej |
| Maintainers | swagger-api |

## Links

- npm: https://www.npmjs.com/package/@swagger-api/apidom-parser-adapter-asyncapi-yaml-2
- Repository: https://github.com/swagger-api/apidom
- Homepage: https://github.com/swagger-api/apidom#readme
- Issues: https://github.com/swagger-api/apidom/issues
- npm.io page: https://npm.io/package/@swagger-api/apidom-parser-adapter-asyncapi-yaml-2

## Recent versions

- 1.14.0 (latest) — 2026-11-04
- 1.11.6 (v1.11-maintenance) — 2026-09-16
- 1.13.3 — 2026-10-21
- 1.13.1 — 2026-10-21
- 1.11.5 — 2026-09-16
- 1.11.4 — 2026-09-15
- 1.12.1 — 2026-09-04
- 1.12.0 — 2026-08-03
- 1.11.3 — 2026-06-22
- 1.11.2 — 2026-06-02
- 1.11.1 — 2026-05-12
- 1.11.0 — 2026-04-27
- 1.10.2 — 2026-04-13
- 1.10.1 — 2026-04-07
- 1.10.0 — 2026-04-01
- … 124 more at https://npm.io/package/@swagger-api/apidom-parser-adapter-asyncapi-yaml-2/versions

## README

# @swagger-api/apidom-parser-adapter-asyncapi-yaml-2

`@swagger-api/apidom-parser-adapter-asyncapi-yaml-2` is a parser adapter for following AsyncAPI specification versions defined in [YAML format](https://yaml.org/spec/1.2/spec.html):

- [AsyncAPI 2.6.0 specification](https://github.com/asyncapi/spec/blob/v2.6.0/spec/asyncapi.md)
- [AsyncAPI 2.5.0 specification](https://github.com/asyncapi/spec/blob/v2.5.0/spec/asyncapi.md)
- [AsyncAPI 2.4.0 specification](https://github.com/asyncapi/spec/blob/v2.4.0/spec/asyncapi.md)
- [AsyncAPI 2.3.0 specification](https://github.com/asyncapi/spec/blob/v2.3.0/spec/asyncapi.md)
- [AsyncAPI 2.2.0 specification](https://github.com/asyncapi/spec/blob/v2.2.0/spec/asyncapi.md)
- [AsyncAPI 2.1.0 specification](https://github.com/asyncapi/spec/blob/v2.1.0/spec/asyncapi.md)
- [AsyncAPI 2.0.0 specification](https://github.com/asyncapi/spec/blob/2.0.0/versions/2.0.0/asyncapi.md)

Under the hood this adapter uses [@swagger-api/apidom-parser-adapter-yaml-1-2](https://github.com/swagger-api/apidom/tree/main/packages/apidom-parser-adapter-yaml-1-2)
to parse a source string into generic ApiDOM in [base ApiDOM namespace](https://github.com/swagger-api/apidom/tree/main/packages/apidom-core#base-namespace)
which is then refracted with [AsyncApi 2.x.y Refractors](https://github.com/swagger-api/apidom/tree/main/packages/apidom-ns-asyncapi-2#refractors).

## Installation

After [prerequisites](https://github.com/swagger-api/apidom/blob/main/README.md#prerequisites) for installing this package are satisfied, you can install it
via [npm CLI](https://docs.npmjs.com/cli) by running the following command:

```sh
 $ npm install @swagger-api/@swagger-api/apidom-parser-adapter-asyncapi-yaml-2
```

## Parser adapter API

This parser adapter is fully compatible with parser adapter interface required by [@swagger-api/apidom-parser](https://github.com/swagger-api/apidom/tree/main/packages/apidom-parser#mounting-parser-adapters)
and implements all required properties.

### mediaTypes

Defines list of media types that this parser adapter recognizes.

```js
[
  'application/vnd.aai.asyncapi;version=2.0.0',
  'application/vnd.aai.asyncapi;version=2.1.0',
  'application/vnd.aai.asyncapi;version=2.2.0',
  'application/vnd.aai.asyncapi;version=2.3.0',
  'application/vnd.aai.asyncapi;version=2.4.0',
  'application/vnd.aai.asyncapi;version=2.5.0',
  'application/vnd.aai.asyncapi;version=2.6.0',
  'application/vnd.aai.asyncapi+yaml;version=2.0.0',
  'application/vnd.aai.asyncapi+yaml;version=2.1.0',
  'application/vnd.aai.asyncapi+yaml;version=2.2.0',
  'application/vnd.aai.asyncapi+yaml;version=2.3.0',
  'application/vnd.aai.asyncapi+yaml;version=2.4.0',
  'application/vnd.aai.asyncapi+yaml;version=2.5.0',
  'application/vnd.aai.asyncapi+yaml;version=2.6.0',
]
```

### detect

[Detection](https://github.com/swagger-api/apidom/blob/main/packages/apidom-parser-adapter-asyncapi-yaml-2/src/adapter.ts#L21) is based on a regular expression matching required AsyncApi 2.x.y specification symbols in YAML format.

### namespace

This adapter exposes an instance of [AsyncApi 2.x.y ApiDOM namespace](https://github.com/swagger-api/apidom/tree/main/packages/apidom-ns-asyncapi-2#asyncapi-2xy-namespace).

### parse

`parse` function consumes various options as a second argument. Here is a list of these options:

Option | Type | Default | Description
--- | --- | --- | ---
<a name="specObj"></a>`specObj` | `Object` | [Specification Object](https://github.com/swagger-api/apidom/blob/main/packages/apidom-ns-asyncapi-2/src/refractor/specification.ts) | This specification object drives the YAML AST transformation to AsyncAPI 2.x ApiDOM namespace.
<a name="sourceMap"></a>`sourceMap` | `Boolean` | `false` | Indicate whether to generate source maps.
<a name="refractorOpts"></a>`refractorOpts` | `Object` | `{}` | Refractor options are [passed to refractors](https://github.com/swagger-api/apidom/tree/main/packages/apidom-ns-asyncapi-2#refractor-plugins) during refracting phase.

All unrecognized arbitrary options will be ignored.

## Usage

This parser adapter can be used directly or indirectly via [@swagger-api/apidom-parser](https://github.com/swagger-api/apidom/tree/main/packages/apidom-parser).

### Direct usage

During direct usage you don't need to provide `mediaType` as the `parse` function is already pre-bound
with [supported media types](#mediatypes).

```js
import { parse, detect } from '@swagger-api/apidom-parser-adapter-asyncapi-yaml-2';

// detecting
await detect('asyncapi: 2.0.0'); // => true
await detect('asyncapi: 2.1.0'); // => true
await detect('asyncapi: 2.2.0'); // => true
await detect('asyncapi: 2.3.0'); // => true
await detect('asyncapi: 2.4.0'); // => true
await detect('asyncapi: 2.5.0'); // => true
await detect('asyncapi: 2.6.0'); // => true
await detect('test'); // => false

// parsing
const parseResult = await parse('asyncapi: 2.6.0', { sourceMap: true });
```

### Indirect usage

You can omit the `mediaType` option here, but please read [Word on detect vs mediaTypes](https://github.com/swagger-api/apidom/tree/main/packages/apidom-parser#word-on-detect-vs-mediatypes) before you do so.

```js
import ApiDOMParser from '@swagger-api/apidom-parser';
import * as asyncApiYamlAdapter from '@swagger-api/apidom-parser-adapter-asyncapi-yaml-2';

const parser = new ApiDOMParser();

parser.use(asyncApiYamlAdapter);

const parseResult = await parser.parse('asyncapi: 2.6.0', { mediaType: asyncApiYamlAdapter.mediaTypes.latest('yaml') });
```

---
_Source: https://npm.io/package/@swagger-api/apidom-parser-adapter-asyncapi-yaml-2 · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
