Skip to content

Commit e1c2eb7

Browse files
authored
feat(ns-openapi-3-0): add support for OpenAPI 3.0.4 (#4613)
Refs #4612
1 parent 40d2b25 commit e1c2eb7

File tree

6 files changed

+235
-6
lines changed

6 files changed

+235
-6
lines changed

packages/apidom-ns-openapi-3-0/src/media-types.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export class OpenAPIMediaTypes extends MediaTypes<string> {
1515
return this.filter((mediaType) => mediaType.includes(effectiveFormat));
1616
}
1717

18-
findBy(version = '3.0.3', format: Format = 'generic') {
18+
findBy(version = '3.0.4', format: Format = 'generic') {
1919
const search =
2020
format === 'generic'
2121
? `vnd.oai.openapi;version=${version}`
@@ -46,6 +46,9 @@ const mediaTypes = new OpenAPIMediaTypes(
4646
'application/vnd.oai.openapi;version=3.0.3',
4747
'application/vnd.oai.openapi+json;version=3.0.3',
4848
'application/vnd.oai.openapi+yaml;version=3.0.3',
49+
'application/vnd.oai.openapi;version=3.0.4',
50+
'application/vnd.oai.openapi+json;version=3.0.4',
51+
'application/vnd.oai.openapi+yaml;version=3.0.4',
4952
);
5053

5154
export default mediaTypes;

packages/apidom-ns-openapi-3-0/src/refractor/plugins/replace-empty-element.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import {
1212
} from '@swagger-api/apidom-core';
1313

1414
/**
15-
* OpenAPI 3.0.3 specification elements.
15+
* OpenAPI 3.0.x specification elements.
1616
*/
1717
import InfoElement from '../../elements/Info.ts';
1818
import ContactElement from '../../elements/Contact.ts';
@@ -89,7 +89,7 @@ import { getNodeType } from '../../traversal/visitor.ts';
8989
* @example
9090
*
9191
* ```yaml
92-
* openapi: 3.0.3
92+
* openapi: 3.0.4
9393
* info:
9494
* ```
9595
* Refracting result without this plugin:

packages/apidom-ns-openapi-3-0/test/refractor/elements/OpenApi3-0/__snapshots__/index.mjs.snap

+125-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,130 @@
11
// Jest Snapshot v1, https://goo.gl/fbAQLP
22

3-
exports[`refractor elements OpenApi3_0Element should refract to semantic ApiDOM tree 1`] = `
3+
exports[`refractor elements OpenApi3_0Element should refract OpenAPI 3.0.0 to semantic ApiDOM tree 1`] = `
4+
(OpenApi3_0Element
5+
(MemberElement
6+
(StringElement)
7+
(OpenapiElement))
8+
(MemberElement
9+
(StringElement)
10+
(InfoElement))
11+
(MemberElement
12+
(StringElement)
13+
(ArrayElement
14+
(ServerElement)))
15+
(MemberElement
16+
(StringElement)
17+
(PathsElement))
18+
(MemberElement
19+
(StringElement)
20+
(ComponentsElement))
21+
(MemberElement
22+
(StringElement)
23+
(ArrayElement
24+
(SecurityRequirementElement)))
25+
(MemberElement
26+
(StringElement)
27+
(ArrayElement
28+
(TagElement)))
29+
(MemberElement
30+
(StringElement)
31+
(ExternalDocumentationElement)))
32+
`;
33+
34+
exports[`refractor elements OpenApi3_0Element should refract OpenAPI 3.0.1 to semantic ApiDOM tree 1`] = `
35+
(OpenApi3_0Element
36+
(MemberElement
37+
(StringElement)
38+
(OpenapiElement))
39+
(MemberElement
40+
(StringElement)
41+
(InfoElement))
42+
(MemberElement
43+
(StringElement)
44+
(ArrayElement
45+
(ServerElement)))
46+
(MemberElement
47+
(StringElement)
48+
(PathsElement))
49+
(MemberElement
50+
(StringElement)
51+
(ComponentsElement))
52+
(MemberElement
53+
(StringElement)
54+
(ArrayElement
55+
(SecurityRequirementElement)))
56+
(MemberElement
57+
(StringElement)
58+
(ArrayElement
59+
(TagElement)))
60+
(MemberElement
61+
(StringElement)
62+
(ExternalDocumentationElement)))
63+
`;
64+
65+
exports[`refractor elements OpenApi3_0Element should refract OpenAPI 3.0.2 to semantic ApiDOM tree 1`] = `
66+
(OpenApi3_0Element
67+
(MemberElement
68+
(StringElement)
69+
(OpenapiElement))
70+
(MemberElement
71+
(StringElement)
72+
(InfoElement))
73+
(MemberElement
74+
(StringElement)
75+
(ArrayElement
76+
(ServerElement)))
77+
(MemberElement
78+
(StringElement)
79+
(PathsElement))
80+
(MemberElement
81+
(StringElement)
82+
(ComponentsElement))
83+
(MemberElement
84+
(StringElement)
85+
(ArrayElement
86+
(SecurityRequirementElement)))
87+
(MemberElement
88+
(StringElement)
89+
(ArrayElement
90+
(TagElement)))
91+
(MemberElement
92+
(StringElement)
93+
(ExternalDocumentationElement)))
94+
`;
95+
96+
exports[`refractor elements OpenApi3_0Element should refract OpenAPI 3.0.3 to semantic ApiDOM tree 1`] = `
97+
(OpenApi3_0Element
98+
(MemberElement
99+
(StringElement)
100+
(OpenapiElement))
101+
(MemberElement
102+
(StringElement)
103+
(InfoElement))
104+
(MemberElement
105+
(StringElement)
106+
(ArrayElement
107+
(ServerElement)))
108+
(MemberElement
109+
(StringElement)
110+
(PathsElement))
111+
(MemberElement
112+
(StringElement)
113+
(ComponentsElement))
114+
(MemberElement
115+
(StringElement)
116+
(ArrayElement
117+
(SecurityRequirementElement)))
118+
(MemberElement
119+
(StringElement)
120+
(ArrayElement
121+
(TagElement)))
122+
(MemberElement
123+
(StringElement)
124+
(ExternalDocumentationElement)))
125+
`;
126+
127+
exports[`refractor elements OpenApi3_0Element should refract OpenAPI 3.0.4 to semantic ApiDOM tree 1`] = `
4128
(OpenApi3_0Element
5129
(MemberElement
6130
(StringElement)

packages/apidom-ns-openapi-3-0/test/refractor/elements/OpenApi3-0/index.ts

+61-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,52 @@ import { OpenApi3_0Element } from '../../../../src/index.ts';
66
describe('refractor', function () {
77
context('elements', function () {
88
context('OpenApi3_0Element', function () {
9-
specify('should refract to semantic ApiDOM tree', function () {
9+
specify('should refract OpenAPI 3.0.0 to semantic ApiDOM tree', function () {
10+
const openApiElement = OpenApi3_0Element.refract({
11+
openapi: '3.0.0',
12+
info: {},
13+
servers: [{}],
14+
paths: {},
15+
components: {},
16+
security: [{}],
17+
tags: [{}],
18+
externalDocs: {},
19+
});
20+
21+
expect(sexprs(openApiElement)).toMatchSnapshot();
22+
});
23+
24+
specify('should refract OpenAPI 3.0.1 to semantic ApiDOM tree', function () {
25+
const openApiElement = OpenApi3_0Element.refract({
26+
openapi: '3.0.1',
27+
info: {},
28+
servers: [{}],
29+
paths: {},
30+
components: {},
31+
security: [{}],
32+
tags: [{}],
33+
externalDocs: {},
34+
});
35+
36+
expect(sexprs(openApiElement)).toMatchSnapshot();
37+
});
38+
39+
specify('should refract OpenAPI 3.0.2 to semantic ApiDOM tree', function () {
40+
const openApiElement = OpenApi3_0Element.refract({
41+
openapi: '3.0.2',
42+
info: {},
43+
servers: [{}],
44+
paths: {},
45+
components: {},
46+
security: [{}],
47+
tags: [{}],
48+
externalDocs: {},
49+
});
50+
51+
expect(sexprs(openApiElement)).toMatchSnapshot();
52+
});
53+
54+
specify('should refract OpenAPI 3.0.3 to semantic ApiDOM tree', function () {
1055
const openApiElement = OpenApi3_0Element.refract({
1156
openapi: '3.0.3',
1257
info: {},
@@ -20,6 +65,21 @@ describe('refractor', function () {
2065

2166
expect(sexprs(openApiElement)).toMatchSnapshot();
2267
});
68+
69+
specify('should refract OpenAPI 3.0.4 to semantic ApiDOM tree', function () {
70+
const openApiElement = OpenApi3_0Element.refract({
71+
openapi: '3.0.4',
72+
info: {},
73+
servers: [{}],
74+
paths: {},
75+
components: {},
76+
security: [{}],
77+
tags: [{}],
78+
externalDocs: {},
79+
});
80+
81+
expect(sexprs(openApiElement)).toMatchSnapshot();
82+
});
2383
});
2484
});
2585
});
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
11
// Jest Snapshot v1, https://goo.gl/fbAQLP
22

3+
exports[`refractor elements OpenapiElement 3.0.0 should refract to semantic ApiDOM tree 1`] = `(OpenapiElement)`;
4+
5+
exports[`refractor elements OpenapiElement 3.0.1 should refract to semantic ApiDOM tree 1`] = `(OpenapiElement)`;
6+
7+
exports[`refractor elements OpenapiElement 3.0.2 should refract to semantic ApiDOM tree 1`] = `(OpenapiElement)`;
8+
9+
exports[`refractor elements OpenapiElement 3.0.3 should refract to semantic ApiDOM tree 1`] = `(OpenapiElement)`;
10+
11+
exports[`refractor elements OpenapiElement 3.0.4 should refract to semantic ApiDOM tree 1`] = `(OpenapiElement)`;
12+
313
exports[`refractor elements OpenapiElement should refract to semantic ApiDOM tree 1`] = `(OpenapiElement)`;

packages/apidom-ns-openapi-3-0/test/refractor/elements/Openapi/index.ts

+33-1
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,44 @@ import { OpenapiElement } from '../../../../src/index.ts';
55

66
describe('refractor', function () {
77
context('elements', function () {
8-
context('OpenapiElement', function () {
8+
context('OpenapiElement 3.0.0', function () {
9+
specify('should refract to semantic ApiDOM tree', function () {
10+
const openapiElement = OpenapiElement.refract('3.0.0');
11+
12+
expect(sexprs(openapiElement)).toMatchSnapshot();
13+
});
14+
});
15+
16+
context('OpenapiElement 3.0.1', function () {
17+
specify('should refract to semantic ApiDOM tree', function () {
18+
const openapiElement = OpenapiElement.refract('3.0.1');
19+
20+
expect(sexprs(openapiElement)).toMatchSnapshot();
21+
});
22+
});
23+
24+
context('OpenapiElement 3.0.2', function () {
25+
specify('should refract to semantic ApiDOM tree', function () {
26+
const openapiElement = OpenapiElement.refract('3.0.2');
27+
28+
expect(sexprs(openapiElement)).toMatchSnapshot();
29+
});
30+
});
31+
32+
context('OpenapiElement 3.0.3', function () {
933
specify('should refract to semantic ApiDOM tree', function () {
1034
const openapiElement = OpenapiElement.refract('3.0.3');
1135

1236
expect(sexprs(openapiElement)).toMatchSnapshot();
1337
});
1438
});
39+
40+
context('OpenapiElement 3.0.4', function () {
41+
specify('should refract to semantic ApiDOM tree', function () {
42+
const openapiElement = OpenapiElement.refract('3.0.4');
43+
44+
expect(sexprs(openapiElement)).toMatchSnapshot();
45+
});
46+
});
1547
});
1648
});

0 commit comments

Comments
 (0)