@asyncapi/parser
Advanced tools
Comparing version 1.6.0-2021-06-release.1 to 1.6.0-2021-06-release.2
@@ -46,4 +46,7 @@ const Ajv = require('ajv'); | ||
'application/vnd.aai.asyncapi;version=2.0.0', | ||
'application/vnd.aai.asyncapi;version=2.1.0', | ||
'application/vnd.aai.asyncapi+json;version=2.0.0', | ||
'application/vnd.aai.asyncapi+json;version=2.1.0', | ||
'application/vnd.aai.asyncapi+yaml;version=2.0.0', | ||
'application/vnd.aai.asyncapi+yaml;version=2.1.0', | ||
'application/schema;version=draft-07', | ||
@@ -50,0 +53,0 @@ 'application/schema+json;version=draft-07', |
@@ -55,3 +55,3 @@ const { getMapValueOfType, mix } = require('./utils'); | ||
schemaFormat() { | ||
return 'application/schema+json;version=draft-07'; | ||
return this._json.schemaFormat; | ||
} | ||
@@ -58,0 +58,0 @@ |
@@ -9,6 +9,5 @@ const path = require('path'); | ||
const { validateChannels, validateServerVariables, validateOperationId, validateServerSecurity } = require('./customValidators.js'); | ||
const { toJS, findRefs, getLocationOf, improveAjvErrors } = require('./utils'); | ||
const { toJS, findRefs, getLocationOf, improveAjvErrors, getDefaultSchemaFormat } = require('./utils'); | ||
const AsyncAPIDocument = require('./models/asyncapi'); | ||
const DEFAULT_SCHEMA_FORMAT = 'application/vnd.aai.asyncapi;version=2.0.0'; | ||
const OPERATIONS = ['publish', 'subscribe']; | ||
@@ -191,9 +190,9 @@ //the only security types that can have a non empty array in the server security item | ||
if (xParserMessageParsed in msg && msg[String(xParserMessageParsed)] === true) return; | ||
const defaultSchemaFormat = getDefaultSchemaFormat(parsedAsyncAPIDocument.asyncapi); | ||
const schemaFormat = msg.schemaFormat || defaultSchemaFormat; | ||
const schemaFormat = msg.schemaFormat || DEFAULT_SCHEMA_FORMAT; | ||
await PARSERS[String(schemaFormat)]({ | ||
schemaFormat, | ||
message: msg, | ||
defaultSchemaFormat: DEFAULT_SCHEMA_FORMAT, | ||
defaultSchemaFormat, | ||
originalAsyncAPIDocument, | ||
@@ -205,3 +204,3 @@ parsedAsyncAPIDocument, | ||
msg.schemaFormat = DEFAULT_SCHEMA_FORMAT; | ||
msg.schemaFormat = defaultSchemaFormat; | ||
msg[String(xParserMessageParsed)] = true; | ||
@@ -208,0 +207,0 @@ } |
@@ -287,1 +287,12 @@ const YAML = require('js-yaml'); | ||
}; | ||
/** | ||
* returns default schema format for a given asyncapi version | ||
* | ||
* @function getDefaultSchemaFormat | ||
* @private | ||
* @param {String} asyncapiVersion AsyncAPI spec version. | ||
*/ | ||
utils.getDefaultSchemaFormat = (asyncapiVersion) => { | ||
return `application/vnd.aai.asyncapi;version=${asyncapiVersion}`; | ||
}; |
{ | ||
"name": "@asyncapi/parser", | ||
"version": "1.6.0-2021-06-release.1", | ||
"version": "1.6.0-2021-06-release.2", | ||
"description": "JavaScript AsyncAPI parser.", | ||
@@ -71,3 +71,3 @@ "main": "lib/index.js", | ||
"@apidevtools/json-schema-ref-parser": "^9.0.6", | ||
"@asyncapi/specs": "2.8.0-2021-06-release.3", | ||
"@asyncapi/specs": "2.8.0-2021-06-release.5", | ||
"@fmvilas/pseudo-yaml-ast": "^0.3.1", | ||
@@ -74,0 +74,0 @@ "ajv": "^6.10.1", |
@@ -52,3 +52,3 @@ <h5 align="center"> | ||
const doc = await parser.parse(` | ||
asyncapi: '2.0.0' | ||
asyncapi: '2.1.0' | ||
info: | ||
@@ -55,0 +55,0 @@ title: Example |
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1170068
7199
+ Added@asyncapi/specs@2.8.0-2021-06-release.5(transitive)
- Removed@asyncapi/specs@2.8.0-2021-06-release.3(transitive)