From b2f37f2f68965f8ff4bbbb84150b28f64c30461d Mon Sep 17 00:00:00 2001 From: Vladimir Gorej Date: Tue, 24 Dec 2024 13:11:51 +0100 Subject: [PATCH] docs(ns-openapi-3-0): adapt to having OpenAPI 3.0.4 support Refs #4612 --- packages/apidom-ns-openapi-3-0/README.md | 63 ++++++++++--------- .../refractor/__snapshots__/index.mjs.snap | 4 +- .../test/refractor/fixtures/openapi.json | 2 +- .../test/refractor/index.ts | 40 ++++++------ .../plugins/replace-empty-element/mappings.ts | 14 ++--- .../replace-empty-element/sequences.ts | 8 +-- 6 files changed, 66 insertions(+), 65 deletions(-) diff --git a/packages/apidom-ns-openapi-3-0/README.md b/packages/apidom-ns-openapi-3-0/README.md index f74427686f..9afe1132f2 100644 --- a/packages/apidom-ns-openapi-3-0/README.md +++ b/packages/apidom-ns-openapi-3-0/README.md @@ -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) @@ -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); @@ -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-pbject) +- [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) diff --git a/packages/apidom-ns-openapi-3-0/test/refractor/__snapshots__/index.mjs.snap b/packages/apidom-ns-openapi-3-0/test/refractor/__snapshots__/index.mjs.snap index 89754bf772..1a3ceaf530 100644 --- a/packages/apidom-ns-openapi-3-0/test/refractor/__snapshots__/index.mjs.snap +++ b/packages/apidom-ns-openapi-3-0/test/refractor/__snapshots__/index.mjs.snap @@ -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": { @@ -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" } } }, diff --git a/packages/apidom-ns-openapi-3-0/test/refractor/fixtures/openapi.json b/packages/apidom-ns-openapi-3-0/test/refractor/fixtures/openapi.json index 579d14dad9..fd0bb7f5c9 100644 --- a/packages/apidom-ns-openapi-3-0/test/refractor/fixtures/openapi.json +++ b/packages/apidom-ns-openapi-3-0/test/refractor/fixtures/openapi.json @@ -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.", diff --git a/packages/apidom-ns-openapi-3-0/test/refractor/index.ts b/packages/apidom-ns-openapi-3-0/test/refractor/index.ts index ee0125084b..97c3223608 100644 --- a/packages/apidom-ns-openapi-3-0/test/refractor/index.ts +++ b/packages/apidom-ns-openapi-3-0/test/refractor/index.ts @@ -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')) @@ -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() {}, @@ -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], @@ -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], @@ -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], @@ -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], @@ -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], @@ -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], @@ -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], @@ -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], @@ -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], @@ -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], @@ -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], @@ -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], @@ -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], @@ -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], @@ -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], @@ -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], diff --git a/packages/apidom-ns-openapi-3-0/test/refractor/plugins/replace-empty-element/mappings.ts b/packages/apidom-ns-openapi-3-0/test/refractor/plugins/replace-empty-element/mappings.ts index 70738ac7f4..2ab35c9c98 100644 --- a/packages/apidom-ns-openapi-3-0/test/refractor/plugins/replace-empty-element/mappings.ts +++ b/packages/apidom-ns-openapi-3-0/test/refractor/plugins/replace-empty-element/mappings.ts @@ -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); @@ -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: `; @@ -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: `; @@ -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: @@ -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: @@ -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); @@ -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 }); diff --git a/packages/apidom-ns-openapi-3-0/test/refractor/plugins/replace-empty-element/sequences.ts b/packages/apidom-ns-openapi-3-0/test/refractor/plugins/replace-empty-element/sequences.ts index 24e2865458..d787e4a213 100644 --- a/packages/apidom-ns-openapi-3-0/test/refractor/plugins/replace-empty-element/sequences.ts +++ b/packages/apidom-ns-openapi-3-0/test/refractor/plugins/replace-empty-element/sequences.ts @@ -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: - `; @@ -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: - `; @@ -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: - - @@ -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: