Skip to content

Commit 7a66b80

Browse files
committed
chore: Improving work with oas 3.1
1 parent e75bcbb commit 7a66b80

File tree

6 files changed

+228
-2
lines changed

6 files changed

+228
-2
lines changed

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,12 @@
2727
"update-lock-file": "update-lock-file @netcracker"
2828
},
2929
"dependencies": {
30-
"@netcracker/qubership-apihub-api-unifier": "2.0.0",
30+
"@netcracker/qubership-apihub-api-unifier": "feature-null-type",
3131
"@netcracker/qubership-apihub-json-crawl": "1.0.4",
3232
"fast-equals": "4.0.3"
3333
},
3434
"devDependencies": {
35-
"@netcracker/qubership-apihub-compatibility-suites": "2.0.3",
35+
"@netcracker/qubership-apihub-compatibility-suites": "feature-null-type",
3636
"@netcracker/qubership-apihub-graphapi": "1.0.8",
3737
"@netcracker/qubership-apihub-npm-gitflow": "3.1.0",
3838
"@types/jest": "29.5.11",

test/compatibility-suites/openapi/parameters-schema.test.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { runCommonSchemaTests } from './templates/schema'
2+
import { runCommonSchema31Tests } from './templates/schema31'
23

34
const SUITE_ID = 'parameters-schema'
45

@@ -11,6 +12,18 @@ const PARAMETERS_SCHEMA_PATH = [
1112
'schema',
1213
]
1314

15+
const PARAMETERS_SCHEMA31_PATH = [
16+
'paths',
17+
'/example',
18+
'get',
19+
'parameters',
20+
0,
21+
'schema',
22+
]
23+
1424
describe('Openapi3 Parameters Schema', () => {
1525
runCommonSchemaTests(SUITE_ID, PARAMETERS_SCHEMA_PATH)
1626
})
27+
describe('Openapi31 Parameters Schema', () => {
28+
runCommonSchema31Tests(SUITE_ID, PARAMETERS_SCHEMA31_PATH)
29+
})

test/compatibility-suites/openapi/request-body-schema.test.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { runCommonSchemaTests } from './templates/schema'
2+
import { runCommonSchema31Tests } from './templates/schema31'
23

34
const SUITE_ID = 'request-body-schema'
45

@@ -12,7 +13,20 @@ const REQUEST_SCHEMA_PATH = [
1213
'schema',
1314
]
1415

16+
const PARAMETERS_SCHEMA31_PATH = [
17+
'paths',
18+
'/example',
19+
'post',
20+
'requestBody',
21+
'content',
22+
'application/json',
23+
'schema',
24+
]
25+
1526
describe('Openapi3 Request Body Schema', () => {
1627
runCommonSchemaTests(SUITE_ID, REQUEST_SCHEMA_PATH)
28+
})
1729

30+
describe('Openapi31 Request Body Schema', () => {
31+
runCommonSchema31Tests(SUITE_ID, PARAMETERS_SCHEMA31_PATH)
1832
})

test/compatibility-suites/openapi/response-body-schema.test.ts

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1628,3 +1628,70 @@ describe('Openapi3 ResponseBody.Schema ', () => {
16281628
]))
16291629
})
16301630
})
1631+
1632+
const RESPONSE_SCHEMA31_PATH = [
1633+
'paths',
1634+
'/example',
1635+
'post',
1636+
'responses',
1637+
'200',
1638+
'content',
1639+
'application/json',
1640+
'schema',
1641+
]
1642+
1643+
describe('Openapi31 ResponseBody.Schema ', () => {
1644+
test('Add second type', async () => {
1645+
const testId = 'add-second-type'
1646+
const result = await compareFiles(SUITE_ID, testId)
1647+
expect(result).toEqual(diffsMatcher([
1648+
expect.objectContaining({
1649+
action: DiffAction.add,
1650+
afterDeclarationPaths: [[...RESPONSE_SCHEMA31_PATH, 'type', 1]],
1651+
type: breaking,
1652+
}),
1653+
]))
1654+
})
1655+
1656+
test('Add third type', async () => {
1657+
const testId = 'add-third-type'
1658+
const result = await compareFiles(SUITE_ID, testId)
1659+
expect(result).toEqual(diffsMatcher([
1660+
expect.objectContaining({
1661+
action: DiffAction.add,
1662+
afterDeclarationPaths: [[...RESPONSE_SCHEMA31_PATH, 'type', 2]],
1663+
type: breaking,
1664+
}),
1665+
]))
1666+
})
1667+
1668+
test('Remove second type', async () => {
1669+
const testId = 'remove-second-type'
1670+
const result = await compareFiles(SUITE_ID, testId)
1671+
expect(result).toEqual(diffsMatcher([
1672+
expect.objectContaining({
1673+
action: DiffAction.remove,
1674+
beforeDeclarationPaths: [[...RESPONSE_SCHEMA31_PATH, 'type', 1]],
1675+
type: nonBreaking,
1676+
}),
1677+
]))
1678+
})
1679+
1680+
test('Remove third type', async () => {
1681+
const testId = 'remove-third-type'
1682+
const result = await compareFiles(SUITE_ID, testId)
1683+
expect(result).toEqual(diffsMatcher([
1684+
expect.objectContaining({
1685+
action: DiffAction.remove,
1686+
beforeDeclarationPaths: [[...RESPONSE_SCHEMA31_PATH, 'type', 2]],
1687+
type: nonBreaking,
1688+
}),
1689+
]))
1690+
})
1691+
1692+
test('Reorder types', async () => {
1693+
const testId = 'reorder-types'
1694+
const result = await compareFiles(SUITE_ID, testId)
1695+
expect(result.length).toEqual(0)
1696+
})
1697+
})
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
import { compareFiles } from '../utils'
2+
import { diffsMatcher } from '../../helper/matchers'
3+
import { breaking, DiffAction, nonBreaking } from '../../../src'
4+
5+
const SUITE_ID = 'response-headers-schema'
6+
7+
const RESPONSE_SCHEMA31_PATH = [
8+
'paths',
9+
'/example',
10+
'get',
11+
'responses',
12+
'200',
13+
'headers',
14+
'X-Header-1',
15+
'schema',
16+
]
17+
18+
describe('Openapi31 ResponseHeaders.Schema ', () => {
19+
test('Add second type', async () => {
20+
const testId = 'add-second-type'
21+
const result = await compareFiles(SUITE_ID, testId)
22+
expect(result).toEqual(diffsMatcher([
23+
expect.objectContaining({
24+
action: DiffAction.add,
25+
afterDeclarationPaths: [[...RESPONSE_SCHEMA31_PATH, 'type', 1]],
26+
type: breaking,
27+
}),
28+
]))
29+
})
30+
31+
test('Add third type', async () => {
32+
const testId = 'add-third-type'
33+
const result = await compareFiles(SUITE_ID, testId)
34+
expect(result).toEqual(diffsMatcher([
35+
expect.objectContaining({
36+
action: DiffAction.add,
37+
afterDeclarationPaths: [[...RESPONSE_SCHEMA31_PATH, 'type', 2]],
38+
type: breaking,
39+
}),
40+
]))
41+
})
42+
43+
test('Remove second type', async () => {
44+
const testId = 'remove-second-type'
45+
const result = await compareFiles(SUITE_ID, testId)
46+
expect(result).toEqual(diffsMatcher([
47+
expect.objectContaining({
48+
action: DiffAction.remove,
49+
beforeDeclarationPaths: [[...RESPONSE_SCHEMA31_PATH, 'type', 1]],
50+
type: nonBreaking,
51+
}),
52+
]))
53+
})
54+
55+
test('Remove third type', async () => {
56+
const testId = 'remove-third-type'
57+
const result = await compareFiles(SUITE_ID, testId)
58+
expect(result).toEqual(diffsMatcher([
59+
expect.objectContaining({
60+
action: DiffAction.remove,
61+
beforeDeclarationPaths: [[...RESPONSE_SCHEMA31_PATH, 'type', 2]],
62+
type: nonBreaking,
63+
}),
64+
]))
65+
})
66+
67+
test('Reorder types', async () => {
68+
const testId = 'reorder-types'
69+
const result = await compareFiles(SUITE_ID, testId)
70+
expect(result.length).toEqual(0)
71+
})
72+
})
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
import { compareFiles } from '../../utils'
2+
import { JsonPath } from '@netcracker/qubership-apihub-json-crawl'
3+
import { breaking, DiffAction, nonBreaking } from '../../../../src'
4+
import { diffsMatcher } from '../../../helper/matchers'
5+
6+
export function runCommonSchema31Tests(suiteId: string, commonPath: JsonPath): void {
7+
test('Add second type', async () => {
8+
const testId = 'add-second-type'
9+
const result = await compareFiles(suiteId, testId)
10+
expect(result).toEqual(diffsMatcher([
11+
expect.objectContaining({
12+
action: DiffAction.add,
13+
afterDeclarationPaths: [[...commonPath, 'type', 1]],
14+
type: nonBreaking,
15+
}),
16+
]))
17+
})
18+
19+
test('Add third type', async () => {
20+
const testId = 'add-third-type'
21+
const result = await compareFiles(suiteId, testId)
22+
expect(result).toEqual(diffsMatcher([
23+
expect.objectContaining({
24+
action: DiffAction.add,
25+
afterDeclarationPaths: [[...commonPath, 'type', 2]],
26+
type: nonBreaking,
27+
}),
28+
]))
29+
})
30+
31+
test('Remove second type', async () => {
32+
const testId = 'remove-second-type'
33+
const result = await compareFiles(suiteId, testId)
34+
expect(result).toEqual(diffsMatcher([
35+
expect.objectContaining({
36+
action: DiffAction.remove,
37+
beforeDeclarationPaths: [[...commonPath, 'type', 1]],
38+
type: breaking,
39+
}),
40+
]))
41+
})
42+
43+
test('Remove third type', async () => {
44+
const testId = 'remove-third-type'
45+
const result = await compareFiles(suiteId, testId)
46+
expect(result).toEqual(diffsMatcher([
47+
expect.objectContaining({
48+
action: DiffAction.remove,
49+
beforeDeclarationPaths: [[...commonPath, 'type', 2]],
50+
type: breaking,
51+
}),
52+
]))
53+
})
54+
55+
test('Reorder types', async () => {
56+
const testId = 'reorder-types'
57+
const result = await compareFiles(suiteId, testId)
58+
expect(result.length).toEqual(0)
59+
})
60+
}

0 commit comments

Comments
 (0)