Skip to content

Commit bbebcb5

Browse files
committed
Merge branch 'release'
2 parents af1948a + 861e2e7 commit bbebcb5

File tree

11 files changed

+389
-126
lines changed

11 files changed

+389
-126
lines changed

.qubership/grand-report.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"exclusions" : [ {
3+
"t-hash" : "00000000",
4+
"f-hash" : "1a515c37cea1b7dff4a71b26f53d0f26a31704f347941387ea7f34ace0a3533c"
5+
}, {
6+
"t-hash" : "00000000",
7+
"f-hash" : "56e0a7bd05350fcb3ef8bb6577abebd0f3db832a00a0f112d1595f1a30da06ad"
8+
} ]
9+
}

package-lock.json

Lines changed: 10 additions & 10 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.2.0",
3+
"version": "2.3.0",
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": "2.3.0",
30+
"@netcracker/qubership-apihub-api-unifier": "2.4.0",
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.2.0",
35+
"@netcracker/qubership-apihub-compatibility-suites": "2.3.0",
3636
"@netcracker/qubership-apihub-graphapi": "1.0.8",
3737
"@netcracker/qubership-apihub-npm-gitflow": "3.1.0",
3838
"@types/jest": "29.5.11",

src/openapi/openapi3.rules.ts

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -388,6 +388,20 @@ export const openApi3Rules = (options: OpenApi3RulesOptions): CompareRules => {
388388
'/*': operationAnnotationRule,
389389
}
390390

391+
const pathItemObjectRules = (options: OpenApi3RulesOptions): CompareRules => ({
392+
$: pathChangeClassifyRule,
393+
mapping: options.mode === COMPARE_MODE_OPERATION ? singleOperationPathMappingResolver : pathMappingResolver,
394+
'/description': { $: allAnnotation },
395+
'/parameters': {
396+
$: [nonBreaking, breaking, breaking],
397+
mapping: paramMappingResolver(1),
398+
...parametersRules,
399+
},
400+
'/servers': serversRules,
401+
'/summary': { $: allAnnotation },
402+
'/*': operationRule,
403+
})
404+
391405
const componentsRule: CompareRules = {
392406
$: allNonBreaking,
393407
[START_NEW_COMPARE_SCOPE_RULE]: COMPARE_SCOPE_COMPONENTS,
@@ -412,6 +426,10 @@ export const openApi3Rules = (options: OpenApi3RulesOptions): CompareRules => {
412426
...requestSchemaRules,
413427
}),
414428
},
429+
'/pathItems': {
430+
$: [nonBreaking, breaking, breaking],
431+
'/*': pathItemObjectRules(options),
432+
},
415433
'/securitySchemes': {
416434
$: [breaking, nonBreaking, breaking],
417435
'/*': {
@@ -438,19 +456,7 @@ export const openApi3Rules = (options: OpenApi3RulesOptions): CompareRules => {
438456
'/paths': {
439457
$: allUnclassified,
440458
mapping: options.mode === COMPARE_MODE_OPERATION ? singleOperationPathMappingResolver : pathMappingResolver,
441-
'/*': {
442-
$: pathChangeClassifyRule,
443-
mapping: options.mode === COMPARE_MODE_OPERATION ? singleOperationPathMappingResolver : pathMappingResolver,
444-
'/description': { $: allAnnotation },
445-
'/parameters': {
446-
$: [nonBreaking, breaking, breaking],
447-
mapping: paramMappingResolver(1),
448-
...parametersRules,
449-
},
450-
'/servers': serversRules,
451-
'/summary': { $: allAnnotation },
452-
'/*': operationRule,
453-
},
459+
'/*': pathItemObjectRules(options),
454460
},
455461
'/components': componentsRule,
456462
'/security': {

test/compatibility-suites/openapi/general-operation-parameters.test.ts

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -767,3 +767,59 @@ describe('Openapi3 General Operation Parameters', () => {
767767
]))
768768
})
769769
})
770+
771+
const PATH_ITEM_PATH = [
772+
'components',
773+
'pathItems',
774+
'UserOps',
775+
]
776+
777+
describe('Openapi3.1 PathItems', () => {
778+
test('Add method in path item', async () => {
779+
const testId = 'add-method-in-path-item'
780+
const result = await compareFiles(SUITE_ID, testId)
781+
expect(result).toEqual(diffsMatcher([
782+
expect.objectContaining({
783+
action: DiffAction.add,
784+
afterDeclarationPaths: [[...PATH_ITEM_PATH, 'post']],
785+
type: nonBreaking,
786+
}),
787+
]))
788+
})
789+
790+
test('Remove unused method in path item', async () => {
791+
const testId = 'remove-unused-method-in-path-item'
792+
const result = await compareFiles(SUITE_ID, testId)
793+
expect(result).toEqual([])
794+
})
795+
796+
test('Add unused method in path item', async () => {
797+
const testId = 'add-unused-method-in-path-item'
798+
const result = await compareFiles(SUITE_ID, testId)
799+
expect(result).toEqual([])
800+
})
801+
802+
test('Remove method in path item', async () => {
803+
const testId = 'remove-method-in-path-item'
804+
const result = await compareFiles(SUITE_ID, testId)
805+
expect(result).toEqual(diffsMatcher([
806+
expect.objectContaining({
807+
action: DiffAction.remove,
808+
beforeDeclarationPaths: [[...PATH_ITEM_PATH, 'post']],
809+
type: breaking,
810+
}),
811+
]))
812+
})
813+
814+
test('Replace inline path item to ref', async () => {
815+
const testId = 'replace-inline-path-item-to-ref'
816+
const result = await compareFiles(SUITE_ID, testId)
817+
expect(result).toEqual([])
818+
})
819+
820+
test('Replace ref path item to inline', async () => {
821+
const testId = 'replace-ref-path-item-to-inline'
822+
const result = await compareFiles(SUITE_ID, testId)
823+
expect(result).toEqual([])
824+
})
825+
})

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1636,3 +1636,4 @@ describe('Openapi3 ResponseBody.Schema ', () => {
16361636
describe('Openapi31 ResponseBody.Schema', () => {
16371637
runCommonResponseSchema31Tests(SUITE_ID, RESPONSE_SCHEMA_PATH)
16381638
})
1639+

test/compatibility-suites/openapi/templates/reference-object-31.template.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ export function runReferenceObjectTests(suiteId: string, refPath: JsonPath, comp
5858

5959
test(`Change referenced ${overridenField} when overridden exists`, async () => {
6060
const testId = `change-referenced-${overridenField}-when-overridden-exists`
61-
const result = await compareFiles(suiteId, testId)
62-
expect(result.length).toEqual(0)
61+
const diffs = await compareFiles(suiteId, testId)
62+
expect(diffs).toBeEmpty()
6363
})
6464
}
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
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1101,8 +1101,8 @@ export function runCommonSchemaTests(suiteId: string, commonPath: JsonPath): voi
11011101
test('Update definition of free-form object', async () => {
11021102

11031103
const testId = 'update-definition-of-free-form-object'
1104-
const result = await compareFiles(suiteId, testId)
1105-
expect(result.length).toEqual(0)
1104+
const diffs = await compareFiles(suiteId, testId)
1105+
expect(diffs).toBeEmpty()
11061106
})
11071107

11081108
test('Add non-boolean additionalProperties', async () => {

0 commit comments

Comments
 (0)