From 1d0b4a5013db445421518f3d6ab4675d8b2ce9f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Gorej?= Date: Wed, 25 Dec 2024 22:24:43 +0100 Subject: [PATCH] docs(parser-adapter-openapi-yaml-3-0): adapt to OpenAPI 3.0.4 support (#4623) Refs #4612 --- .../apidom-parser-adapter-openapi-yaml-3-0/README.md | 10 ++++++---- .../test/media-types.ts | 12 ++++++------ 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/packages/apidom-parser-adapter-openapi-yaml-3-0/README.md b/packages/apidom-parser-adapter-openapi-yaml-3-0/README.md index 149aab22e5..51adfa042b 100644 --- a/packages/apidom-parser-adapter-openapi-yaml-3-0/README.md +++ b/packages/apidom-parser-adapter-openapi-yaml-3-0/README.md @@ -1,6 +1,6 @@ # @swagger-api/apidom-parser-adapter-openapi-yaml-3-0 -`@swagger-api/apidom-parser-adapter-openapi-yaml-3-0` is a parser adapter for the [OpenAPI 3.0.x specification](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md) in [YAML format](https://yaml.org/spec/1.2/spec.html). +`@swagger-api/apidom-parser-adapter-openapi-yaml-3-0` is a parser adapter for the [OpenAPI 3.0.x specification](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.4.md) in [YAML format](https://yaml.org/spec/1.2/spec.html). Under the hood this adapter uses [apidom-parser-adapter-yaml-1-2](https://github.com/swagger-api/apidom/tree/main/packages/apidom-parser-adapter-yaml-1-2) to parse a source string into generic ApiDOM in [base ApiDOM namespace](https://github.com/swagger-api/apidom/tree/main/packages/apidom#base-namespace) which is then refracted with [OpenAPI 3.0.x Refractors](https://github.com/swagger-api/apidom/tree/main/packages/apidom-ns-openapi-3-0#refractors). @@ -33,6 +33,8 @@ Defines list of media types that this parser adapter recognizes. 'application/vnd.oai.openapi+yaml;version=3.0.2', 'application/vnd.oai.openapi;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+yaml;version=3.0.4', ] ``` @@ -69,11 +71,11 @@ with [supported media types](#mediatypes). import { parse, detect } from '@swagger-api/apidom-parser-adapter-openapi-yaml-3-0'; // detecting -await detect('openapi: 3.0.3'); // => true +await detect('openapi: 3.0.4'); // => true await detect('test'); // => false // parsing -const parseResult = await parse('openapi: 3.0.0', { sourceMap: true }); +const parseResult = await parse('openapi: 3.0.4', { sourceMap: true }); ``` ### Indirect usage @@ -88,5 +90,5 @@ const parser = new ApiDOMParser(); parser.use(openApiYamlAdapter); -const parseResult = await parser.parse('openapi: 3.0.3', { mediaType: openApiYamlAdapter.mediaTypes.latest('yaml') }); +const parseResult = await parser.parse('openapi: 3.0.4', { mediaType: openApiYamlAdapter.mediaTypes.latest('yaml') }); ``` diff --git a/packages/apidom-parser-adapter-openapi-yaml-3-0/test/media-types.ts b/packages/apidom-parser-adapter-openapi-yaml-3-0/test/media-types.ts index abaa340fee..cea79979d4 100644 --- a/packages/apidom-parser-adapter-openapi-yaml-3-0/test/media-types.ts +++ b/packages/apidom-parser-adapter-openapi-yaml-3-0/test/media-types.ts @@ -46,25 +46,25 @@ describe('given adapter is used in parser', function () { }); }); - context('given OpenAPI 3.0.3-rc2 definition in YAML format', function () { + context('given OpenAPI 3.0.0-rc2 definition in YAML format', function () { specify('should not find appropriate media type', async function () { - const mediaType = await parser.findMediaType('openapi: "3.0.3-rc2"'); + const mediaType = await parser.findMediaType('openapi: "3.0.0-rc2"'); assert.strictEqual(mediaType, 'application/octet-stream'); }); }); - context('given OpenAPI 3.0.3-rc1 definition in YAML format', function () { + context('given OpenAPI 3.0.0-rc1 definition in YAML format', function () { specify('should not find appropriate media type', async function () { - const mediaType = await parser.findMediaType('openapi: "3.0.3-rc1"'); + const mediaType = await parser.findMediaType('openapi: "3.0.0-rc1"'); assert.strictEqual(mediaType, 'application/octet-stream'); }); }); - context('given OpenAPI 3.0.3-rc0 definition in YAML format', function () { + context('given OpenAPI 3.0.0-rc0 definition in YAML format', function () { specify('should not find appropriate media type', async function () { - const mediaType = await parser.findMediaType('openapi: "3.0.3-rc0"'); + const mediaType = await parser.findMediaType('openapi: "3.0.0-rc0"'); assert.strictEqual(mediaType, 'application/octet-stream'); });