@asyncapi/specs
Advanced tools
Comparing version 6.3.0 to 6.4.0
@@ -74,11 +74,11 @@ { | ||
} | ||
}, | ||
"bindingVersion": { | ||
"type": "string", | ||
"enum": [ | ||
"0.2.0" | ||
], | ||
"description": "The version of this binding. If omitted, \"latest\" MUST be assumed." | ||
} | ||
}, | ||
"bindingVersion": { | ||
"type": "string", | ||
"enum": [ | ||
"0.2.0" | ||
], | ||
"description": "The version of this binding. If omitted, \"latest\" MUST be assumed." | ||
}, | ||
"examples": [ | ||
@@ -85,0 +85,0 @@ { |
@@ -82,11 +82,11 @@ { | ||
} | ||
}, | ||
"bindingVersion": { | ||
"type": "string", | ||
"enum": [ | ||
"0.3.0" | ||
], | ||
"description": "The version of this binding. If omitted, \"latest\" MUST be assumed." | ||
} | ||
}, | ||
"bindingVersion": { | ||
"type": "string", | ||
"enum": [ | ||
"0.3.0" | ||
], | ||
"description": "The version of this binding. If omitted, \"latest\" MUST be assumed." | ||
}, | ||
"examples": [ | ||
@@ -93,0 +93,0 @@ { |
@@ -292,3 +292,3 @@ { | ||
"bindingVersion": { | ||
"enum": ["0.3.0", "0.2.0"] | ||
"enum": ["0.4.0", "0.3.0", "0.2.0"] | ||
} | ||
@@ -307,3 +307,3 @@ }, | ||
"then": { | ||
"$ref": "http://asyncapi.com/bindings/solace/0.3.0/operation.json" | ||
"$ref": "http://asyncapi.com/bindings/solace/0.4.0/operation.json" | ||
} | ||
@@ -316,2 +316,15 @@ }, | ||
"bindingVersion": { | ||
"const": "0.4.0" | ||
} | ||
} | ||
}, | ||
"then": { | ||
"$ref": "http://asyncapi.com/bindings/solace/0.4.0/operation.json" | ||
} | ||
}, | ||
{ | ||
"if": { | ||
"required": [ "bindingVersion" ], | ||
"properties": { | ||
"bindingVersion": { | ||
"const": "0.3.0" | ||
@@ -318,0 +331,0 @@ } |
@@ -177,3 +177,3 @@ { | ||
"bindingVersion": { | ||
"enum": ["0.3.0", "0.2.0"] | ||
"enum": ["0.4.0", "0.3.0", "0.2.0"] | ||
} | ||
@@ -192,3 +192,3 @@ }, | ||
"then": { | ||
"$ref": "http://asyncapi.com/bindings/solace/0.3.0/server.json" | ||
"$ref": "http://asyncapi.com/bindings/solace/0.4.0/server.json" | ||
} | ||
@@ -201,2 +201,15 @@ }, | ||
"bindingVersion": { | ||
"const": "0.4.0" | ||
} | ||
} | ||
}, | ||
"then": { | ||
"$ref": "http://asyncapi.com/bindings/solace/0.4.0/server.json" | ||
} | ||
}, | ||
{ | ||
"if": { | ||
"required": [ "bindingVersion" ], | ||
"properties": { | ||
"bindingVersion": { | ||
"const": "0.3.0" | ||
@@ -203,0 +216,0 @@ } |
40
index.js
module.exports = { | ||
'schemas': { | ||
'2.0.0': require('./schemas/2.0.0.json'), | ||
'2.1.0': require('./schemas/2.1.0.json'), | ||
'2.2.0': require('./schemas/2.2.0.json'), | ||
'2.3.0': require('./schemas/2.3.0.json'), | ||
'2.4.0': require('./schemas/2.4.0.json'), | ||
'2.5.0': require('./schemas/2.5.0.json'), | ||
'2.6.0': require('./schemas/2.6.0.json'), | ||
'3.0.0': require('./schemas/3.0.0.json'), | ||
}, | ||
'schemasWithoutId': { | ||
'2.0.0': require('./schemas/2.0.0-without-$id.json'), | ||
'2.1.0': require('./schemas/2.1.0-without-$id.json'), | ||
'2.2.0': require('./schemas/2.2.0-without-$id.json'), | ||
'2.3.0': require('./schemas/2.3.0-without-$id.json'), | ||
'2.4.0': require('./schemas/2.4.0-without-$id.json'), | ||
'2.5.0': require('./schemas/2.5.0-without-$id.json'), | ||
'2.6.0': require('./schemas/2.6.0-without-$id.json'), | ||
'3.0.0': require('./schemas/3.0.0-without-$id.json'), | ||
} | ||
schemas: { | ||
'2.0.0': require('./schemas/2.0.0.json'), | ||
'2.1.0': require('./schemas/2.1.0.json'), | ||
'2.2.0': require('./schemas/2.2.0.json'), | ||
'2.3.0': require('./schemas/2.3.0.json'), | ||
'2.4.0': require('./schemas/2.4.0.json'), | ||
'2.5.0': require('./schemas/2.5.0.json'), | ||
'2.6.0': require('./schemas/2.6.0.json'), | ||
'3.0.0': require('./schemas/3.0.0.json'), | ||
}, | ||
schemasWithoutId: { | ||
'2.0.0': require('./schemas/2.0.0-without-$id.json'), | ||
'2.1.0': require('./schemas/2.1.0-without-$id.json'), | ||
'2.2.0': require('./schemas/2.2.0-without-$id.json'), | ||
'2.3.0': require('./schemas/2.3.0-without-$id.json'), | ||
'2.4.0': require('./schemas/2.4.0-without-$id.json'), | ||
'2.5.0': require('./schemas/2.5.0-without-$id.json'), | ||
'2.6.0': require('./schemas/2.6.0-without-$id.json'), | ||
'3.0.0': require('./schemas/3.0.0-without-$id.json'), | ||
} | ||
}; |
{ | ||
"name": "@asyncapi/specs", | ||
"version": "6.3.0", | ||
"version": "6.4.0", | ||
"description": "AsyncAPI schema versions", | ||
@@ -14,3 +14,4 @@ "main": "index.js", | ||
"startNewVersion": "newVersion=$npm_config_new_version node scripts/add-new-version.js", | ||
"lint": "echo 'No linter integrated yet'", | ||
"lint": "eslint --max-warnings 0 --config .eslintrc.yml .", | ||
"lint:fix": "eslint --max-warnings 0 --config .eslintrc.yml --fix .", | ||
"bump:version": "npm --no-git-tag-version --allow-same-version version $VERSION", | ||
@@ -45,2 +46,4 @@ "validate:schemas": "node scripts/validate-schemas.js" | ||
"conventional-changelog-conventionalcommits": "^5.0.0", | ||
"eslint": "^8.56.0", | ||
"eslint-plugin-sonarjs": "^0.23.0", | ||
"mocha": "^10.0.0", | ||
@@ -47,0 +50,0 @@ "nyc": "^15.1.0" |
@@ -19,3 +19,3 @@ const path = require('path'); | ||
return new Promise((resolve, reject) => { | ||
exec(command, function (error, stdout, stderr) { //NOSONAR | ||
exec(command, (error, stdout, stderr) => { //NOSONAR | ||
if (!error) resolve(stdout); | ||
@@ -46,7 +46,7 @@ console.error(stderr); | ||
// Adapt all the MUST supported schema formats | ||
let mustSupportedSchemaFormats = [] = obj?.else?.properties?.schemaFormat?.anyOf[1]?.enum; | ||
let mustSupportedSchemaFormats = obj && obj.else && obj.else.properties && obj.else.properties.schemaFormat && obj.else.properties.schemaFormat.anyOf && obj.else.properties.schemaFormat.anyOf[1] && obj.else.properties.schemaFormat.anyOf[1].enum ? obj.else.properties.schemaFormat.anyOf[1].enum : []; | ||
//Add new version to the list of available schemaFormat values | ||
if(mustSupportedSchemaFormats) { | ||
if(isMajorVersionChange) { | ||
if (mustSupportedSchemaFormats) { | ||
if (isMajorVersionChange) { | ||
//Remove all old AsyncAPI schema formats because we want a clean slate | ||
@@ -59,8 +59,9 @@ mustSupportedSchemaFormats = mustSupportedSchemaFormats.filter((format) => !format.includes('application/vnd.aai.asyncapi')); | ||
} else { | ||
throw new Error("Could not find object to add schemaFormat values to"); | ||
throw new Error('Could not find object to add schemaFormat values to'); | ||
} | ||
//Make sure new versions apply the right schema | ||
let enumsForValidatingSchema = [] = obj?.else?.allOf[1]?.if?.properties?.schemaFormat?.enum; | ||
if(enumsForValidatingSchema) { | ||
//Make sure new versions apply the right schema; | ||
const enumsForValidatingSchema = obj && obj.else && obj.else.allOf && obj.else.allOf[1] && obj.else.allOf[1].if && obj.else.allOf[1].if.properties && obj.else.allOf[1].if.properties.schemaFormat && obj.else.allOf[1].if.properties.schemaFormat.enum ? obj.else.allOf[1].if.properties.schemaFormat.enum : []; | ||
if (enumsForValidatingSchema) { | ||
//Add new schema formats | ||
@@ -70,3 +71,3 @@ enumsForValidatingSchema.push(...newSchemaFormats); | ||
} else { | ||
throw new Error("Could not find location for schemaFormats that applies the AsyncAPI Schema object to the schema property"); | ||
throw new Error('Could not find location for schemaFormats that applies the AsyncAPI Schema object to the schema property'); | ||
} | ||
@@ -94,5 +95,7 @@ | ||
fs.accessSync(newVersionDir); | ||
console.error(`Directory ${newVersionDir} already exist and cannot be overwritten. Please create a different version.`) | ||
console.error(`Directory ${newVersionDir} already exist and cannot be overwritten. Please create a different version.`); | ||
return process.exit(1); | ||
} catch (err) { } | ||
} catch (err) { | ||
console.error(`Error checking if directory ${newVersionDir} exist: ${err}`); | ||
} | ||
@@ -107,3 +110,3 @@ //Use the newest version as baseline for the new one | ||
// Replace $ref and $id paths such as `/3.0.0/` with new version (http://asyncapi.com/definitions/3.0.0/specificationExtension.json) | ||
await execute(`find ${newVersionDir} -name '*.json' -exec sed -i '' \"s+\/${latestVersion}\/+\/${newVersion}\/+g\" {} +`); | ||
await execute(`find ${newVersionDir} -name '*.json' -exec sed -i '' "s+/${latestVersion}/+/${newVersion}/+g" {} +`); | ||
@@ -117,3 +120,3 @@ // Replace .asyncapi version from old to new version | ||
console.log(`New version added to ${newVersionDir}`) | ||
console.log(`New version added to ${newVersionDir}`); | ||
} | ||
@@ -123,3 +126,3 @@ | ||
if (!versionMatch) { | ||
console.error(`The new version ${inputNewVersion} must use semver versioning. `) | ||
console.error(`The new version ${inputNewVersion} must use semver versioning. `); | ||
process.exit(1); | ||
@@ -126,0 +129,0 @@ } else { |
@@ -12,4 +12,4 @@ const fs = require('fs'); | ||
const validate = schemaValidator(obj); | ||
const errors = validate ? [] : (obj.$schema === 'http://json-schema.org/draft-04/schema' ? ajvDraft04.errors : ajv.errors); | ||
const errors = validate ? [] : (obj.$schema === 'http://json-schema.org/draft-04/schema' && ajvDraft04.errors) || ajv.errors; | ||
return { filePath, validate, errors }; | ||
@@ -16,0 +16,0 @@ } catch (error) { |
Sorry, the diff of this file is too big to display
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
3459181
731
98321
7