Skip to content

Commit 2c023aa

Browse files
committed
chore: Added tests diff array of types
1 parent 7a66b80 commit 2c023aa

File tree

5 files changed

+163
-0
lines changed

5 files changed

+163
-0
lines changed
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
{
2+
"openapi": "3.1.0",
3+
"paths": {
4+
"/example": {
5+
"post": {
6+
"responses": {
7+
"200": {
8+
"description": "OK",
9+
"content": {
10+
"application/json": {
11+
"schema": {
12+
"type": [
13+
"string",
14+
"null"
15+
]
16+
}
17+
}
18+
}
19+
}
20+
}
21+
}
22+
}
23+
}
24+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
{
2+
"openapi": "3.1.0",
3+
"paths": {
4+
"/example": {
5+
"post": {
6+
"responses": {
7+
"200": {
8+
"description": "OK",
9+
"content": {
10+
"application/json": {
11+
"schema": {
12+
"anyOf": [
13+
{
14+
"type": "string"
15+
},
16+
{
17+
"type": "null"
18+
}
19+
]
20+
}
21+
}
22+
}
23+
}
24+
}
25+
}
26+
}
27+
}
28+
}
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
{
2+
"openapi": "3.1.0",
3+
"paths": {
4+
"/example": {
5+
"post": {
6+
"responses": {
7+
"200": {
8+
"description": "OK",
9+
"content": {
10+
"application/json": {
11+
"schema": {
12+
"allOf": [
13+
{
14+
"allOf": [
15+
{
16+
"type": "string"
17+
}
18+
]
19+
},
20+
{
21+
"allOf": [
22+
{
23+
"type": "null"
24+
},
25+
{
26+
"type": "integer"
27+
},
28+
{
29+
"type": "boolean"
30+
}
31+
]
32+
}
33+
]
34+
}
35+
}
36+
}
37+
}
38+
}
39+
}
40+
}
41+
}
42+
}
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
{
2+
"openapi": "3.1.0",
3+
"paths": {
4+
"/example": {
5+
"post": {
6+
"responses": {
7+
"200": {
8+
"description": "OK",
9+
"content": {
10+
"application/json": {
11+
"schema": {
12+
"allOf": [
13+
{
14+
"allOf": [
15+
{
16+
"type": "null"
17+
},
18+
{
19+
"type": "string"
20+
}
21+
]
22+
},
23+
{
24+
"allOf": [
25+
{
26+
"type": "integer"
27+
},
28+
{
29+
"type": "boolean"
30+
}
31+
]
32+
}
33+
]
34+
}
35+
}
36+
}
37+
}
38+
}
39+
}
40+
}
41+
}
42+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import arrayOfTypeIsEquivalentToAnyOfBefore from './helper/resources/array-of-type-is-equivalent-to-anyOf/before.json'
2+
import arrayOfTypeIsEquivalentToAnyOfAfter from './helper/resources/array-of-type-is-equivalent-to-anyOf/after.json'
3+
4+
import nullMovesInCombinerHierarchyBefore from './helper/resources/null-moves-in-combiner-hierarchy/before.json'
5+
import nullMovesInCombinerHierarchyAfter from './helper/resources/null-moves-in-combiner-hierarchy/after.json'
6+
import { apiDiff, CompareOptions } from '../src'
7+
import { TEST_DIFF_FLAG, TEST_ORIGINS_FLAG } from './helper'
8+
import { diffsMatcher } from './helper/matchers'
9+
10+
const OPTIONS: CompareOptions = {
11+
originsFlag: TEST_ORIGINS_FLAG,
12+
metaKey: TEST_DIFF_FLAG,
13+
validate: true,
14+
unify: true,
15+
}
16+
17+
describe('OAS 3.1 array of types', () => {
18+
it('array of type is equivalent to anyOf', () => {
19+
const { diffs } = apiDiff(arrayOfTypeIsEquivalentToAnyOfBefore, arrayOfTypeIsEquivalentToAnyOfAfter, OPTIONS)
20+
expect(diffs).toBeEmpty()
21+
})
22+
23+
it('no changes when "null" moves in combiner hierarchy', () => {
24+
const { diffs } = apiDiff(nullMovesInCombinerHierarchyBefore, nullMovesInCombinerHierarchyAfter, OPTIONS)
25+
expect(diffs).toBeEmpty()
26+
})
27+
})

0 commit comments

Comments
 (0)