Skip to content

Commit 5985c8e

Browse files
committed
feat: Review
1 parent 85987dc commit 5985c8e

File tree

7 files changed

+174
-206
lines changed

7 files changed

+174
-206
lines changed

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

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { runAddRemoveDefaultValuesSchemaTests, runCommonSchemaTests } from './templates/schema'
22
import { runCommonSchema31Tests } from './templates/schema31'
3-
import { runSiblingPropertiesSchema } from './templates/sibling-properties-schema.template'
43

54
const SUITE_ID = 'parameters-schema'
65

@@ -22,7 +21,3 @@ describe('Openapi3 Parameters Schema', () => {
2221
describe('Openapi31 Parameters Schema', () => {
2322
runCommonSchema31Tests(SUITE_ID, PARAMETERS_SCHEMA_PATH)
2423
})
25-
26-
describe('Openapi31 Parameters. Sibling properties Schema', () => {
27-
runSiblingPropertiesSchema(SUITE_ID, PARAMETERS_SCHEMA_PATH)
28-
})

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

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { runAddRemoveDefaultValuesSchemaTests, runCommonSchemaTests } from './templates/schema'
22
import { runCommonSchema31Tests } from './templates/schema31'
3-
import { runSiblingPropertiesSchema } from './templates/sibling-properties-schema.template'
43

54
const SUITE_ID = 'request-body-schema'
65

@@ -23,7 +22,3 @@ describe('Openapi3 Request Body Schema', () => {
2322
describe('Openapi31 Request Body Schema', () => {
2423
runCommonSchema31Tests(SUITE_ID, REQUEST_SCHEMA_PATH)
2524
})
26-
27-
describe('Openapi31 Request Body. Sibling properties Schema', () => {
28-
runSiblingPropertiesSchema(SUITE_ID, REQUEST_SCHEMA_PATH)
29-
})

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

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import { annotation, breaking, DiffAction, nonBreaking, risky } from '../../../s
44
import { JSON_SCHEMA_NODE_SYNTHETIC_TYPE_ANY } from '@netcracker/qubership-apihub-api-unifier'
55
import { runAddRemoveDefaultValuesSchemaTests } from './templates/schema'
66
import { runCommonResponseSchema31Tests } from './templates/response-schema31'
7-
import { runResponseSiblingPropertiesSchema } from './templates/sibling-properties-schema.template'
87

98
const SUITE_ID = 'response-body-schema'
109

@@ -1638,6 +1637,3 @@ describe('Openapi31 ResponseBody.Schema', () => {
16381637
runCommonResponseSchema31Tests(SUITE_ID, RESPONSE_SCHEMA_PATH)
16391638
})
16401639

1641-
describe('Openapi31 ResponseBody. Sibling properties Schema', () => {
1642-
runResponseSiblingPropertiesSchema(SUITE_ID, RESPONSE_SCHEMA_PATH)
1643-
})

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

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import { runCommonResponseSchema31Tests } from './templates/response-schema31'
2-
import { runResponseSiblingPropertiesSchema } from './templates/sibling-properties-schema.template'
32

43
const SUITE_ID = 'response-headers-schema'
54

@@ -17,7 +16,3 @@ const RESPONSE_HEADERS_SCHEMA_PATH = [
1716
describe('Openapi31 ResponseHeaders.Schema', () => {
1817
runCommonResponseSchema31Tests(SUITE_ID, RESPONSE_HEADERS_SCHEMA_PATH)
1918
})
20-
21-
describe('Openapi31 ResponseHeaders. Sibling properties Schema', () => {
22-
runResponseSiblingPropertiesSchema(SUITE_ID, RESPONSE_HEADERS_SCHEMA_PATH)
23-
})
Lines changed: 101 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,60 +1,113 @@
11
import { compareFiles } from '../../utils'
22
import { JsonPath } from '@netcracker/qubership-apihub-json-crawl'
3-
import { breaking, DiffAction, nonBreaking } from '../../../../src'
3+
import { annotation, breaking, DiffAction, nonBreaking, risky } from '../../../../src'
44
import { diffsMatcher } from '../../../helper/matchers'
55

6+
const COMPONENTS_SCHEMAS = ['components', 'schemas']
7+
68
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-
})
9+
describe('Union type', () => {
10+
test('Add union type', async () => {
11+
const testId = 'add-union-type'
12+
const result = await compareFiles(suiteId, testId)
13+
expect(result).toEqual(diffsMatcher([
14+
expect.objectContaining({
15+
action: DiffAction.add,
16+
afterDeclarationPaths: [[...commonPath, 'type', 1]],
17+
type: breaking,
18+
}),
19+
]))
20+
})
1821

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-
})
22+
test('Add null to union type', async () => {
23+
const testId = 'add-null-to-union-type'
24+
const result = await compareFiles(suiteId, testId)
25+
expect(result).toEqual(diffsMatcher([
26+
expect.objectContaining({
27+
action: DiffAction.add,
28+
afterDeclarationPaths: [[...commonPath, 'type', 2]],
29+
type: breaking,
30+
}),
31+
]))
32+
})
3033

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-
})
34+
test('Remove union type', async () => {
35+
const testId = 'remove-union-type'
36+
const result = await compareFiles(suiteId, testId)
37+
expect(result).toEqual(diffsMatcher([
38+
expect.objectContaining({
39+
action: DiffAction.remove,
40+
beforeDeclarationPaths: [[...commonPath, 'type', 1]],
41+
type: nonBreaking,
42+
}),
43+
]))
44+
})
4245

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-
]))
46+
test('Remove null from union type', async () => {
47+
const testId = 'remove-null-from-union-type'
48+
const result = await compareFiles(suiteId, testId)
49+
expect(result).toEqual(diffsMatcher([
50+
expect.objectContaining({
51+
action: DiffAction.remove,
52+
beforeDeclarationPaths: [[...commonPath, 'type', 2]],
53+
type: nonBreaking,
54+
}),
55+
]))
56+
})
57+
58+
test('Reorder types in union type', async () => {
59+
const testId = 'reorder-types-in-union-type'
60+
const result = await compareFiles(suiteId, testId)
61+
expect(result).toBeEmpty()
62+
})
5363
})
5464

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()
65+
describe('$ref sibling properties', () => {
66+
test('Add sibling description for ref', async () => {
67+
const testId = 'add-sibling-description-for-ref'
68+
const result = await compareFiles(suiteId, testId)
69+
expect(result).toEqual(diffsMatcher([
70+
expect.objectContaining({
71+
action: DiffAction.replace,
72+
afterDeclarationPaths: [[...commonPath, 'description']],
73+
beforeDeclarationPaths: [[...COMPONENTS_SCHEMAS, 'Pet', 'description']],
74+
type: annotation,
75+
}),
76+
]))
77+
})
78+
79+
test('Change sibling enum for ref', async () => {
80+
const testId = 'change-sibling-enum-for-ref'
81+
const diffs = await compareFiles(suiteId, testId)
82+
expect(diffs).toBeEmpty()
83+
})
84+
85+
test('Change referenced enum when sibling exists for ref', async () => {
86+
const testId = 'change-referenced-enum-when-sibling-exists-for-ref'
87+
const result = await compareFiles(suiteId, testId)
88+
expect(result).toEqual(diffsMatcher([
89+
expect.objectContaining({
90+
action: DiffAction.add,
91+
afterDeclarationPaths: [
92+
[...COMPONENTS_SCHEMAS, 'Color', 'enum', 1],
93+
[...commonPath, 'enum', 1],
94+
],
95+
type: risky,
96+
}),
97+
]))
98+
})
99+
100+
test('Remove sibling maxLength for ref', async () => {
101+
const testId = 'remove-sibling-maxLength-for-ref'
102+
const result = await compareFiles(suiteId, testId)
103+
expect(result).toEqual(diffsMatcher([
104+
expect.objectContaining({
105+
action: DiffAction.replace,
106+
beforeDeclarationPaths: [[...commonPath, 'maxLength']],
107+
afterDeclarationPaths: [[...COMPONENTS_SCHEMAS, 'Color', 'maxLength']],
108+
type: breaking,
109+
}),
110+
]))
111+
})
59112
})
60113
}
Lines changed: 73 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,60 +1,85 @@
11
import { compareFiles } from '../../utils'
22
import { JsonPath } from '@netcracker/qubership-apihub-json-crawl'
3-
import { breaking, DiffAction, nonBreaking } from '../../../../src'
3+
import { annotation, breaking, DiffAction, nonBreaking } from '../../../../src'
44
import { diffsMatcher } from '../../../helper/matchers'
55

6+
const COMPONENTS_SCHEMAS = ['components', 'schemas']
7+
68
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-
})
9+
describe('Union type', () => {
10+
test('Add union type', async () => {
11+
const testId = 'add-union-type'
12+
const result = await compareFiles(suiteId, testId)
13+
expect(result).toEqual(diffsMatcher([
14+
expect.objectContaining({
15+
action: DiffAction.add,
16+
afterDeclarationPaths: [[...commonPath, 'type', 1]],
17+
type: nonBreaking,
18+
}),
19+
]))
20+
})
1821

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-
})
22+
test('Add null to union type', async () => {
23+
const testId = 'add-null-to-union-type'
24+
const result = await compareFiles(suiteId, testId)
25+
expect(result).toEqual(diffsMatcher([
26+
expect.objectContaining({
27+
action: DiffAction.add,
28+
afterDeclarationPaths: [[...commonPath, 'type', 2]],
29+
type: nonBreaking,
30+
}),
31+
]))
32+
})
3033

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-
})
34+
test('Remove union type', async () => {
35+
const testId = 'remove-union-type'
36+
const result = await compareFiles(suiteId, testId)
37+
expect(result).toEqual(diffsMatcher([
38+
expect.objectContaining({
39+
action: DiffAction.remove,
40+
beforeDeclarationPaths: [[...commonPath, 'type', 1]],
41+
type: breaking,
42+
}),
43+
]))
44+
})
45+
46+
test('Remove null from union type', async () => {
47+
const testId = 'remove-null-from-union-type'
48+
const result = await compareFiles(suiteId, testId)
49+
expect(result).toEqual(diffsMatcher([
50+
expect.objectContaining({
51+
action: DiffAction.remove,
52+
beforeDeclarationPaths: [[...commonPath, 'type', 2]],
53+
type: breaking,
54+
}),
55+
]))
56+
})
4257

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-
]))
58+
test('Reorder types in union type', async () => {
59+
const testId = 'reorder-types-in-union-type'
60+
const result = await compareFiles(suiteId, testId)
61+
expect(result).toBeEmpty()
62+
})
5363
})
5464

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()
65+
describe('$ref sibling properties', () => {
66+
test('Add sibling description for ref', async () => {
67+
const testId = 'add-sibling-description-for-ref'
68+
const result = await compareFiles(suiteId, testId)
69+
expect(result).toEqual(diffsMatcher([
70+
expect.objectContaining({
71+
action: DiffAction.replace,
72+
afterDeclarationPaths: [[...commonPath, 'description']],
73+
beforeDeclarationPaths: [[...COMPONENTS_SCHEMAS, 'Pet', 'description']],
74+
type: annotation,
75+
}),
76+
]))
77+
})
78+
79+
test('Change sibling enum for ref', async () => {
80+
const testId = 'change-sibling-enum-for-ref'
81+
const diffs = await compareFiles(suiteId, testId)
82+
expect(diffs).toBeEmpty()
83+
})
5984
})
6085
}

0 commit comments

Comments
 (0)