Skip to content

Commit

Permalink
Register optional schema parsers (#247)
Browse files Browse the repository at this point in the history
* Register optional schema parsers

* Bump parser version
  • Loading branch information
fmvilas authored Mar 16, 2020
1 parent 67607ed commit 2cbb2d6
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 7 deletions.
15 changes: 14 additions & 1 deletion lib/generator.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand All @@ -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);
Expand Down
25 changes: 20 additions & 5 deletions package-lock.json

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

4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,10 @@
"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",
"asyncapi-parser": "^0.15.0",
"commander": "^2.12.2",
"filenamify": "^4.1.0",
"fs.extra": "^1.3.2",
Expand Down

0 comments on commit 2cbb2d6

Please sign in to comment.