Skip to content

Commit

Permalink
feat(reference): add support for OpenAPI 3.0.4 (#4624)
Browse files Browse the repository at this point in the history
Refs #4612
  • Loading branch information
char0n authored Dec 26, 2024
1 parent 1d0b4a5 commit 0dcb105
Show file tree
Hide file tree
Showing 214 changed files with 688 additions and 677 deletions.
3 changes: 2 additions & 1 deletion packages/apidom-reference/.mocharc.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"recursive": true,
"spec": "test/**/*.mjs",
"file": ["test/mocha-bootstrap.mjs"]
"file": ["test/mocha-bootstrap.mjs"],
"ignore": ["test/perf/**/*.mjs"]
}
18 changes: 14 additions & 4 deletions packages/apidom-reference/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ Supported media types are:
#### [openapi-json-3-0](https://github.com/swagger-api/apidom/tree/main/packages/apidom-reference/src/parse/parsers/openapi-json-3-0)

Wraps [@swagger-api/apidom-parser-adapter-openapi-json-3-0](https://github.com/swagger-api/apidom/tree/main/packages/apidom-parser-adapter-openapi-json-3-0) package
and is uniquely identified by `openapi-json-3-1` name.
and is uniquely identified by `openapi-json-3-0` name.

Supported media types are:

Expand All @@ -146,6 +146,8 @@ Supported media types are:
'application/vnd.oai.openapi+json;version=3.0.2',
'application/vnd.oai.openapi;version=3.0.3',
'application/vnd.oai.openapi+json;version=3.0.3',
'application/vnd.oai.openapi;version=3.0.4',
'application/vnd.oai.openapi+json;version=3.0.4',
]
```

Expand All @@ -166,7 +168,7 @@ Supported media types are:
#### [openapi-yaml-3-0](https://github.com/swagger-api/apidom/tree/main/packages/apidom-reference/src/parse/parsers/openapi-yaml-3-0)

Wraps [@swagger-api/apidom-parser-adapter-openapi-yaml-3-0](https://github.com/swagger-api/apidom/tree/main/packages/apidom-parser-adapter-openapi-yaml-3-0) package
and is uniquely identified by `openapi-yaml-3-1` name.
and is uniquely identified by `openapi-yaml-3-0` name.

Supported media types are:

Expand All @@ -180,6 +182,8 @@ Supported media types are:
'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 @@ -1187,7 +1191,7 @@ Supported media types:

##### [openapi-3-0](https://github.com/swagger-api/apidom/tree/main/packages/apidom-reference/src/resolve/strategies/openapi-3-0)

External resolution strategy for understanding and resolving external dependencies of [OpenApi 3.0.x](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md) definitions.
External resolution strategy for understanding and resolving external dependencies of [OpenApi 3.0.x](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.4.md) definitions.

Supported media types:

Expand All @@ -1205,6 +1209,9 @@ Supported media types:
'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',
]
```

Expand Down Expand Up @@ -1555,7 +1562,7 @@ Supported media types:

##### [openapi-3-0](https://github.com/swagger-api/apidom/tree/main/packages/apidom-reference/src/dereference/strategies/openapi-3-0)

Dereference strategy for dereferencing [OpenApi 3.0.x](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md) definitions.
Dereference strategy for dereferencing [OpenApi 3.0.x](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.4.md) definitions.

Supported media types:

Expand All @@ -1573,6 +1580,9 @@ Supported media types:
'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',
]
```

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"openapi": "3.0.3",
"openapi": "2.0",
"paths": {
"/path1": {
"$ref": "#/paths/~1path1"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[
{
"openapi": "3.0.3",
"openapi": "3.0.4",
"components": {
"callbacks": {
"callback1": {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"openapi": "3.0.3",
"openapi": "3.0.4",
"components": {
"callbacks": {
"callback1": {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[
{
"openapi": "3.0.3",
"openapi": "3.0.4",
"paths": {
"/path": {
"get": {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"openapi": "3.0.3",
"openapi": "3.0.4",
"paths": {
"/path": {
"get": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,18 @@ import { loadJsonFile } from '../../../../helpers.ts';
import { dereference } from '../../../../../src/index.ts';

const __dirname = path.dirname(fileURLToPath(import.meta.url));
const rootFixturePath = path.join(__dirname, 'fixtures');
const entryFixturePath = path.join(__dirname, 'fixtures');

describe('dereference', function () {
context('strategies', function () {
context('openapi-3-0', function () {
context('Callback Object', function () {
context('given in components/callbacks field', function () {
const fixturePath = path.join(rootFixturePath, 'components-callbacks');
const fixturePath = path.join(entryFixturePath, 'components-callbacks');

specify('should dereference', async function () {
const rootFilePath = path.join(fixturePath, 'root.json');
const actual = await dereference(rootFilePath, {
const entryFilePath = path.join(fixturePath, 'entry.json');
const actual = await dereference(entryFilePath, {
parse: { mediaType: mediaTypes.latest('json') },
});
const expected = loadJsonFile(path.join(fixturePath, 'dereferenced.json'));
Expand All @@ -29,11 +29,11 @@ describe('dereference', function () {
});

context('given in Operation Object', function () {
const fixturePath = path.join(rootFixturePath, 'operation-object');
const fixturePath = path.join(entryFixturePath, 'operation-object');

specify('should dereference', async function () {
const rootFilePath = path.join(fixturePath, 'root.json');
const actual = await dereference(rootFilePath, {
const entryFilePath = path.join(fixturePath, 'entry.json');
const actual = await dereference(entryFilePath, {
parse: { mediaType: mediaTypes.latest('json') },
});
const expected = loadJsonFile(path.join(fixturePath, 'dereferenced.json'));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ describe('dereference', function () {
context('openapi-3-0', function () {
context('Example Object', function () {
context('given single ExampleElement passed to dereferenceApiDOM', function () {
const fixturePath = path.join(__dirname, 'fixtures', 'external-value-json', 'root.json');
const fixturePath = path.join(__dirname, 'fixtures', 'external-value-json', 'entry.json');

specify('should dereference', async function () {
const parseResult = await parse(fixturePath, {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[
{
"openapi": "3.0.3",
"openapi": "3.0.4",
"components": {
"examples": {
"example1": {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"openapi": "3.0.3",
"openapi": "3.0.4",
"components": {
"examples": {
"example1": {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[
{
"openapi": "3.0.3",
"openapi": "3.0.4",
"components": {
"examples": {
"example1": {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"openapi": "3.0.3",
"openapi": "3.0.4",
"components": {
"examples": {
"example1": {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[
{
"openapi": "3.0.3",
"openapi": "3.0.4",
"components": {
"examples": {
"example1": {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"openapi": "3.0.3",
"openapi": "3.0.4",
"components": {
"examples": {
"example1": {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[
{
"openapi": "3.0.3",
"openapi": "3.0.4",
"components": {
"examples": {
"example1": {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"openapi": "3.0.3",
"openapi": "3.0.4",
"components": {
"examples": {
"example1": {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[
{
"openapi": "3.0.3",
"openapi": "3.0.4",
"components": {
"examples": {
"example1": {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"openapi": "3.0.3",
"openapi": "3.0.4",
"components": {
"examples": {
"example1": {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[
{
"openapi": "3.0.3",
"openapi": "3.0.4",
"components": {
"examples": {
"example1": {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"openapi": "3.0.3",
"openapi": "3.0.4",
"components": {
"examples": {
"example1": {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"openapi": "3.0.3",
"openapi": "3.0.4",
"components": {
"examples": {
"example1": {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"openapi": "3.0.3",
"openapi": "3.0.4",
"components": {
"examples": {
"example1": {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[
{
"openapi": "3.0.3",
"openapi": "3.0.4",
"components": {
"examples": {
"example1": {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"openapi": "3.0.3",
"openapi": "3.0.4",
"components": {
"examples": {
"example1": {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[
{
"openapi": "3.0.3",
"openapi": "3.0.4",
"paths": {
"/path": {
"get": {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"openapi": "3.0.3",
"openapi": "3.0.4",
"paths": {
"/path": {
"get": {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[
{
"openapi": "3.0.3",
"openapi": "3.0.4",
"components": {
"parameters": {
"param1": {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"openapi": "3.0.3",
"openapi": "3.0.4",
"components": {
"parameters": {
"param1": {
Expand Down
Loading

0 comments on commit 0dcb105

Please sign in to comment.