Skip to content

Commit

Permalink
docs(ns-openapi-3-0): adapt to having OpenAPI 3.0.4 support (#4618)
Browse files Browse the repository at this point in the history
Refs #4612
  • Loading branch information
char0n authored Dec 24, 2024
1 parent db2140e commit b92891e
Show file tree
Hide file tree
Showing 6 changed files with 66 additions and 65 deletions.
63 changes: 32 additions & 31 deletions packages/apidom-ns-openapi-3-0/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

`@swagger-api/apidom-ns-openapi-3-0` contains ApiDOM namespace supports following OpenAPI specification versions:

- [OpenAPI 3.0.4 specification](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.4.md)
- [OpenAPI 3.0.3 specification](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md)
- [OpenAPI 3.0.2 specification](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.2.md)
- [OpenAPI 3.0.1 specification](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.1.md)
Expand Down Expand Up @@ -156,7 +157,7 @@ import { parse } from '@swagger-api/apidom-parser-adapter-yaml-1-2';
import { refractorPluginReplaceEmptyElement, OpenApi3_0Element } from '@swagger-api/apidom-ns-openapi-3-0';

const yamlDefinition = `
openapi: 3.0.3
openapi: 3.0.4
info:
`;
const apiDOM = await parse(yamlDefinition);
Expand Down Expand Up @@ -187,34 +188,34 @@ const openApiElement = OpenApi3_0Element.refract(apiDOM.result, {

Only fully implemented specification objects should be checked here.

- [x] [OpenAPI Object](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#oasObject)
- [x] [Info Object](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#infoObject)
- [x] [Contact Object](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#contactObject)
- [x] [License Object](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#licenseObject)
- [x] [Server Object](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#serverObject)
- [x] [Server Variable Object](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#serverVariableObject)
- [x] [Components](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#componentsObject)
- [x] [Paths Object](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#pathsObject)
- [x] [Path Item Object](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#pathItemObject)
- [x] [Operation Object](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#operationObject)
- [x] [External Documentation Object](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#externalDocumentationObject)
- [x] [Parameter Object](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#parameterObject)
- [x] [Request Body Object](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#requestBodyObject)
- [x] [Media Type Object](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#mediaTypeObject)
- [x] [Encoding Object](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#encodingObject)
- [x] [Responses Object](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#responsesObject)
- [x] [Callback Object](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#callbackObject)
- [x] [Example Object](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#exampleObject)
- [x] [Link Object](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#linkObject)
- [x] [Header Object](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#headerObject)
- [x] [Tag Object](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#tagObject)
- [x] [Reference Object](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#referenceObject)
- [x] [Schema Object](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#schemaObject)
- [x] [Discriminator Object](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#discriminatorObject)
- [x] [XML Object](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#xmlObject)
- [x] [Security Scheme Object](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#securitySchemeObject)
- [x] [OAuth Flows Object](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#oauthFlowsObject)
- [x] [OAuth Flow Object](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#oauthFlowObject)
- [x] [Security Requirement Object](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#securityRequirementObject)
- [x] [Specification extensions](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#specificationExtensions)
- [x] [OpenAPI Object](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.4.md#openapi-object)
- [x] [Info Object](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.4.md#info-object)
- [x] [Contact Object](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.4.md#contact-object)
- [x] [License Object](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.4.md#license-object)
- [x] [Server Object](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.4.md#server-object)
- [x] [Server Variable Object](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.4.md#server-variable-object)
- [x] [Components](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.4.md#components-object)
- [x] [Paths Object](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.4.md#paths-object)
- [x] [Path Item Object](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.4.md#path-item-object)
- [x] [Operation Object](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.4.md#operation-object)
- [x] [External Documentation Object](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.4.md#external-documentation-object)
- [x] [Parameter Object](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.4.md#parameter-object)
- [x] [Request Body Object](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.4.md#request-body-object)
- [x] [Media Type Object](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.4.md#media-type-object)
- [x] [Encoding Object](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.4.md#encoding-object)
- [x] [Responses Object](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.4.md#responses-object)
- [x] [Callback Object](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.4.md#callback-object)
- [x] [Example Object](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.4.md#example-object)
- [x] [Link Object](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.4.md#link-object)
- [x] [Header Object](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.4.md#header-object)
- [x] [Tag Object](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.4.md#tag-object)
- [x] [Reference Object](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.4.md#reference-object)
- [x] [Schema Object](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.4.md#schema-object)
- [x] [Discriminator Object](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.4.md#discriminator-object)
- [x] [XML Object](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.4.md#xml-object)
- [x] [Security Scheme Object](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.4.md#security-scheme-object)
- [x] [OAuth Flows Object](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.4.md#oauth-flows-object)
- [x] [OAuth Flow Object](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.4.md#oauth-flow-object)
- [x] [Security Requirement Object](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.4.md#security-requirement-object)
- [x] [Specification extensions](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.4.md#specification-extensions)

Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`refractor given generic ApiDOM object in OpenApi 3.0.3 shape should refract to OpenApi 3.0 Element 1`] = `
exports[`refractor given generic ApiDOM object in OpenApi 3.0.4 shape should refract to OpenApi 3.0 Element 1`] = `
{
"element": "openApi3_0",
"meta": {
Expand Down Expand Up @@ -50,7 +50,7 @@ exports[`refractor given generic ApiDOM object in OpenApi 3.0.3 shape should ref
]
}
},
"content": "3.0.3"
"content": "3.0.4"
}
}
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"openapi": "3.0.3",
"openapi": "3.0.4",
"info": {
"title": "Sample Pet Store App",
"description": "This is a sample server for a pet store.",
Expand Down
40 changes: 20 additions & 20 deletions packages/apidom-ns-openapi-3-0/test/refractor/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import * as predicates from '../../src/predicates.ts';
const __dirname = path.dirname(fileURLToPath(import.meta.url));

describe('refractor', function () {
context('given generic ApiDOM object in OpenApi 3.0.3 shape', function () {
context('given generic ApiDOM object in OpenApi 3.0.4 shape', function () {
specify('should refract to OpenApi 3.0 Element', function () {
const openApiString = fs
.readFileSync(path.join(__dirname, 'fixtures', 'openapi.json'))
Expand Down Expand Up @@ -57,7 +57,7 @@ describe('refractor', function () {
visitor: {
OpenapiElement(element: OpenapiElement) {
// @ts-ignore
element.content = '3.0.4'; // eslint-disable-line no-param-reassign
element.content = '3.0.5'; // eslint-disable-line no-param-reassign
},
},
post() {},
Expand Down Expand Up @@ -88,7 +88,7 @@ describe('refractor', function () {
context('plugin', function () {
specify('should be called with toolbox object', function () {
const genericObject = new ObjectElement({
openapi: '3.0.3',
openapi: '3.0.4',
});
OpenApi3_0Element.refract(genericObject, {
plugins: [plugin1],
Expand All @@ -99,7 +99,7 @@ describe('refractor', function () {

specify('should have predicates in toolbox object', function () {
const genericObject = new ObjectElement({
openapi: '3.0.3',
openapi: '3.0.4',
});
OpenApi3_0Element.refract(genericObject, {
plugins: [plugin1],
Expand All @@ -110,7 +110,7 @@ describe('refractor', function () {

specify('should have namespace in toolbox object', function () {
const genericObject = new ObjectElement({
openapi: '3.0.3',
openapi: '3.0.4',
});
OpenApi3_0Element.refract(genericObject, {
plugins: [plugin1],
Expand All @@ -123,7 +123,7 @@ describe('refractor', function () {
context('pre hook', function () {
specify('should call it once', function () {
const genericObject = new ObjectElement({
openapi: '3.0.3',
openapi: '3.0.4',
});
OpenApi3_0Element.refract(genericObject, {
plugins: [plugin1],
Expand All @@ -134,7 +134,7 @@ describe('refractor', function () {

specify('should call it before other plugin pre hook', function () {
const genericObject = new ObjectElement({
openapi: '3.0.3',
openapi: '3.0.4',
});
OpenApi3_0Element.refract(genericObject, {
plugins: [plugin1, plugin2],
Expand All @@ -145,7 +145,7 @@ describe('refractor', function () {

specify('should call it before visiting', function () {
const genericObject = new ObjectElement({
openapi: '3.0.3',
openapi: '3.0.4',
});
OpenApi3_0Element.refract(genericObject, {
plugins: [plugin1, plugin2],
Expand All @@ -159,7 +159,7 @@ describe('refractor', function () {
context('post hook', function () {
specify('should call it once', function () {
const genericObject = new ObjectElement({
openapi: '3.0.3',
openapi: '3.0.4',
});
OpenApi3_0Element.refract(genericObject, {
plugins: [plugin1],
Expand All @@ -170,7 +170,7 @@ describe('refractor', function () {

specify('should call it before other plugin post hook', function () {
const genericObject = new ObjectElement({
openapi: '3.0.3',
openapi: '3.0.4',
});
OpenApi3_0Element.refract(genericObject, {
plugins: [plugin1, plugin2],
Expand All @@ -181,7 +181,7 @@ describe('refractor', function () {

specify('should call it after visiting', function () {
const genericObject = new ObjectElement({
openapi: '3.0.3',
openapi: '3.0.4',
});
OpenApi3_0Element.refract(genericObject, {
plugins: [plugin1, plugin2],
Expand All @@ -195,7 +195,7 @@ describe('refractor', function () {
context('visitor', function () {
specify('should be called once', function () {
const genericObject = new ObjectElement({
openapi: '3.0.3',
openapi: '3.0.4',
});
OpenApi3_0Element.refract(genericObject, {
plugins: [plugin1, plugin2],
Expand All @@ -207,7 +207,7 @@ describe('refractor', function () {

specify('should be called in proper order', function () {
const genericObject = new ObjectElement({
openapi: '3.0.3',
openapi: '3.0.4',
});
OpenApi3_0Element.refract(genericObject, {
plugins: [plugin1, plugin2],
Expand All @@ -221,7 +221,7 @@ describe('refractor', function () {
context('first plugin', function () {
specify('should receive arguments', function () {
const genericObject = new ObjectElement({
openapi: '3.0.3',
openapi: '3.0.4',
});
OpenApi3_0Element.refract(genericObject, {
plugins: [plugin1],
Expand All @@ -232,7 +232,7 @@ describe('refractor', function () {

specify('should receive node as first argument', function () {
const genericObject = new ObjectElement({
openapi: '3.0.3',
openapi: '3.0.4',
});
OpenApi3_0Element.refract(genericObject, {
plugins: [plugin1],
Expand All @@ -243,20 +243,20 @@ describe('refractor', function () {

specify('should augment openapi version', function () {
const genericObject = new ObjectElement({
openapi: '3.0.3',
openapi: '3.0.4',
});
const openApiElement = OpenApi3_0Element.refract(genericObject, {
plugins: [plugin1],
});

assert.deepEqual(toValue(openApiElement), { openapi: '3.0.4' });
assert.deepEqual(toValue(openApiElement), { openapi: '3.0.5' });
});
});

context('second plugin', function () {
specify('should receive arguments', function () {
const genericObject = new ObjectElement({
openapi: '3.0.3',
openapi: '3.0.4',
});
OpenApi3_0Element.refract(genericObject, {
plugins: [plugin1, plugin2],
Expand All @@ -267,7 +267,7 @@ describe('refractor', function () {

specify('should receive node as first argument', function () {
const genericObject = new ObjectElement({
openapi: '3.0.3',
openapi: '3.0.4',
});
OpenApi3_0Element.refract(genericObject, {
plugins: [plugin1, plugin2],
Expand All @@ -278,7 +278,7 @@ describe('refractor', function () {

specify('should append metadata to openapi version', function () {
const genericObject = new ObjectElement({
openapi: '3.0.3',
openapi: '3.0.4',
});
const openApiElement = OpenApi3_0Element.refract(genericObject, {
plugins: [plugin1, plugin2],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { refractorPluginReplaceEmptyElement, OpenApi3_0Element } from '../../../
describe('given empty value instead of InfoElement', function () {
it('should replace empty value with semantic element', async function () {
const yamlDefinition = dedent`
openapi: 3.0.3
openapi: 3.0.4
info:
`;
const apiDOM = await parse(yamlDefinition);
Expand All @@ -23,7 +23,7 @@ describe('given empty value instead of InfoElement', function () {
describe('given empty value instead of ContactElement', function () {
it('should replace empty value with semantic element', async function () {
const yamlDefinition = dedent`
openapi: 3.0.3
openapi: 3.0.4
info:
contact:
`;
Expand All @@ -39,7 +39,7 @@ describe('given empty value instead of ContactElement', function () {
describe('given empty value instead for OpenAPI.components.schemas', function () {
it('should replace empty value with semantic element', async function () {
const yamlDefinition = dedent`
openapi: 3.0.3
openapi: 3.0.4
components:
schemas:
`;
Expand All @@ -60,7 +60,7 @@ describe('given empty value instead for OpenAPI.components.schemas', function ()
describe('given empty value instead for OpenAPI.components.schemas.*', function () {
it('should replace empty value with semantic element', async function () {
const yamlDefinition = dedent`
openapi: 3.0.3
openapi: 3.0.4
components:
schemas:
Schema1:
Expand All @@ -77,7 +77,7 @@ describe('given empty value instead for OpenAPI.components.schemas.*', function
describe('given empty value instead for Schema.properties.*', function () {
it('should replace empty value with semantic element', async function () {
const yamlDefinition = dedent`
openapi: 3.0.3
openapi: 3.0.4
components:
schemas:
User:
Expand All @@ -96,7 +96,7 @@ describe('given empty value instead for Schema.properties.*', function () {
describe('given OpenAPI definition with no empty values', function () {
it('should do nothing', async function () {
const yamlDefinition = dedent`
openapi: 3.0.3
openapi: 3.0.4
info: {}
`;
const apiDOM = await parse(yamlDefinition);
Expand All @@ -111,7 +111,7 @@ describe('given OpenAPI definition with no empty values', function () {
describe('given OpenAPI definition with empty values', function () {
it('should generate proper source maps', async function () {
const yamlDefinition = dedent`
openapi: 3.0.3
openapi: 3.0.4
info:
`;
const apiDOM = await parse(yamlDefinition, { sourceMap: true });
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { refractorPluginReplaceEmptyElement, OpenApi3_0Element } from '../../../
describe('given empty value instead of ServerElement', function () {
it('should replace empty value with semantic element', async function () {
const yamlDefinition = dedent`
openapi: 3.0.3
openapi: 3.0.4
servers:
-
`;
Expand All @@ -24,7 +24,7 @@ describe('given empty value instead of ServerElement', function () {
describe('given empty value instead of SecurityRequirementElement', function () {
it('should replace empty value with semantic element', async function () {
const yamlDefinition = dedent`
openapi: 3.0.3
openapi: 3.0.4
security:
-
`;
Expand All @@ -40,7 +40,7 @@ describe('given empty value instead of SecurityRequirementElement', function ()
describe('given multiple empty values instead of TagElement', function () {
it('should replace empty values with semantic elements', async function () {
const yamlDefinition = dedent`
openapi: 3.0.3
openapi: 3.0.4
tags:
-
-
Expand All @@ -57,7 +57,7 @@ describe('given multiple empty values instead of TagElement', function () {
describe('given empty values instead of SchemaElement for allOf keyword', function () {
it('should replace empty values with semantic elements', async function () {
const yamlDefinition = dedent`
openapi: 3.0.3
openapi: 3.0.4
components:
schemas:
Schema1:
Expand Down

0 comments on commit b92891e

Please sign in to comment.