Skip to content

Commit a06f472

Browse files
committed
revert: feat: classification of cnahges of OAS extension for Path Item object
This reverts commit 1d97203.
1 parent 1d97203 commit a06f472

File tree

2 files changed

+54
-67
lines changed

2 files changed

+54
-67
lines changed

src/openapi/openapi3.rules.ts

Lines changed: 44 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -74,20 +74,6 @@ import { encodingParamsCalculator } from './openapi3.description.encoding'
7474
const documentAnnotationRule: CompareRules = { $: allAnnotation }
7575
const operationAnnotationRule: CompareRules = { $: allAnnotation }
7676

77-
const openApiExtensionRulesFunction: (fallbackRules: CompareRules | (() => CompareRules)) => CompareRules = (fallbackRules) => ({
78-
'/*': (ctx) => {
79-
const { key } = ctx
80-
return typeof key === 'string' && key.startsWith('x-')
81-
? {
82-
$: allUnclassified,
83-
'/**': {
84-
$: allUnclassified,
85-
},
86-
}
87-
: typeof fallbackRules === 'function' ? fallbackRules() : fallbackRules
88-
},
89-
})
90-
9177
export const openApi3Rules = (options: OpenApi3RulesOptions): CompareRules => {
9278
const requestSchemaRules = openApiSchemaRules(options)
9379
const responseSchemaRules = openApiSchemaRules({ ...options, response: true })
@@ -345,51 +331,6 @@ export const openApi3Rules = (options: OpenApi3RulesOptions): CompareRules => {
345331
},
346332
}
347333

348-
const operationCompareRules:CompareRules = {
349-
$: [nonBreaking, breaking, unclassified],
350-
'/*': operationAnnotationRule,
351-
'/tags': {
352-
...operationAnnotationRule,
353-
mapping: deepEqualsUniqueItemsArrayMappingResolver,
354-
'/*': {
355-
...operationAnnotationRule,
356-
[IGNORE_DIFFERENCE_IN_KEYS_RULE]: true,
357-
},
358-
},
359-
'/parameters': {
360-
...parametersRules,
361-
$: [nonBreaking, apihubParametersRemovalClassifyRule, breaking],
362-
mapping: paramMappingResolver(2),
363-
},
364-
'/requestBody': requestBodiesRules,
365-
'/callbacks': {
366-
'/*': {
367-
//no support?
368-
},
369-
},
370-
'/responses': responsesRules,
371-
'/deprecated': { $: allDeprecated },
372-
'/security': {
373-
$: operationSecurityClassifyRule,
374-
'/*': {
375-
$: operationSecurityItemClassifyRule,
376-
'/*': {
377-
$: allBreaking,
378-
mapping: deepEqualsUniqueItemsArrayMappingResolver,
379-
'/*': {
380-
$: [breaking, nonBreaking, breaking],
381-
ignoreKeyDifference: true,
382-
},
383-
},
384-
},
385-
},
386-
'/servers': serversRules,
387-
'/externalDocs': {
388-
$: allAnnotation,
389-
'/*': { $: allAnnotation },
390-
},
391-
}
392-
393334
return {
394335
'/openapi': documentAnnotationRule,
395336
'/info': {
@@ -405,7 +346,50 @@ export const openApi3Rules = (options: OpenApi3RulesOptions): CompareRules => {
405346
mapping: options.mode === COMPARE_MODE_OPERATION ? singleOperationPathMappingResolver : pathMappingResolver,
406347
'/summary': { $: allAnnotation },
407348
'/description': { $: allAnnotation },
408-
...openApiExtensionRulesFunction(operationCompareRules),
349+
'/*': {
350+
$: [nonBreaking, breaking, unclassified],
351+
'/*': operationAnnotationRule,
352+
'/tags': {
353+
...operationAnnotationRule,
354+
mapping: deepEqualsUniqueItemsArrayMappingResolver,
355+
'/*': {
356+
...operationAnnotationRule,
357+
[IGNORE_DIFFERENCE_IN_KEYS_RULE]: true,
358+
},
359+
},
360+
'/parameters': {
361+
...parametersRules,
362+
$: [nonBreaking, apihubParametersRemovalClassifyRule, breaking],
363+
mapping: paramMappingResolver(2),
364+
},
365+
'/requestBody': requestBodiesRules,
366+
'/callbacks': {
367+
'/*': {
368+
//no support?
369+
},
370+
},
371+
'/responses': responsesRules,
372+
'/deprecated': { $: allDeprecated },
373+
'/security': {
374+
$: operationSecurityClassifyRule,
375+
'/*': {
376+
$: operationSecurityItemClassifyRule,
377+
'/*': {
378+
$: allBreaking,
379+
mapping: deepEqualsUniqueItemsArrayMappingResolver,
380+
'/*': {
381+
$: [breaking, nonBreaking, breaking],
382+
ignoreKeyDifference: true,
383+
},
384+
},
385+
},
386+
},
387+
'/servers': serversRules,
388+
'/externalDocs': {
389+
$: allAnnotation,
390+
'/*': { $: allAnnotation },
391+
},
392+
},
409393
'/servers': serversRules,
410394
'/parameters': {
411395
...parametersRules,

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

Lines changed: 10 additions & 7 deletions
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, deprecated, DiffAction, nonBreaking, unclassified } from '../../../src'
3+
import { annotation, breaking, deprecated, DiffAction, nonBreaking } from '../../../src'
44

55
const SUITE_ID = 'general-operation-parameters'
66
const COMMON_PATH1_GET = ['paths', '/path1', 'get']
@@ -595,39 +595,42 @@ describe('Openapi3 General Operation Parameters', () => {
595595
]))
596596
})
597597

598-
test('Add custom property in path', async () => {
598+
// No changes
599+
test.skip('Add custom property in path', async () => {
599600
const testId = 'add-custom-property-in-path'
600601
const result = await compareFiles(SUITE_ID, testId)
601602
expect(result).toEqual(diffsMatcher([
602603
expect.objectContaining({
603604
action: DiffAction.add,
604605
afterDeclarationPaths: [['paths', '/pets', 'x-feature-flag']],
605-
type: unclassified,
606+
type: nonBreaking,
606607
}),
607608
]))
608609
})
609610

610-
test('Update custom property in path', async () => {
611+
// No changes
612+
test.skip('Update custom property in path', async () => {
611613
const testId = 'update-custom-property-value-in-path'
612614
const result = await compareFiles(SUITE_ID, testId)
613615
expect(result).toEqual(diffsMatcher([
614616
expect.objectContaining({
615617
action: DiffAction.replace,
616618
beforeDeclarationPaths: [['paths', '/pets', 'x-feature-flag']],
617619
afterDeclarationPaths: [['paths', '/pets', 'x-feature-flag']],
618-
type: unclassified,
620+
type: nonBreaking,
619621
}),
620622
]))
621623
})
622624

623-
test('Remove custom property in path', async () => {
625+
// No changes
626+
test.skip('Remove custom property in path', async () => {
624627
const testId = 'remove-custom-property-in-path'
625628
const result = await compareFiles(SUITE_ID, testId)
626629
expect(result).toEqual(diffsMatcher([
627630
expect.objectContaining({
628631
action: DiffAction.remove,
629632
beforeDeclarationPaths: [['paths', '/pets', 'x-feature-flag']],
630-
type: unclassified,
633+
type: nonBreaking,
631634
}),
632635
]))
633636
})

0 commit comments

Comments
 (0)