Skip to content

Commit 5c4928b

Browse files
magicmatatjahuP0lip
authored andcommitted
feat(formats): support AsyncAPI 2.6.0 (#2391)
1 parent e026a85 commit 5c4928b

File tree

5 files changed

+35
-5
lines changed

5 files changed

+35
-5
lines changed

docs/guides/4-custom-rulesets.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ Formats are an optional way to specify which API description formats a rule, or
2929
- `aas2_3` (AsyncAPI v2.3.0)
3030
- `aas2_4` (AsyncAPI v2.4.0)
3131
- `aas2_5` (AsyncAPI v2.5.0)
32+
- `aas2_6` (AsyncAPI v2.6.0)
3233
- `oas2` (OpenAPI v2.0)
3334
- `oas3` (OpenAPI v3.x)
3435
- `oas3_0` (OpenAPI v3.0.x)

packages/formats/src/__tests__/asyncapi.test.ts

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { aas2, aas2_0, aas2_1, aas2_2, aas2_3, aas2_4, aas2_5 } from '../asyncapi';
1+
import { aas2, aas2_0, aas2_1, aas2_2, aas2_3, aas2_4, aas2_5, aas2_6 } from '../asyncapi';
22

33
describe('AsyncAPI format', () => {
44
describe('AsyncAPI 2.x', () => {
@@ -101,4 +101,28 @@ describe('AsyncAPI format', () => {
101101
},
102102
);
103103
});
104+
105+
describe('AsyncAPI 2.6', () => {
106+
it.each(['2.6.0', '2.6.2'])('recognizes %s version correctly', version => {
107+
expect(aas2_6({ asyncapi: version }, null)).toBe(true);
108+
});
109+
110+
it.each([
111+
'2',
112+
'2.3',
113+
'2.0.0',
114+
'2.1.0',
115+
'2.1.37',
116+
'2.2.0',
117+
'2.3.0',
118+
'2.4.0',
119+
'2.4.3',
120+
'2.5.0',
121+
'2.5.4',
122+
'2.7.0',
123+
'2.7.4',
124+
])('does not recognize %s version', version => {
125+
expect(aas2_6({ asyncapi: version }, null)).toBe(false);
126+
});
127+
});
104128
});

packages/formats/src/asyncapi.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ const aas2_2Regex = /^2\.2(?:\.[0-9]*)?$/;
1010
const aas2_3Regex = /^2\.3(?:\.[0-9]*)?$/;
1111
const aas2_4Regex = /^2\.4(?:\.[0-9]*)?$/;
1212
const aas2_5Regex = /^2\.5(?:\.[0-9]*)?$/;
13+
const aas2_6Regex = /^2\.6(?:\.[0-9]*)?$/;
1314

1415
const isAas2 = (document: unknown): document is { asyncapi: string } & Record<string, unknown> =>
1516
isPlainObject(document) && 'asyncapi' in document && aas2Regex.test(String((document as MaybeAAS2).asyncapi));
@@ -44,3 +45,7 @@ aas2_4.displayName = 'AsyncAPI 2.4.x';
4445
export const aas2_5: Format = (document: unknown): boolean =>
4546
isAas2(document) && aas2_5Regex.test(String((document as MaybeAAS2).asyncapi));
4647
aas2_5.displayName = 'AsyncAPI 2.5.x';
48+
49+
export const aas2_6: Format = (document: unknown): boolean =>
50+
isAas2(document) && aas2_6Regex.test(String((document as MaybeAAS2).asyncapi));
51+
aas2_6.displayName = 'AsyncAPI 2.6.x';

test-harness/scenarios/asyncapi2-streetlights.scenario

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ module.exports = asyncapi;
218218
====stdout====
219219
{document}
220220
1:1 warning asyncapi-tags AsyncAPI object must have non-empty "tags" array.
221-
1:11 information asyncapi-latest-version The latest version is not used. You should update to the "2.5.0" version. asyncapi
221+
1:11 information asyncapi-latest-version The latest version is not used. You should update to the "2.6.0" version. asyncapi
222222
2:6 warning asyncapi-info-contact Info object must have "contact" object. info
223223
45:13 warning asyncapi-operation-description Operation "description" must be present and non-empty string. channels.smartylighting/streetlights/1/0/event/{streetlightId}/lighting/measured.publish
224224
57:15 warning asyncapi-operation-description Operation "description" must be present and non-empty string. channels.smartylighting/streetlights/1/0/action/{streetlightId}/turn/on.subscribe

yarn.lock

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@ __metadata:
2828
linkType: hard
2929

3030
"@asyncapi/specs@npm:^3.2.0":
31-
version: 3.2.0
32-
resolution: "@asyncapi/specs@npm:3.2.0"
33-
checksum: 09971262aefc8844ab3e7c0c3652711862ac562dd5d614f23b496185690430a81df8e50eddba657f4141e0fd9548ef622fe6c20f4e3dec8054be23f774798335
31+
version: 3.2.1
32+
resolution: "@asyncapi/specs@npm:3.2.1"
33+
checksum: 6392d0aaa658905f67553160c725bb0b535e187a120fb2305eb1a223460244a43eea804c00f4985ecbaddb2b04527ce9db51e72117dbe694db547b734f8082dd
3434
languageName: node
3535
linkType: hard
3636

0 commit comments

Comments
 (0)