@asyncapi/raml-dt-schema-parser
TypeScript icon, indicating that this package has built-in type declarations

4.0.22 • Public • Published

RAML Data Types Schema Parser

A schema parser for RAML data types.

Note Version >= 3.0.0 of package is only supported by @asyncapi/parser version >= 2.0.0.

Warning This package is not browser-compatible.

Installation

npm install @asyncapi/raml-dt-schema-parser
// OR
yarn add @asyncapi/raml-dt-schema-parser

Usage

import { Parser } from '@asyncapi/parser';
import { RamlDTSchemaParser } from '@asyncapi/raml-dt-schema-parser';

const parser = new Parser();
parser.registerSchemaParser(RamlDTSchemaParser()); 

const asyncapiWithRAML = `
asyncapi: 2.0.0
info:
  title: Example with RAML
  version: 0.1.0
channels:
  example:
    publish:
      message:
        schemaFormat: 'application/raml+yaml;version=1.0'
        payload: # The following is a RAML data type
          type: object
          properties:
            title: string
            author:
              type: string
              examples:
                anExample: Jack Johnson
`;

const { document } = await parser.parse(asyncapiWithRAML);
const { Parser } = require('@asyncapi/parser');
const { RamlDTSchemaParser } = require('@asyncapi/raml-dt-schema-parser');

const parser = new Parser();
parser.registerSchemaParser(RamlDTSchemaParser()); 

const asyncapiWithRAML = `
asyncapi: 2.0.0
info:
  title: Example with RAML
  version: 0.1.0
channels:
  example:
    publish:
      message:
        schemaFormat: 'application/raml+yaml;version=1.0'
        payload: # The following is a RAML data type
          type: object
          properties:
            title: string
            author:
              type: string
              examples:
                anExample: Jack Johnson
`;

const { document } = await parser.parse(asyncapiWithRAML);

It also supports referencing remote RAML data types:

import { Parser } from '@asyncapi/parser';
import { RamlDTSchemaParser } from '@asyncapi/raml-dt-schema-parser';

const parser = new Parser();
parser.registerSchemaParser(RamlDTSchemaParser()); 

const asyncapiWithRAML = `
asyncapi: 2.0.0
info:
  title: Example with RAML
  version: 0.1.0
channels:
  example:
    publish:
      message:
        schemaFormat: 'application/raml+yaml;version=1.0'
        payload:
          $ref: 'yourserver.com/data-types/library.raml#/Book'
`;

const { document } = await parser.parse(asyncapiWithRAML);

Package Sidebar

Install

npm i @asyncapi/raml-dt-schema-parser

Weekly Downloads

53,271

Version

4.0.22

License

Apache-2.0

Unpacked Size

22.2 kB

Total Files

7

Last publish

Collaborators

  • fmvilas
  • derberg
  • asyncapi-bot