Skip to content

Commit d1e3bcc

Browse files
committed
feat: add compatibility suite tests for schema default values
1 parent 7103e8f commit d1e3bcc

File tree

4 files changed

+73
-2
lines changed

4 files changed

+73
-2
lines changed

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { runCommonSchemaTests } from './templates/schema'
1+
import { runAddRemoveDefaultValuesSchemaTests, runCommonSchemaTests } from './templates/schema'
22

33
const SUITE_ID = 'parameters-schema'
44

@@ -13,4 +13,6 @@ const PARAMETERS_SCHEMA_PATH = [
1313

1414
describe('Openapi3 Parameters Schema', () => {
1515
runCommonSchemaTests(SUITE_ID, PARAMETERS_SCHEMA_PATH)
16+
17+
runAddRemoveDefaultValuesSchemaTests(SUITE_ID)
1618
})

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { runCommonSchemaTests } from './templates/schema'
1+
import { runAddRemoveDefaultValuesSchemaTests, runCommonSchemaTests } from './templates/schema'
22

33
const SUITE_ID = 'request-body-schema'
44

@@ -15,4 +15,5 @@ const REQUEST_SCHEMA_PATH = [
1515
describe('Openapi3 Request Body Schema', () => {
1616
runCommonSchemaTests(SUITE_ID, REQUEST_SCHEMA_PATH)
1717

18+
runAddRemoveDefaultValuesSchemaTests(SUITE_ID)
1819
})

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { compareFiles, compareFilesWithMerge, TEST_DEFAULTS_DECLARATION_PATHS }
22
import { diffsMatcher } from '../../helper/matchers'
33
import { annotation, breaking, DiffAction, nonBreaking, risky } from '../../../src'
44
import { JSON_SCHEMA_NODE_SYNTHETIC_TYPE_ANY } from '@netcracker/qubership-apihub-api-unifier'
5+
import { runAddRemoveDefaultValuesSchemaTests } from './templates/schema'
56

67
const SUITE_ID = 'response-body-schema'
78

@@ -1627,4 +1628,6 @@ describe('Openapi3 ResponseBody.Schema ', () => {
16271628
}),
16281629
]))
16291630
})
1631+
1632+
runAddRemoveDefaultValuesSchemaTests(SUITE_ID)
16301633
})

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

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1609,3 +1609,68 @@ export function runCommonSchemaTests(suiteId: string, commonPath: JsonPath): voi
16091609
})
16101610
})
16111611
}
1612+
1613+
export function runAddRemoveDefaultValuesSchemaTests(suiteId: string): void {
1614+
describe('Add/remove default values', () => {
1615+
1616+
test('Add minItems with default value for array property', async () => {
1617+
const testId = 'add-minItems-with-default-value-for-array-property'
1618+
const result = await compareFiles(suiteId, testId)
1619+
expect(result).toEqual([])
1620+
})
1621+
1622+
test('Remove minItems with default value for array property', async () => {
1623+
const testId = 'remove-minItems-with-default-value-for-array-property'
1624+
const result = await compareFiles(suiteId, testId)
1625+
expect(result).toEqual([])
1626+
})
1627+
1628+
test('Add uniqueItems with default value for array property', async () => {
1629+
const testId = 'add-uniqueItems-with-default-value-for-array-property'
1630+
const result = await compareFiles(suiteId, testId)
1631+
expect(result).toEqual([])
1632+
})
1633+
1634+
test('Remove uniqueItems with default value for array property', async () => {
1635+
const testId = 'remove-uniqueItems-with-default-value-for-array-property'
1636+
const result = await compareFiles(suiteId, testId)
1637+
expect(result).toEqual([])
1638+
})
1639+
1640+
test('Add minProperties with default value for object property', async () => {
1641+
const testId = 'add-minProperties-with-default-value-for-object-property'
1642+
const result = await compareFiles(suiteId, testId)
1643+
expect(result).toEqual([])
1644+
})
1645+
1646+
test('Remove minProperties with default value for object property', async () => {
1647+
const testId = 'remove-minProperties-with-default-value-for-object-property'
1648+
const result = await compareFiles(suiteId, testId)
1649+
expect(result).toEqual([])
1650+
})
1651+
1652+
test('Add attribute with default value for xml', async () => {
1653+
const testId = 'add-attribute-with-default-value-for-xml'
1654+
const result = await compareFiles(suiteId, testId)
1655+
expect(result).toEqual([])
1656+
})
1657+
1658+
test('Remove attribute with default value for xml', async () => {
1659+
const testId = 'remove-attribute-with-default-value-for-xml'
1660+
const result = await compareFiles(suiteId, testId)
1661+
expect(result).toEqual([])
1662+
})
1663+
1664+
test('Add xml:wrapped with default value for array property', async () => {
1665+
const testId = 'add-xml-wrapped-with-default-value-for-array-property'
1666+
const result = await compareFiles(suiteId, testId)
1667+
expect(result).toEqual([])
1668+
})
1669+
1670+
test('Remove xml:wrapped with default value for array property', async () => {
1671+
const testId = 'remove-xml-wrapped-with-default-value-for-array-property'
1672+
const result = await compareFiles(suiteId, testId)
1673+
expect(result).toEqual([])
1674+
})
1675+
})
1676+
}

0 commit comments

Comments
 (0)