Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(ns-openapi-3-0): add support for OpenAPI 3.0.4 #4613

Merged
merged 1 commit into from
Dec 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion packages/apidom-ns-openapi-3-0/src/media-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export class OpenAPIMediaTypes extends MediaTypes<string> {
return this.filter((mediaType) => mediaType.includes(effectiveFormat));
}

findBy(version = '3.0.3', format: Format = 'generic') {
findBy(version = '3.0.4', format: Format = 'generic') {
const search =
format === 'generic'
? `vnd.oai.openapi;version=${version}`
Expand Down Expand Up @@ -46,6 +46,9 @@ const mediaTypes = new OpenAPIMediaTypes(
'application/vnd.oai.openapi;version=3.0.3',
'application/vnd.oai.openapi+json;version=3.0.3',
'application/vnd.oai.openapi+yaml;version=3.0.3',
'application/vnd.oai.openapi;version=3.0.4',
'application/vnd.oai.openapi+json;version=3.0.4',
'application/vnd.oai.openapi+yaml;version=3.0.4',
);

export default mediaTypes;
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
} from '@swagger-api/apidom-core';

/**
* OpenAPI 3.0.3 specification elements.
* OpenAPI 3.0.x specification elements.
*/
import InfoElement from '../../elements/Info.ts';
import ContactElement from '../../elements/Contact.ts';
Expand Down Expand Up @@ -89,7 +89,7 @@ import { getNodeType } from '../../traversal/visitor.ts';
* @example
*
* ```yaml
* openapi: 3.0.3
* openapi: 3.0.4
* info:
* ```
* Refracting result without this plugin:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,130 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`refractor elements OpenApi3_0Element should refract to semantic ApiDOM tree 1`] = `
exports[`refractor elements OpenApi3_0Element should refract OpenAPI 3.0.0 to semantic ApiDOM tree 1`] = `
(OpenApi3_0Element
(MemberElement
(StringElement)
(OpenapiElement))
(MemberElement
(StringElement)
(InfoElement))
(MemberElement
(StringElement)
(ArrayElement
(ServerElement)))
(MemberElement
(StringElement)
(PathsElement))
(MemberElement
(StringElement)
(ComponentsElement))
(MemberElement
(StringElement)
(ArrayElement
(SecurityRequirementElement)))
(MemberElement
(StringElement)
(ArrayElement
(TagElement)))
(MemberElement
(StringElement)
(ExternalDocumentationElement)))
`;

exports[`refractor elements OpenApi3_0Element should refract OpenAPI 3.0.1 to semantic ApiDOM tree 1`] = `
(OpenApi3_0Element
(MemberElement
(StringElement)
(OpenapiElement))
(MemberElement
(StringElement)
(InfoElement))
(MemberElement
(StringElement)
(ArrayElement
(ServerElement)))
(MemberElement
(StringElement)
(PathsElement))
(MemberElement
(StringElement)
(ComponentsElement))
(MemberElement
(StringElement)
(ArrayElement
(SecurityRequirementElement)))
(MemberElement
(StringElement)
(ArrayElement
(TagElement)))
(MemberElement
(StringElement)
(ExternalDocumentationElement)))
`;

exports[`refractor elements OpenApi3_0Element should refract OpenAPI 3.0.2 to semantic ApiDOM tree 1`] = `
(OpenApi3_0Element
(MemberElement
(StringElement)
(OpenapiElement))
(MemberElement
(StringElement)
(InfoElement))
(MemberElement
(StringElement)
(ArrayElement
(ServerElement)))
(MemberElement
(StringElement)
(PathsElement))
(MemberElement
(StringElement)
(ComponentsElement))
(MemberElement
(StringElement)
(ArrayElement
(SecurityRequirementElement)))
(MemberElement
(StringElement)
(ArrayElement
(TagElement)))
(MemberElement
(StringElement)
(ExternalDocumentationElement)))
`;

exports[`refractor elements OpenApi3_0Element should refract OpenAPI 3.0.3 to semantic ApiDOM tree 1`] = `
(OpenApi3_0Element
(MemberElement
(StringElement)
(OpenapiElement))
(MemberElement
(StringElement)
(InfoElement))
(MemberElement
(StringElement)
(ArrayElement
(ServerElement)))
(MemberElement
(StringElement)
(PathsElement))
(MemberElement
(StringElement)
(ComponentsElement))
(MemberElement
(StringElement)
(ArrayElement
(SecurityRequirementElement)))
(MemberElement
(StringElement)
(ArrayElement
(TagElement)))
(MemberElement
(StringElement)
(ExternalDocumentationElement)))
`;

exports[`refractor elements OpenApi3_0Element should refract OpenAPI 3.0.4 to semantic ApiDOM tree 1`] = `
(OpenApi3_0Element
(MemberElement
(StringElement)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,52 @@ import { OpenApi3_0Element } from '../../../../src/index.ts';
describe('refractor', function () {
context('elements', function () {
context('OpenApi3_0Element', function () {
specify('should refract to semantic ApiDOM tree', function () {
specify('should refract OpenAPI 3.0.0 to semantic ApiDOM tree', function () {
const openApiElement = OpenApi3_0Element.refract({
openapi: '3.0.0',
info: {},
servers: [{}],
paths: {},
components: {},
security: [{}],
tags: [{}],
externalDocs: {},
});

expect(sexprs(openApiElement)).toMatchSnapshot();
});

specify('should refract OpenAPI 3.0.1 to semantic ApiDOM tree', function () {
const openApiElement = OpenApi3_0Element.refract({
openapi: '3.0.1',
info: {},
servers: [{}],
paths: {},
components: {},
security: [{}],
tags: [{}],
externalDocs: {},
});

expect(sexprs(openApiElement)).toMatchSnapshot();
});

specify('should refract OpenAPI 3.0.2 to semantic ApiDOM tree', function () {
const openApiElement = OpenApi3_0Element.refract({
openapi: '3.0.2',
info: {},
servers: [{}],
paths: {},
components: {},
security: [{}],
tags: [{}],
externalDocs: {},
});

expect(sexprs(openApiElement)).toMatchSnapshot();
});

specify('should refract OpenAPI 3.0.3 to semantic ApiDOM tree', function () {
const openApiElement = OpenApi3_0Element.refract({
openapi: '3.0.3',
info: {},
Expand All @@ -20,6 +65,21 @@ describe('refractor', function () {

expect(sexprs(openApiElement)).toMatchSnapshot();
});

specify('should refract OpenAPI 3.0.4 to semantic ApiDOM tree', function () {
const openApiElement = OpenApi3_0Element.refract({
openapi: '3.0.4',
info: {},
servers: [{}],
paths: {},
components: {},
security: [{}],
tags: [{}],
externalDocs: {},
});

expect(sexprs(openApiElement)).toMatchSnapshot();
});
});
});
});
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`refractor elements OpenapiElement 3.0.0 should refract to semantic ApiDOM tree 1`] = `(OpenapiElement)`;

exports[`refractor elements OpenapiElement 3.0.1 should refract to semantic ApiDOM tree 1`] = `(OpenapiElement)`;

exports[`refractor elements OpenapiElement 3.0.2 should refract to semantic ApiDOM tree 1`] = `(OpenapiElement)`;

exports[`refractor elements OpenapiElement 3.0.3 should refract to semantic ApiDOM tree 1`] = `(OpenapiElement)`;

exports[`refractor elements OpenapiElement 3.0.4 should refract to semantic ApiDOM tree 1`] = `(OpenapiElement)`;

exports[`refractor elements OpenapiElement should refract to semantic ApiDOM tree 1`] = `(OpenapiElement)`;
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,44 @@ import { OpenapiElement } from '../../../../src/index.ts';

describe('refractor', function () {
context('elements', function () {
context('OpenapiElement', function () {
context('OpenapiElement 3.0.0', function () {
specify('should refract to semantic ApiDOM tree', function () {
const openapiElement = OpenapiElement.refract('3.0.0');

expect(sexprs(openapiElement)).toMatchSnapshot();
});
});

context('OpenapiElement 3.0.1', function () {
specify('should refract to semantic ApiDOM tree', function () {
const openapiElement = OpenapiElement.refract('3.0.1');

expect(sexprs(openapiElement)).toMatchSnapshot();
});
});

context('OpenapiElement 3.0.2', function () {
specify('should refract to semantic ApiDOM tree', function () {
const openapiElement = OpenapiElement.refract('3.0.2');

expect(sexprs(openapiElement)).toMatchSnapshot();
});
});

context('OpenapiElement 3.0.3', function () {
specify('should refract to semantic ApiDOM tree', function () {
const openapiElement = OpenapiElement.refract('3.0.3');

expect(sexprs(openapiElement)).toMatchSnapshot();
});
});

context('OpenapiElement 3.0.4', function () {
specify('should refract to semantic ApiDOM tree', function () {
const openapiElement = OpenapiElement.refract('3.0.4');

expect(sexprs(openapiElement)).toMatchSnapshot();
});
});
});
});
Loading