Skip to content

Commit 9944d90

Browse files
committed
chore: merge branch 'develop' into feature/asyncapi-basic-e2e
2 parents 234a8f4 + 8996279 commit 9944d90

File tree

11 files changed

+178
-25
lines changed

11 files changed

+178
-25
lines changed

package-lock.json

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

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@netcracker/qubership-apihub-api-diff",
3-
"version": "2.5.2",
3+
"version": "2.5.3",
44
"module": "./dist/index.es.js",
55
"main": "./dist/index.cjs.js",
66
"types": "./dist/index.d.ts",
@@ -32,7 +32,7 @@
3232
"fast-equals": "4.0.3"
3333
},
3434
"devDependencies": {
35-
"@netcracker/qubership-apihub-compatibility-suites": "2.3.0",
35+
"@netcracker/qubership-apihub-compatibility-suites": "dev",
3636
"@netcracker/qubership-apihub-graphapi": "dev",
3737
"@netcracker/qubership-apihub-npm-gitflow": "3.1.0",
3838
"@types/jest": "29.5.11",

test/bugs.test.ts

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ import {
1010
} from '../src'
1111

1212
const TEST_AFTER_NORMALIZED_VALUE = Symbol('test-after-normalized-value')
13+
import { loadYamlSample } from './helper/utils'
14+
1315
import offeringQualificationBefore from './helper/resources/api-v2-offeringqualification-qualification-post/before.json'
1416
import offeringQualificationAfter from './helper/resources/api-v2-offeringqualification-qualification-post/after.json'
1517
import readDefaultValueOfRequiredBefore from './helper/resources/read-default-value-of-required-field/before.json'
@@ -52,7 +54,7 @@ import shouldReportSingleDiffWhenRequiredPropertyIsChangedForTheCombinerAfter fr
5254
import duplicateParametersBefore from './helper/resources/duplicate-parameters/before.json'
5355
import duplicateParametersAfter from './helper/resources/duplicate-parameters/after.json'
5456

55-
import { diffsMatcher } from './helper/matchers'
57+
import { diffsMatcher, expectOpenApiVersionChange } from './helper/matchers'
5658
import { TEST_DIFF_FLAG, TEST_ORIGINS_FLAG } from './helper'
5759
import { JSON_SCHEMA_NODE_SYNTHETIC_TYPE_NOTHING } from '@netcracker/qubership-apihub-api-unifier'
5860

@@ -331,4 +333,15 @@ describe('Real Data', () => {
331333
}),
332334
]))
333335
})
336+
337+
it('should not report changes for the same string pattern overriden via ref', () => {
338+
const before = loadYamlSample('uuid-pattern/before.yaml')
339+
const after = loadYamlSample('uuid-pattern/after.yaml')
340+
341+
const { diffs } = apiDiff(before, after)
342+
343+
expect(diffs).toEqual(diffsMatcher([
344+
expectOpenApiVersionChange(),
345+
]))
346+
})
334347
})

test/compatibility-suites/graphql/interface-output-type-of-root-type.test.ts

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { compareFiles, TEST_DEFAULTS_DECLARATION_PATHS } from '../utils'
22
import { diffsMatcher } from '../../helper/matchers'
3-
import { annotation, breaking, DiffAction, nonBreaking, risky } from '../../../src'
3+
import { annotation, breaking, DiffAction, nonBreaking, risky, unclassified } from '../../../src'
44
import { TEST_SPEC_TYPE_GRAPH_QL } from '@netcracker/qubership-apihub-compatibility-suites'
55
import { COMPARE_SCOPE_OUTPUT } from '../../../src/graphapi'
66

@@ -49,6 +49,25 @@ describe('GraphQL Interface Output Type of Root Type', () => {
4949
}),
5050
]))
5151
})
52+
test('Change field type of output interface from enum to string', async () => {
53+
const testId = 'change-field-type-of-output-interface-from-enum-to-string'
54+
const result = await compareFiles(SUITE_ID, testId, TEST_SPEC_TYPE_GRAPH_QL)
55+
expect(result).toEqual(diffsMatcher([
56+
expect.objectContaining({
57+
action: DiffAction.replace,
58+
//beforeDeclarationPaths: [[...COMPONENT_PATH, 'type', 'methods', 'name', 'output', 'typeDef', 'type']], // TODO: fix before declaration paths
59+
afterDeclarationPaths: [[...COMPONENT_PATH, 'type', 'methods', 'name', 'output', 'typeDef', 'type']],
60+
type: breaking,
61+
scope: COMPARE_SCOPE_OUTPUT
62+
}),
63+
expect.objectContaining({
64+
action: DiffAction.remove,
65+
// beforeDeclarationPaths: [[...ENUM_PATH]], // TODO: fix before declaration paths
66+
type: unclassified,
67+
scope: COMPARE_SCOPE_OUTPUT
68+
}),
69+
]))
70+
})
5271
test('Add new field in output interface', async () => {
5372
const testId = 'add-new-field-in-output-interface'
5473
const result = await compareFiles(SUITE_ID, testId, TEST_SPEC_TYPE_GRAPH_QL)

test/compatibility-suites/graphql/object-output-type-of-root-type.test.ts

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { compareFiles, TEST_DEFAULTS_DECLARATION_PATHS } from '../utils'
22
import { diffsMatcher } from '../../helper/matchers'
3-
import { annotation, breaking, DiffAction, nonBreaking, risky } from '../../../src'
3+
import { annotation, breaking, DiffAction, nonBreaking, risky, unclassified } from '../../../src'
44
import { TEST_SPEC_TYPE_GRAPH_QL } from '@netcracker/qubership-apihub-compatibility-suites'
55
import { COMPARE_SCOPE_OUTPUT } from '../../../src/graphapi'
66

@@ -49,6 +49,25 @@ describe('GraphQL Object Output Type of Root Type', () => {
4949
}),
5050
]))
5151
})
52+
test('Change field type of output object type from enum to string', async () => {
53+
const testId = 'change-field-type-of-output-object-type-from-enum-to-string'
54+
const result = await compareFiles(SUITE_ID, testId, TEST_SPEC_TYPE_GRAPH_QL)
55+
expect(result).toEqual(diffsMatcher([
56+
expect.objectContaining({
57+
action: DiffAction.replace,
58+
//beforeDeclarationPaths: [[...COMPONENT_PATH, 'type', 'methods', 'name', 'output', 'typeDef', 'type']], // TODO: fix before declaration paths
59+
afterDeclarationPaths: [[...COMPONENT_PATH, 'type', 'methods', 'name', 'output', 'typeDef', 'type']],
60+
type: breaking,
61+
scope: COMPARE_SCOPE_OUTPUT
62+
}),
63+
expect.objectContaining({
64+
action: DiffAction.remove,
65+
// beforeDeclarationPaths: [[...ENUM_PATH]], // TODO: fix before declaration paths
66+
type: unclassified,
67+
scope: COMPARE_SCOPE_OUTPUT
68+
}),
69+
]))
70+
})
5271
test('Add new field in output object type', async () => {
5372
const testId = 'add-new-field-in-output-object-type'
5473
const result = await compareFiles(SUITE_ID, testId, TEST_SPEC_TYPE_GRAPH_QL)

test/compatibility-suites/graphql/scalar-output-type-of-root-type.test.ts

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { compareFiles, TEST_DEFAULTS_DECLARATION_PATHS } from '../utils'
22
import { diffsMatcher } from '../../helper/matchers'
3-
import { annotation, breaking, DiffAction, nonBreaking, risky } from '../../../src'
3+
import { annotation, breaking, DiffAction, nonBreaking, risky, unclassified } from '../../../src'
44
import { TEST_SPEC_TYPE_GRAPH_QL } from '@netcracker/qubership-apihub-compatibility-suites'
55
import { COMPARE_SCOPE_OUTPUT } from '../../../src/graphapi'
66

@@ -50,6 +50,25 @@ describe('GraphQL Scalar output type of root type', () => {
5050
}),
5151
]))
5252
})
53+
test('Change output type from enum to string', async () => {
54+
const testId = 'change-output-type-from-enum-to-string'
55+
const result = await compareFiles(SUITE_ID, testId, TEST_SPEC_TYPE_GRAPH_QL)
56+
expect(result).toEqual(diffsMatcher([
57+
expect.objectContaining({
58+
action: DiffAction.replace,
59+
// beforeDeclarationPaths: [[...QUERY_PATH, 'typeDef', 'type']], // TODO: fix before declaration paths
60+
afterDeclarationPaths: [[...QUERY_PATH, 'typeDef', 'type']],
61+
type: breaking,
62+
scope: COMPARE_SCOPE_OUTPUT
63+
}),
64+
expect.objectContaining({
65+
action: DiffAction.remove,
66+
// beforeDeclarationPaths: [[...ENUM_PATH]], // TODO: fix before declaration paths
67+
type: unclassified,
68+
scope: COMPARE_SCOPE_OUTPUT
69+
}),
70+
]))
71+
})
5372
test('Add list type for output type', async () => {
5473
const testId = 'add-list-type-for-output-type'
5574
const result = await compareFiles(SUITE_ID, testId, TEST_SPEC_TYPE_GRAPH_QL)

test/helper/matchers.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,3 +59,13 @@ export function diffsMatcher(
5959
): DiffMatcher {
6060
return expect.toIncludeSameMembers(expected)
6161
}
62+
63+
export const expectOpenApiVersionChange = (fromVersion: string = '3.0.4', toVersion: string = '3.1.0') =>
64+
expect.objectContaining({
65+
action: 'replace',
66+
afterDeclarationPaths: [['openapi']],
67+
afterValue: toVersion,
68+
beforeDeclarationPaths: [['openapi']],
69+
beforeValue: fromVersion,
70+
type: 'annotation',
71+
})
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
openapi: 3.1.0
2+
info:
3+
title: Sample API Service
4+
version: '1.0'
5+
description: Sample API Service
6+
servers:
7+
- url: /
8+
paths:
9+
/somepath/{id}:
10+
delete:
11+
summary: Delete resource
12+
description: This operation deletes a resource by id
13+
parameters:
14+
- name: id
15+
in: path
16+
description: Resource identifier
17+
required: true
18+
schema:
19+
$ref: '#/components/schemas/UUID'
20+
type: string
21+
format: uuid
22+
pattern: '[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}'
23+
responses:
24+
'204':
25+
description: Success
26+
content:
27+
application/json:
28+
schema:
29+
type: object
30+
security:
31+
- OAuth2 Access Token: []
32+
components:
33+
schemas:
34+
UUID:
35+
type: string
36+
format: uuid
37+
pattern: '[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}'
38+
securitySchemes:
39+
OAuth2 Access Token:
40+
type: apiKey
41+
name: Authorization
42+
in: header
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
openapi: 3.0.4
2+
info:
3+
title: Sample API Service
4+
version: '1.0'
5+
description: Sample API Service
6+
servers:
7+
- url: /
8+
paths:
9+
/somepath/{id}:
10+
delete:
11+
summary: Delete resource
12+
description: This operation deletes a resource by id
13+
parameters:
14+
- name: id
15+
in: path
16+
description: Resource identifier
17+
required: true
18+
schema:
19+
$ref: '#/components/schemas/UUID'
20+
responses:
21+
'204':
22+
description: Success
23+
content:
24+
application/json:
25+
schema:
26+
type: object
27+
security:
28+
- OAuth2 Access Token: []
29+
components:
30+
schemas:
31+
UUID:
32+
type: string
33+
format: uuid
34+
pattern: >-
35+
[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}
36+
securitySchemes:
37+
OAuth2 Access Token:
38+
type: apiKey
39+
name: Authorization
40+
in: header

test/helper/utils.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import { buildSchema } from "graphql"
22
import { buildFromSchema, GraphApiSchema } from '@netcracker/qubership-apihub-graphapi'
3-
import { readFileSync } from 'fs'
4-
import { load } from 'js-yaml'
3+
import { readFileSync } from "fs"
4+
import { loadYaml } from '@netcracker/qubership-apihub-api-unifier'
55

66
export function loadYamlSample(path: string) {
7-
return load(readFileSync(`./test/helper/resources/${path}`).toString())
7+
return loadYaml(readFileSync(`./test/helper/resources/${path}`).toString())
88
}
99

1010
export function takeIf(value: object, condition: boolean): object {

0 commit comments

Comments
 (0)