From 7364b2dd602f4f2a9367d8a8653b621b9fef4326 Mon Sep 17 00:00:00 2001 From: Jonas Lagoni Date: Mon, 2 May 2022 22:57:04 +0200 Subject: [PATCH] feat(rulesets): support AsyncAPI 2.4 (#2146) --- packages/rulesets/package.json | 6 +++--- .../functions/asyncApi2DocumentSchema.ts | 5 ++++- packages/rulesets/src/asyncapi/index.ts | 4 ++-- yarn.lock | 18 +++++++++--------- 4 files changed, 18 insertions(+), 15 deletions(-) diff --git a/packages/rulesets/package.json b/packages/rulesets/package.json index 140829a88..19917e39f 100644 --- a/packages/rulesets/package.json +++ b/packages/rulesets/package.json @@ -21,14 +21,14 @@ "release": "semantic-release -e semantic-release-monorepo" }, "dependencies": { - "@asyncapi/specs": "^2.13.0", + "@asyncapi/specs": "^2.14.0", "@stoplight/better-ajv-errors": "1.0.1", "@stoplight/json": "^3.17.0", "@stoplight/spectral-core": "^1.8.1", - "@stoplight/spectral-formats": "^1.1.0", + "@stoplight/spectral-formats": "^1.2.0", "@stoplight/spectral-functions": "^1.5.1", "@stoplight/spectral-runtime": "^1.1.1", - "@stoplight/types": "^12.3.0", + "@stoplight/types": "^12.5.0", "@types/json-schema": "^7.0.7", "ajv": "^8.8.2", "ajv-formats": "~2.1.0", diff --git a/packages/rulesets/src/asyncapi/functions/asyncApi2DocumentSchema.ts b/packages/rulesets/src/asyncapi/functions/asyncApi2DocumentSchema.ts index dceae2ed7..c32d1fd12 100644 --- a/packages/rulesets/src/asyncapi/functions/asyncApi2DocumentSchema.ts +++ b/packages/rulesets/src/asyncapi/functions/asyncApi2DocumentSchema.ts @@ -1,6 +1,6 @@ import { createRulesetFunction } from '@stoplight/spectral-core'; import { schema as schemaFn } from '@stoplight/spectral-functions'; -import { aas2_0, aas2_1, aas2_2, aas2_3 } from '@stoplight/spectral-formats'; +import { aas2_0, aas2_1, aas2_2, aas2_3, aas2_4 } from '@stoplight/spectral-formats'; import type { ErrorObject } from 'ajv'; import type { IFunctionResult, Format } from '@stoplight/spectral-core'; @@ -10,6 +10,7 @@ import * as asyncAPI2_0_0Schema from '@asyncapi/specs/schemas/2.0.0.json'; import * as asyncAPI2_1_0Schema from '@asyncapi/specs/schemas/2.1.0.json'; import * as asyncAPI2_2_0Schema from '@asyncapi/specs/schemas/2.2.0.json'; import * as asyncAPI2_3_0Schema from '@asyncapi/specs/schemas/2.3.0.json'; +import * as asyncAPI2_4_0Schema from '@asyncapi/specs/schemas/2.4.0.json'; function shouldIgnoreError(error: ErrorObject): boolean { return ( @@ -81,6 +82,8 @@ function getSchema(formats: Set): Record | void { return asyncAPI2_2_0Schema; case formats.has(aas2_3): return asyncAPI2_3_0Schema; + case formats.has(aas2_4): + return asyncAPI2_4_0Schema; default: return; } diff --git a/packages/rulesets/src/asyncapi/index.ts b/packages/rulesets/src/asyncapi/index.ts index 434240a9a..c36d3ed13 100644 --- a/packages/rulesets/src/asyncapi/index.ts +++ b/packages/rulesets/src/asyncapi/index.ts @@ -1,4 +1,4 @@ -import { aas2_0, aas2_1, aas2_2, aas2_3 } from '@stoplight/spectral-formats'; +import { aas2_0, aas2_1, aas2_2, aas2_3, aas2_4 } from '@stoplight/spectral-formats'; import { truthy, pattern, @@ -14,7 +14,7 @@ import asyncApi2PayloadValidation from './functions/asyncApi2PayloadValidation'; export default { documentationUrl: 'https://meta.stoplight.io/docs/spectral/docs/reference/asyncapi-rules.md', - formats: [aas2_0, aas2_1, aas2_2, aas2_3], + formats: [aas2_0, aas2_1, aas2_2, aas2_3, aas2_4], rules: { 'asyncapi-channel-no-empty-parameter': { description: 'Channel path must not have empty parameter substitution pattern.', diff --git a/yarn.lock b/yarn.lock index c222a3281..87c74c58d 100644 --- a/yarn.lock +++ b/yarn.lock @@ -17,10 +17,10 @@ __metadata: languageName: node linkType: hard -"@asyncapi/specs@npm:^2.13.0": - version: 2.13.0 - resolution: "@asyncapi/specs@npm:2.13.0" - checksum: 94355c96ac2562bfd9118a3e33dd36359196d070684da952f6b0f800b588b426d012fbf96f85b7341ec74f401e3487934b92e43f48e086fa956eab29b90ab694 +"@asyncapi/specs@npm:^2.14.0": + version: 2.14.0 + resolution: "@asyncapi/specs@npm:2.14.0" + checksum: 066c23c493df54c44c319433bdcf8482a3acd584e32c0073e6a9f5b167d61bde23a252621be2b28bbaf1466636f6cafaab570795de403f0c671358784d4b12ed languageName: node linkType: hard @@ -2411,7 +2411,7 @@ __metadata: languageName: unknown linkType: soft -"@stoplight/spectral-formats@*, @stoplight/spectral-formats@>=1, @stoplight/spectral-formats@^1.0.0, @stoplight/spectral-formats@^1.1.0, @stoplight/spectral-formats@workspace:packages/formats": +"@stoplight/spectral-formats@*, @stoplight/spectral-formats@>=1, @stoplight/spectral-formats@^1.0.0, @stoplight/spectral-formats@^1.2.0, @stoplight/spectral-formats@workspace:packages/formats": version: 0.0.0-use.local resolution: "@stoplight/spectral-formats@workspace:packages/formats" dependencies: @@ -2523,17 +2523,17 @@ __metadata: version: 0.0.0-use.local resolution: "@stoplight/spectral-rulesets@workspace:packages/rulesets" dependencies: - "@asyncapi/specs": ^2.13.0 + "@asyncapi/specs": ^2.14.0 "@stoplight/better-ajv-errors": 1.0.1 "@stoplight/json": ^3.17.0 "@stoplight/path": ^1.3.2 "@stoplight/spectral-core": ^1.8.1 - "@stoplight/spectral-formats": ^1.1.0 + "@stoplight/spectral-formats": ^1.2.0 "@stoplight/spectral-functions": ^1.5.1 "@stoplight/spectral-parsers": "*" "@stoplight/spectral-ref-resolver": "*" "@stoplight/spectral-runtime": ^1.1.1 - "@stoplight/types": ^12.3.0 + "@stoplight/types": ^12.5.0 "@types/json-schema": ^7.0.7 ajv: ^8.8.2 ajv-formats: ~2.1.0 @@ -2578,7 +2578,7 @@ __metadata: languageName: node linkType: hard -"@stoplight/types@npm:^12.0.0, @stoplight/types@npm:^12.3.0": +"@stoplight/types@npm:^12.0.0, @stoplight/types@npm:^12.3.0, @stoplight/types@npm:^12.5.0": version: 12.5.0 resolution: "@stoplight/types@npm:12.5.0" dependencies: