Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@asyncapi/specs

Package Overview
Dependencies
Maintainers
3
Versions
120
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@asyncapi/specs - npm Package Compare versions

Comparing version 3.0.0-next-major.3 to 3.0.0-next-major.4

definitions/2.4.0/apiKey.json

6

definitions/2.3.0/components.json

@@ -14,2 +14,8 @@ {

},
"servers": {
"$ref": "http://asyncapi.com/definitions/2.3.0/servers.json"
},
"channels": {
"$ref": "http://asyncapi.com/definitions/2.3.0/channels.json"
},
"messages": {

@@ -16,0 +22,0 @@ "$ref": "http://asyncapi.com/definitions/2.3.0/messages.json"

3

index.js

@@ -10,3 +10,4 @@ module.exports = {

'2.2.0': require('./schemas/2.2.0.json'),
'2.3.0': require('./schemas/2.3.0.json')
'2.3.0': require('./schemas/2.3.0.json'),
'2.4.0': require('./schemas/2.4.0.json'),
};
# Migrating to version 3
In version 3, the only breaking change is that the provided bundled schemas located under [schemas](../schemas) now use completely different `$id`s and definition namings.
In version 3, we wanted to improve how you make changes to the JSON schema documents and improve maintainability. This was done through splitting the schemas into smaller files and then on release bundle them together to form what is called a Compound Schema Document.
> If you don't manually access schemas under `definitions`, you can upgrade the version without any problems.
To read more about bundling in JSON Schema, [we refer to the official documentation](https://json-schema.org/understanding-json-schema/structuring.html#bundling).
Previously, each definition would have it defined as:
## Change of `$id`s
Previously, each definition would be defined as:
```json

@@ -36,1 +38,45 @@ {

All definitions follow the same change from `<name>` to `http://asyncapi.com/definitions/<version>/<name>.json`.
## References
Because the `$id`s changes, so must the references and this might be a problem for some implementations if they do not follow JSON Schema behavior where they can auto map loaded schemas to references.
```json
{
...
"patternProperties": {
"^x-[\\w\\d\\.\\x2d_]+$": {
"$ref": "http://asyncapi.com/definitions/2.3.0/specificationExtension.json"
}
},
"definitions": {
"http://asyncapi.com/definitions/2.2.0/specificationExtension.json": { ... },
...
}
}
```
## Bundled schemas
Because the provided schemas are now bundled together some validation tools **might** find this a problem, for example [Ajv](#ajv-example).
### Ajv example
Because the AsyncAPI JSON Schema documents are written with a [specific meta schema](https://github.com/asyncapi/spec-json-schemas/blob/5d6ea0361a5b30707afa67a2df28e2805095c10f/schemas/2.3.0.json#L3). That meta schema, is already loaded by [Ajv](https://ajv.js.org), and when you try to load the bundled AsyncAPI JSON Schema, it now contains that same meta schema. Ajv does not like to load duplicate schemas and simply throw an error when you try to, and there are no way to tell it to ignore it. Therefore for Ajv you **must** remove it before using it.
Example code:
```js
const Ajv = require('ajv');
const asyncapi = require('@asyncapi/specs');
const ajv = new Ajv({
jsonPointers: true,
allErrors: true,
schemaId: 'auto',
logger: false
});
const asyncapiSchema = asyncapi['2.0.0'];
// Remove the meta schemas because it is already present within Ajv, and it's not possible to add duplicate schemas.
delete asyncapiSchema.definitions['http://json-schema.org/draft-07/schema'];
//delete asyncapiSchema.definitions['http://json-schema.org/draft-04/schema']; <-- This is needed if you use AsyncAPI > v2
ajv.addSchema(asyncapiSchema, version);
validate = ajv.getSchema(version);
const validAsyncAPI = validate(...);
```
[Here is how we migrated our JS parser](https://github.com/asyncapi/parser-js/pull/423).
{
"name": "@asyncapi/specs",
"version": "3.0.0-next-major.3",
"version": "3.0.0-next-major.4",
"description": "AsyncAPI schema versions",

@@ -59,2 +59,6 @@ "main": "index.js",

"prerelease": true
},
{
"name": "next-major-spec",
"prerelease": true
}

@@ -61,0 +65,0 @@ ],

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc