From 09446e02e5e9230c4f52e42f6797814b5d1069ab Mon Sep 17 00:00:00 2001 From: fmvilas Date: Wed, 11 Mar 2020 18:35:07 +0100 Subject: [PATCH 1/2] Register optional schema parsers --- lib/generator.js | 15 ++++++++++++++- package-lock.json | 17 +++++++++++++++++ package.json | 2 ++ 3 files changed, 33 insertions(+), 1 deletion(-) diff --git a/lib/generator.js b/lib/generator.js index 92d81751e..89cd2dca5 100644 --- a/lib/generator.js +++ b/lib/generator.js @@ -4,7 +4,10 @@ const util = require('util'); const xfs = require('fs.extra'); const walkSync = require('klaw-sync'); const minimatch = require('minimatch'); -const { parse, AsyncAPIDocument } = require('asyncapi-parser'); +const parser = require('asyncapi-parser'); +const { parse, AsyncAPIDocument } = parser; +const ramlDtParser = require('@asyncapi/raml-dt-schema-parser'); +const openapiSchemaParser = require('@asyncapi/openapi-schema-parser'); const Nunjucks = require('nunjucks'); const jmespath = require('jmespath'); const Ajv = require('ajv'); @@ -14,6 +17,16 @@ const npmi = require('npmi'); const ajv = new Ajv({ allErrors: true }); +parser.registerSchemaParser([ + 'application/vnd.oai.openapi;version=3.0.0', + 'application/vnd.oai.openapi+json;version=3.0.0', + 'application/vnd.oai.openapi+yaml;version=3.0.0', +], openapiSchemaParser); + +parser.registerSchemaParser([ + 'application/raml+yaml;version=1.0', +], ramlDtParser); + const readFile = util.promisify(fs.readFile); const writeFile = util.promisify(fs.writeFile); const copyFile = util.promisify(fs.copyFile); diff --git a/package-lock.json b/package-lock.json index ad96d8afd..4233b79f7 100644 --- a/package-lock.json +++ b/package-lock.json @@ -4,6 +4,23 @@ "lockfileVersion": 1, "requires": true, "dependencies": { + "@asyncapi/openapi-schema-parser": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/@asyncapi/openapi-schema-parser/-/openapi-schema-parser-1.0.0.tgz", + "integrity": "sha512-zvE58V0nBjpb4E+IC1i7mjUAUF0u58fGL9/c+/wAgT/AuCPO5C8kGzIJDYb04ck17isFlHZ4xg74c6qvKnLUKw==", + "requires": { + "@openapi-contrib/openapi-schema-to-json-schema": "^3.0.0" + } + }, + "@asyncapi/raml-dt-schema-parser": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/@asyncapi/raml-dt-schema-parser/-/raml-dt-schema-parser-1.0.4.tgz", + "integrity": "sha512-1JQxr2LISzMevMcrerHhnv973W/skWZ8MfAaG8NoUmuFUIvH8rDVD9yCppLikBUaygJ360JcDjIujn5+BufF9Q==", + "requires": { + "js-yaml": "^3.13.1", + "ramldt2jsonschema": "^1.1.0" + } + }, "@babel/parser": { "version": "7.8.6", "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.8.6.tgz", diff --git a/package.json b/package.json index dbba945d9..9db518d00 100644 --- a/package.json +++ b/package.json @@ -31,6 +31,8 @@ "license": "Apache-2.0", "homepage": "https://github.com/asyncapi/generator", "dependencies": { + "@asyncapi/openapi-schema-parser": "^1.0.0", + "@asyncapi/raml-dt-schema-parser": "^1.0.4", "ajv": "^6.10.2", "asyncapi-parser": "^0.14.0", "commander": "^2.12.2", From 01b79f23ea98200b953cbeaeb78db5cb7cfe1612 Mon Sep 17 00:00:00 2001 From: fmvilas Date: Mon, 16 Mar 2020 12:57:33 +0100 Subject: [PATCH 2/2] Bump parser version --- package-lock.json | 8 +++----- package.json | 2 +- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/package-lock.json b/package-lock.json index 4233b79f7..8b6d3a9a5 100644 --- a/package-lock.json +++ b/package-lock.json @@ -150,17 +150,15 @@ "integrity": "sha512-ROszLQMYzyp/CzPyLhuT/9NpJXxI7wrjv6yW8JpA/XVMEWCqyVXr9jajJhs9d/863+ispS+ptGhg1PC17AnIzQ==" }, "asyncapi-parser": { - "version": "0.14.0", - "resolved": "https://registry.npmjs.org/asyncapi-parser/-/asyncapi-parser-0.14.0.tgz", - "integrity": "sha512-FR7Cx4DyBS3SP2hd1KJ1uFgMVbIES/cRIYq4teqUcogmd0La5mV6T21iLhCwPGWbWJUcR8KrvQyNOY9yNLPaEw==", + "version": "0.15.0", + "resolved": "https://registry.npmjs.org/asyncapi-parser/-/asyncapi-parser-0.15.0.tgz", + "integrity": "sha512-K8P8ELZGBCtETvsx3QyBPHhF1DOSeL40EDcdXW9DtgX9BCD2H5PTCBEhOvNZO78mBx+TXEPSY0QF7rBlzteicg==", "requires": { - "@openapi-contrib/openapi-schema-to-json-schema": "^3.0.0", "ajv": "^6.10.1", "asyncapi": "^2.6.1", "js-yaml": "^3.13.1", "json-schema-ref-parser": "^7.1.0", "node-fetch": "^2.6.0", - "ramldt2jsonschema": "^1.1.0", "tiny-merge-patch": "^0.1.2" } }, diff --git a/package.json b/package.json index 9db518d00..8c9e206ba 100644 --- a/package.json +++ b/package.json @@ -34,7 +34,7 @@ "@asyncapi/openapi-schema-parser": "^1.0.0", "@asyncapi/raml-dt-schema-parser": "^1.0.4", "ajv": "^6.10.2", - "asyncapi-parser": "^0.14.0", + "asyncapi-parser": "^0.15.0", "commander": "^2.12.2", "filenamify": "^4.1.0", "fs.extra": "^1.3.2",