Skip to content

Commit

Permalink
docs(parser-adapter-openapi-yaml-3-0): adapt to OpenAPI 3.0.4 support (
Browse files Browse the repository at this point in the history
  • Loading branch information
char0n authored Dec 25, 2024
1 parent d736090 commit 1d0b4a5
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
10 changes: 6 additions & 4 deletions packages/apidom-parser-adapter-openapi-yaml-3-0/README.md
Original file line number Diff line number Diff line change
@@ -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).
Expand Down Expand Up @@ -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',
]
```

Expand Down Expand Up @@ -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
Expand All @@ -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') });
```
Original file line number Diff line number Diff line change
Expand Up @@ -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');
});
Expand Down

0 comments on commit 1d0b4a5

Please sign in to comment.