Skip to content

Commit

Permalink
bump deps
Browse files Browse the repository at this point in the history
  • Loading branch information
magicmatatjahu committed Oct 25, 2022
1 parent 4a36894 commit 491bf50
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 19 deletions.
32 changes: 31 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ yarn add @asyncapi/raml-dt-schema-parser

## Usage

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

Expand Down Expand Up @@ -57,6 +57,36 @@ channels:
const { document } = await parser.parse(asyncapiWithRAML);
```

```js
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:

```js
Expand Down
17 changes: 7 additions & 10 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,10 @@
"schema",
"parser"
],
"author": "Fran Mendez (fmvilas.com)",
"author": {
"name": "The AsyncAPI maintainers",
"url": "https://www.asyncapi.com"
},
"publishConfig": {
"access": "public"
},
Expand All @@ -46,10 +49,7 @@
"README.md"
],
"dependencies": {
"@asyncapi/parser": "^2.0.0-next-major.6",
"ajv": "^8.11.0",
"ajv-errors": "^3.0.0",
"ajv-formats": "^2.1.1",
"@asyncapi/parser": "^2.0.0-next-major.7",
"js-yaml": "^4.1.0",
"ramldt2jsonschema": "^1.2.3",
"webapi-parser": "^0.5.0"
Expand Down
5 changes: 2 additions & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ const wap = lib.WebApiParser;
const r2j = require('ramldt2jsonschema');
/* eslint-enable */

import type { SchemaParser, ParseSchemaInput, ValidateSchemaInput, SchemaValidateResult } from '@asyncapi/parser';
import type { v2 } from '@asyncapi/parser/esm/spec-types';
import type { SchemaParser, ParseSchemaInput, ValidateSchemaInput, SchemaValidateResult, SpecTypesV2 } from '@asyncapi/parser';

export function RamlDTSchemaParser(): SchemaParser {
return {
Expand Down Expand Up @@ -39,7 +38,7 @@ async function validate(input: ValidateSchemaInput<unknown, unknown>): Promise<S
return validateResult;
}

async function parse(input: ParseSchemaInput<unknown, unknown>): Promise<v2.SchemaObject> {
async function parse(input: ParseSchemaInput<unknown, unknown>): Promise<SpecTypesV2.SchemaObject> {
const payload = formatPayload(input.data);

// Draft 6 is compatible with 7.
Expand Down

0 comments on commit 491bf50

Please sign in to comment.