diff --git a/src/jsonSchema/jsonSchema.classify.ts b/src/jsonSchema/jsonSchema.classify.ts index 462bf1c..c69af2b 100644 --- a/src/jsonSchema/jsonSchema.classify.ts +++ b/src/jsonSchema/jsonSchema.classify.ts @@ -4,6 +4,7 @@ import { breakingIfAfterTrue, nonBreaking, PARENT_JUMP, + semiBreaking, strictResolveValueFromContext, unclassified, } from '../core' @@ -100,6 +101,9 @@ export const enumClassifyRule: ClassifyRule = [ ({ before }) => (isNotEmptyArray(before.parent) ? nonBreaking : breaking), ({ after }) => (isNotEmptyArray(after.parent) ? breaking : nonBreaking), breaking, + ({ before }) => (isNotEmptyArray(before.parent) ? semiBreaking : nonBreaking), + ({ after }) => (isNotEmptyArray(after.parent) ? nonBreaking: semiBreaking ), + nonBreaking ] export const nonInvertible = (rule: ClassifyRule): ClassifyRule => { diff --git a/src/jsonSchema/jsonSchema.rules.ts b/src/jsonSchema/jsonSchema.rules.ts index 861aa48..876b1bd 100644 --- a/src/jsonSchema/jsonSchema.rules.ts +++ b/src/jsonSchema/jsonSchema.rules.ts @@ -20,6 +20,7 @@ import { transformCompareRules, unclassified, deepEqualsUniqueItemsArrayMappingResolver, + semiBreaking, } from '../core' import { enumClassifyRule, @@ -122,7 +123,7 @@ export const jsonSchemaRules = ({ '/default': simpleRule([nonBreaking, breaking, breaking], resolveSchemaDescriptionTemplates('default value')), '/enum': { - $: [breaking, nonBreaking, breaking], + $: [breaking, nonBreaking, breaking, nonBreaking, semiBreaking, nonBreaking], mapping: deepEqualsUniqueItemsArrayMappingResolver, '/*': ({ key, value }) => { if (!isNumber(key)) { diff --git a/test/compatibility-suites/openapi/response-body-schema.test.ts b/test/compatibility-suites/openapi/response-body-schema.test.ts index 308a4a2..6c9b2bc 100644 --- a/test/compatibility-suites/openapi/response-body-schema.test.ts +++ b/test/compatibility-suites/openapi/response-body-schema.test.ts @@ -1,6 +1,6 @@ import { compareFiles, compareFilesWithMerge, TEST_DEFAULTS_DECLARATION_PATHS } from '../utils' import { diffsMatcher } from '../../helper/matchers' -import { annotation, breaking, DiffAction, nonBreaking } from '../../../src' +import { annotation, breaking, DiffAction, nonBreaking, semiBreaking } from '../../../src' import { JSON_SCHEMA_NODE_SYNTHETIC_TYPE_ANY } from '@netcracker/qubership-apihub-api-unifier' const SUITE_ID = 'response-body-schema' @@ -160,7 +160,7 @@ describe('Openapi3 ResponseBody.Schema ', () => { expect.objectContaining({ action: DiffAction.remove, beforeDeclarationPaths: [[...RESPONSE_SCHEMA_PATH, 'enum']], - type: breaking, + type: semiBreaking, }), ])) }) @@ -172,7 +172,7 @@ describe('Openapi3 ResponseBody.Schema ', () => { expect.objectContaining({ action: DiffAction.add, afterDeclarationPaths: [[...RESPONSE_SCHEMA_PATH, 'enum', 2]], - type: breaking, + type: semiBreaking, }), ])) }) @@ -189,7 +189,7 @@ describe('Openapi3 ResponseBody.Schema ', () => { expect.objectContaining({ action: DiffAction.add, afterDeclarationPaths: [[...RESPONSE_SCHEMA_PATH, 'enum', 1]], - type: breaking, + type: semiBreaking, }), ], ))