Package Exports
- @asyncapi/parser
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@asyncapi/parser) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
JS Parser
Parse and validate AsyncAPI documents
📢 ATTENTION:
This package is under development and it has not reached version 1.0.0 yet, what means its API might change without prior notice. Once it reaches its first stable version, we'll follow semantic versioning.
Use this package to parse and validate AsyncAPI documents —either YAML or JSON— in your Node.js or browser application. Updated bundle for the browser is always attached to the GitHub Release.
This package doesn't support AsyncAPI 1.x.
Install
npm install @asyncapi/parserAPI
Examples
Example passing inline AsyncAPI
const parser = require('@asyncapi/parser');
const doc = await parser.parse(`
asyncapi: '2.0.0'
info:
title: Example
version: '0.1.0'
channels:
example-channel:
subscribe:
message:
payload:
type: object
properties:
exampleField:
type: string
exampleNumber:
type: number
exampleDate:
type: string
format: date-time
`);
console.log(doc.info().title());
// => ExampleExample passing a URL
const parser = require('@asyncapi/parser');
const doc = await parser.parseUrl('https://my.server.com/example-asyncapi.yaml');
console.log(doc.info().title());
// => ExampleExample using OpenAPI schemas
Head over to asyncapi/openapi-schema-parser for more information.
Example using RAML data types
Head over to asyncapi/raml-dt-schema-parser for more information.
Develop
- Run tests with
npm test - Write code and tests.
- Make sure all tests pass
npm test - Generate new API docs
npm run docs - Update bundle for client-side parser
npm run bundle
Contributing
Read CONTRIBUTING guide.