diff --git a/docs/guides/4-custom-rulesets.md b/docs/guides/4-custom-rulesets.md index d68a6fb21..1fd70f995 100644 --- a/docs/guides/4-custom-rulesets.md +++ b/docs/guides/4-custom-rulesets.md @@ -29,6 +29,7 @@ Formats are an optional way to specify which API description formats a rule, or - `aas2_3` (AsyncAPI v2.3.0) - `aas2_4` (AsyncAPI v2.4.0) - `aas2_5` (AsyncAPI v2.5.0) +- `aas2_6` (AsyncAPI v2.6.0) - `oas2` (OpenAPI v2.0) - `oas3` (OpenAPI v3.x) - `oas3_0` (OpenAPI v3.0.x) diff --git a/packages/formats/src/__tests__/asyncapi.test.ts b/packages/formats/src/__tests__/asyncapi.test.ts index 1695b2f24..1b350cf9b 100644 --- a/packages/formats/src/__tests__/asyncapi.test.ts +++ b/packages/formats/src/__tests__/asyncapi.test.ts @@ -1,4 +1,4 @@ -import { aas2, aas2_0, aas2_1, aas2_2, aas2_3, aas2_4, aas2_5 } from '../asyncapi'; +import { aas2, aas2_0, aas2_1, aas2_2, aas2_3, aas2_4, aas2_5, aas2_6 } from '../asyncapi'; describe('AsyncAPI format', () => { describe('AsyncAPI 2.x', () => { @@ -101,4 +101,28 @@ describe('AsyncAPI format', () => { }, ); }); + + describe('AsyncAPI 2.6', () => { + it.each(['2.6.0', '2.6.2'])('recognizes %s version correctly', version => { + expect(aas2_6({ asyncapi: version }, null)).toBe(true); + }); + + it.each([ + '2', + '2.3', + '2.0.0', + '2.1.0', + '2.1.37', + '2.2.0', + '2.3.0', + '2.4.0', + '2.4.3', + '2.5.0', + '2.5.4', + '2.7.0', + '2.7.4', + ])('does not recognize %s version', version => { + expect(aas2_6({ asyncapi: version }, null)).toBe(false); + }); + }); }); diff --git a/packages/formats/src/asyncapi.ts b/packages/formats/src/asyncapi.ts index 81ab204dc..a47b629a4 100644 --- a/packages/formats/src/asyncapi.ts +++ b/packages/formats/src/asyncapi.ts @@ -10,6 +10,7 @@ const aas2_2Regex = /^2\.2(?:\.[0-9]*)?$/; const aas2_3Regex = /^2\.3(?:\.[0-9]*)?$/; const aas2_4Regex = /^2\.4(?:\.[0-9]*)?$/; const aas2_5Regex = /^2\.5(?:\.[0-9]*)?$/; +const aas2_6Regex = /^2\.6(?:\.[0-9]*)?$/; const isAas2 = (document: unknown): document is { asyncapi: string } & Record => isPlainObject(document) && 'asyncapi' in document && aas2Regex.test(String((document as MaybeAAS2).asyncapi)); @@ -44,3 +45,7 @@ aas2_4.displayName = 'AsyncAPI 2.4.x'; export const aas2_5: Format = (document: unknown): boolean => isAas2(document) && aas2_5Regex.test(String((document as MaybeAAS2).asyncapi)); aas2_5.displayName = 'AsyncAPI 2.5.x'; + +export const aas2_6: Format = (document: unknown): boolean => + isAas2(document) && aas2_6Regex.test(String((document as MaybeAAS2).asyncapi)); +aas2_6.displayName = 'AsyncAPI 2.6.x'; diff --git a/yarn.lock b/yarn.lock index ae19b3b33..913c437f8 100644 --- a/yarn.lock +++ b/yarn.lock @@ -28,9 +28,9 @@ __metadata: linkType: hard "@asyncapi/specs@npm:^3.2.0": - version: 3.2.0 - resolution: "@asyncapi/specs@npm:3.2.0" - checksum: 09971262aefc8844ab3e7c0c3652711862ac562dd5d614f23b496185690430a81df8e50eddba657f4141e0fd9548ef622fe6c20f4e3dec8054be23f774798335 + version: 3.2.1 + resolution: "@asyncapi/specs@npm:3.2.1" + checksum: 6392d0aaa658905f67553160c725bb0b535e187a120fb2305eb1a223460244a43eea804c00f4985ecbaddb2b04527ce9db51e72117dbe694db547b734f8082dd languageName: node linkType: hard