Skip to content

Commit 974dc33

Browse files
committed
feat: classify add-enum-value and remove-enum in response as semiBreaking
1 parent 6500d01 commit 974dc33

File tree

3 files changed

+10
-5
lines changed

3 files changed

+10
-5
lines changed

src/jsonSchema/jsonSchema.classify.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import {
44
breakingIfAfterTrue,
55
nonBreaking,
66
PARENT_JUMP,
7+
semiBreaking,
78
strictResolveValueFromContext,
89
unclassified,
910
} from '../core'
@@ -100,6 +101,9 @@ export const enumClassifyRule: ClassifyRule = [
100101
({ before }) => (isNotEmptyArray(before.parent) ? nonBreaking : breaking),
101102
({ after }) => (isNotEmptyArray(after.parent) ? breaking : nonBreaking),
102103
breaking,
104+
({ before }) => (isNotEmptyArray(before.parent) ? semiBreaking : nonBreaking),
105+
({ after }) => (isNotEmptyArray(after.parent) ? nonBreaking: semiBreaking ),
106+
nonBreaking
103107
]
104108

105109
export const nonInvertible = (rule: ClassifyRule): ClassifyRule => {

src/jsonSchema/jsonSchema.rules.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import {
2020
transformCompareRules,
2121
unclassified,
2222
deepEqualsUniqueItemsArrayMappingResolver,
23+
semiBreaking,
2324
} from '../core'
2425
import {
2526
enumClassifyRule,
@@ -122,7 +123,7 @@ export const jsonSchemaRules = ({
122123
'/default': simpleRule([nonBreaking, breaking, breaking], resolveSchemaDescriptionTemplates('default value')),
123124

124125
'/enum': {
125-
$: [breaking, nonBreaking, breaking],
126+
$: [breaking, nonBreaking, breaking, nonBreaking, semiBreaking, nonBreaking],
126127
mapping: deepEqualsUniqueItemsArrayMappingResolver,
127128
'/*': ({ key, value }) => {
128129
if (!isNumber(key)) {

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { compareFiles, compareFilesWithMerge, TEST_DEFAULTS_DECLARATION_PATHS } from '../utils'
22
import { diffsMatcher } from '../../helper/matchers'
3-
import { annotation, breaking, DiffAction, nonBreaking } from '../../../src'
3+
import { annotation, breaking, DiffAction, nonBreaking, semiBreaking } from '../../../src'
44
import { JSON_SCHEMA_NODE_SYNTHETIC_TYPE_ANY } from '@netcracker/qubership-apihub-api-unifier'
55

66
const SUITE_ID = 'response-body-schema'
@@ -160,7 +160,7 @@ describe('Openapi3 ResponseBody.Schema ', () => {
160160
expect.objectContaining({
161161
action: DiffAction.remove,
162162
beforeDeclarationPaths: [[...RESPONSE_SCHEMA_PATH, 'enum']],
163-
type: breaking,
163+
type: semiBreaking,
164164
}),
165165
]))
166166
})
@@ -172,7 +172,7 @@ describe('Openapi3 ResponseBody.Schema ', () => {
172172
expect.objectContaining({
173173
action: DiffAction.add,
174174
afterDeclarationPaths: [[...RESPONSE_SCHEMA_PATH, 'enum', 2]],
175-
type: breaking,
175+
type: semiBreaking,
176176
}),
177177
]))
178178
})
@@ -189,7 +189,7 @@ describe('Openapi3 ResponseBody.Schema ', () => {
189189
expect.objectContaining({
190190
action: DiffAction.add,
191191
afterDeclarationPaths: [[...RESPONSE_SCHEMA_PATH, 'enum', 1]],
192-
type: breaking,
192+
type: semiBreaking,
193193
}),
194194
],
195195
))

0 commit comments

Comments
 (0)