Skip to content

Commit 113c054

Browse files
committed
chore: merge branch 'develop' into feature/default-values
2 parents 78f2495 + 0bc0eae commit 113c054

File tree

13 files changed

+334
-18
lines changed

13 files changed

+334
-18
lines changed

package-lock.json

Lines changed: 9 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@netcracker/qubership-apihub-api-diff",
3-
"version": "2.0.2",
3+
"version": "2.0.3",
44
"module": "./dist/index.es.js",
55
"main": "./dist/index.cjs.js",
66
"types": "./dist/index.d.ts",
@@ -27,12 +27,12 @@
2727
"update-lock-file": "update-lock-file @netcracker"
2828
},
2929
"dependencies": {
30-
"@netcracker/qubership-apihub-api-unifier": "feature-default-values",
30+
"@netcracker/qubership-apihub-api-unifier": "dev",
3131
"@netcracker/qubership-apihub-json-crawl": "1.0.4",
3232
"fast-equals": "4.0.3"
3333
},
3434
"devDependencies": {
35-
"@netcracker/qubership-apihub-compatibility-suites": "feature-default-values",
35+
"@netcracker/qubership-apihub-compatibility-suites": "dev",
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: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { runAddRemoveDefaultValuesSchemaTests, runCommonSchemaTests } from './templates/schema'
2+
import { runCommonSchema31Tests } from './templates/schema31'
23

34
const SUITE_ID = 'parameters-schema'
45

@@ -16,3 +17,7 @@ describe('Openapi3 Parameters Schema', () => {
1617

1718
runAddRemoveDefaultValuesSchemaTests(SUITE_ID)
1819
})
20+
21+
describe('Openapi31 Parameters Schema', () => {
22+
runCommonSchema31Tests(SUITE_ID, PARAMETERS_SCHEMA_PATH)
23+
})

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

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

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

@@ -17,3 +18,7 @@ describe('Openapi3 Request Body Schema', () => {
1718

1819
runAddRemoveDefaultValuesSchemaTests(SUITE_ID)
1920
})
21+
22+
describe('Openapi31 Request Body Schema', () => {
23+
runCommonSchema31Tests(SUITE_ID, REQUEST_SCHEMA_PATH)
24+
})

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

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { diffsMatcher } from '../../helper/matchers'
33
import { annotation, breaking, DiffAction, nonBreaking, risky } from '../../../src'
44
import { JSON_SCHEMA_NODE_SYNTHETIC_TYPE_ANY } from '@netcracker/qubership-apihub-api-unifier'
55
import { runAddRemoveDefaultValuesSchemaTests } from './templates/schema'
6+
import { runCommonResponseSchema31Tests } from './templates/response-schema31'
67

78
const SUITE_ID = 'response-body-schema'
89

@@ -138,7 +139,7 @@ describe('Openapi3 ResponseBody.Schema ', () => {
138139
afterDeclarationPaths: TEST_DEFAULTS_DECLARATION_PATHS,
139140
type: nonBreaking,
140141
}),
141-
]
142+
],
142143
))
143144
})
144145

@@ -305,7 +306,7 @@ describe('Openapi3 ResponseBody.Schema ', () => {
305306
beforeDeclarationPaths: [[...RESPONSE_SCHEMA_PATH, 'properties', 'option2', 'minLength']],
306307
afterDeclarationPaths: TEST_DEFAULTS_DECLARATION_PATHS,
307308
type: breaking,
308-
})
309+
}),
309310
]))
310311
})
311312

@@ -694,7 +695,7 @@ describe('Openapi3 ResponseBody.Schema ', () => {
694695
beforeDeclarationPaths: [[...RESPONSE_SCHEMA_PATH, 'properties', 'option1', 'minItems']],
695696
afterDeclarationPaths: [[...RESPONSE_SCHEMA_PATH, 'properties', 'option1', 'minItems']],
696697
type: nonBreaking,
697-
})
698+
}),
698699
]))
699700
})
700701

@@ -739,7 +740,7 @@ describe('Openapi3 ResponseBody.Schema ', () => {
739740
beforeDeclarationPaths: [[...RESPONSE_SCHEMA_PATH, 'properties', 'option1', 'minItems']],
740741
afterDeclarationPaths: [[...RESPONSE_SCHEMA_PATH, 'properties', 'option1', 'minItems']],
741742
type: breaking,
742-
})
743+
}),
743744
]))
744745
})
745746

@@ -1021,7 +1022,7 @@ describe('Openapi3 ResponseBody.Schema ', () => {
10211022
beforeDeclarationPaths: TEST_DEFAULTS_DECLARATION_PATHS,
10221023
afterDeclarationPaths: [[...RESPONSE_SCHEMA_PATH, 'properties', 'option2', 'minProperties']],
10231024
type: nonBreaking,
1024-
})
1025+
}),
10251026
]))
10261027
})
10271028

@@ -1066,7 +1067,7 @@ describe('Openapi3 ResponseBody.Schema ', () => {
10661067
beforeDeclarationPaths: [[...RESPONSE_SCHEMA_PATH, 'properties', 'option2', 'minProperties']],
10671068
afterDeclarationPaths: TEST_DEFAULTS_DECLARATION_PATHS,
10681069
type: breaking,
1069-
})
1070+
}),
10701071
]))
10711072
})
10721073

@@ -1631,3 +1632,7 @@ describe('Openapi3 ResponseBody.Schema ', () => {
16311632

16321633
runAddRemoveDefaultValuesSchemaTests(SUITE_ID)
16331634
})
1635+
1636+
describe('Openapi31 ResponseBody.Schema', () => {
1637+
runCommonResponseSchema31Tests(SUITE_ID, RESPONSE_SCHEMA_PATH)
1638+
})
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import { runCommonResponseSchema31Tests } from './templates/response-schema31'
2+
3+
const SUITE_ID = 'response-headers-schema'
4+
5+
const RESPONSE_HEADERS_SCHEMA_PATH = [
6+
'paths',
7+
'/path1',
8+
'post',
9+
'responses',
10+
'200',
11+
'headers',
12+
'X-Header-1',
13+
'schema',
14+
]
15+
16+
describe('Openapi31 ResponseHeaders.Schema', () => {
17+
runCommonResponseSchema31Tests(SUITE_ID, RESPONSE_HEADERS_SCHEMA_PATH)
18+
})
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 runCommonResponseSchema31Tests(suiteId: string, commonPath: JsonPath): void {
7+
test('Add union type', async () => {
8+
const testId = 'add-union-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: breaking,
15+
}),
16+
]))
17+
})
18+
19+
test('Add null to union type', async () => {
20+
const testId = 'add-null-to-union-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: breaking,
27+
}),
28+
]))
29+
})
30+
31+
test('Remove union type', async () => {
32+
const testId = 'remove-union-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: nonBreaking,
39+
}),
40+
]))
41+
})
42+
43+
test('Remove null from union type', async () => {
44+
const testId = 'remove-null-from-union-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: nonBreaking,
51+
}),
52+
]))
53+
})
54+
55+
test('Reorder types in union type', async () => {
56+
const testId = 'reorder-types-in-union-type'
57+
const result = await compareFiles(suiteId, testId)
58+
expect(result).toBeEmpty()
59+
})
60+
}
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 union type', async () => {
8+
const testId = 'add-union-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 null to union type', async () => {
20+
const testId = 'add-null-to-union-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 union type', async () => {
32+
const testId = 'remove-union-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 null from union type', async () => {
44+
const testId = 'remove-null-from-union-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 in union type', async () => {
56+
const testId = 'reorder-types-in-union-type'
57+
const result = await compareFiles(suiteId, testId)
58+
expect(result).toBeEmpty()
59+
})
60+
}
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+
"number"
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": "number"
18+
}
19+
]
20+
}
21+
}
22+
}
23+
}
24+
}
25+
}
26+
}
27+
}
28+
}

0 commit comments

Comments
 (0)