Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@
"update-lock-file": "update-lock-file @netcracker"
},
"dependencies": {
"@netcracker/qubership-apihub-api-unifier": "2.2.0",
"@netcracker/qubership-apihub-api-unifier": "dev",
"@netcracker/qubership-apihub-json-crawl": "1.0.4",
"fast-equals": "4.0.3"
},
"devDependencies": {
"@netcracker/qubership-apihub-compatibility-suites": "2.1.3",
"@netcracker/qubership-apihub-compatibility-suites": "dev",
"@netcracker/qubership-apihub-graphapi": "1.0.8",
"@netcracker/qubership-apihub-npm-gitflow": "3.1.0",
"@types/jest": "29.5.11",
Expand Down
9 changes: 9 additions & 0 deletions test/compatibility-suites/openapi/headers.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { runRefObjectDescriptionTests } from './templates/reference-object-31.template'

const SUITE_ID = 'headers'
const HEADER_PATH = ['paths', '/path1', 'get', 'responses', '200', 'headers', 'X-Rate-Limit']
const COMPONENTS_HEADER_PATH = ['components', 'headers', 'X-Rate-Limit']

describe('Reference object. Headers. Description fields in ref object', () => {
runRefObjectDescriptionTests(SUITE_ID, HEADER_PATH, COMPONENTS_HEADER_PATH)
})
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { compareFiles, TEST_DEFAULTS_DECLARATION_PATHS } from '../utils'
import { diffsMatcher } from '../../helper/matchers'
import { annotation, breaking, deprecated, DiffAction, nonBreaking, unclassified } from '../../../src'
import { runRefObjectDescriptionTests } from './templates/reference-object-31.template'

const SUITE_ID = 'operation-parameters'

Expand Down Expand Up @@ -338,7 +339,6 @@ describe('Openapi3 Operation Parameters', () => {
}),
]))
})


// TODO: fixme
test.skip('Mark primitive parameter as exploded', async () => {
Expand Down Expand Up @@ -724,3 +724,8 @@ describe('Openapi3 Operation Parameters', () => {
})
})
})

const COMPONENTS_OPERATION_PARAMETER_PATH = ['components', 'parameters', 'status']
describe('Reference object. Operation parameters. Description fields in ref object', () => {
runRefObjectDescriptionTests(SUITE_ID, [...OPERATION_PARAMETERS_PATH, 0], COMPONENTS_OPERATION_PARAMETER_PATH)
})
17 changes: 9 additions & 8 deletions test/compatibility-suites/openapi/parameters-examples.test.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,11 @@
import { compareFiles } from '../utils'
import { diffsMatcher } from '../../helper/matchers'
import { annotation, DiffAction } from '../../../src'
import { runRefObjectDescriptionTests, runRefObjectSummaryTests } from './templates/reference-object-31.template'

const SUITE_ID = 'parameters-examples'

const PARAMETERS_EXAMPLES_PATH = [
'paths',
'/path1',
'post',
'parameters',
0,
'examples',
]
const PARAMETERS_EXAMPLES_PATH = ['paths', '/path1', 'post', 'parameters', 0, 'examples']

describe('Openapi3 Parameters Examples', () => {

Expand Down Expand Up @@ -168,3 +162,10 @@ describe('Openapi3 Parameters Examples', () => {
]))
})
})

const COMPONENTS_PARAMETERS_EXAMPLE_PATH = ['components', 'examples', 'ex1']
describe('Reference object. Parameters examples. Description and Summary fields in ref object', () => {
runRefObjectDescriptionTests(SUITE_ID, [...PARAMETERS_EXAMPLES_PATH, 'ex1'], COMPONENTS_PARAMETERS_EXAMPLE_PATH)
runRefObjectSummaryTests(SUITE_ID, [...PARAMETERS_EXAMPLES_PATH, 'ex1'], COMPONENTS_PARAMETERS_EXAMPLE_PATH)
})

47 changes: 24 additions & 23 deletions test/compatibility-suites/openapi/request-body-examples.test.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
import { compareFiles } from '../utils'
import { diffsMatcher } from '../../helper/matchers'
import { annotation, DiffAction } from '../../../src'
import { runRefObjectDescriptionTests } from './templates/reference-object-31.template'

const SUITE_ID = 'request-body-examples'

const REQUEST_BODY_PATH = [
'paths',
'/path1',
'post',
'requestBody',
]
const REQUEST_BODY_CONTENT_EXAMPLES_PATH = ['paths', '/path1', 'post', 'requestBody', 'content', 'application/json', 'examples']

describe('Openapi3 Request Body Examples', () => {

Expand All @@ -19,7 +15,7 @@ describe('Openapi3 Request Body Examples', () => {
expect(result).toEqual(diffsMatcher([
expect.objectContaining({
action: DiffAction.add,
afterDeclarationPaths: [[...REQUEST_BODY_PATH, 'content', 'application/json', 'examples', 'example1']],
afterDeclarationPaths: [[...REQUEST_BODY_CONTENT_EXAMPLES_PATH, 'example1']],
type: annotation,
}),
]))
Expand All @@ -31,7 +27,7 @@ describe('Openapi3 Request Body Examples', () => {
expect(result).toEqual(diffsMatcher([
expect.objectContaining({
action: DiffAction.add,
afterDeclarationPaths: [[...REQUEST_BODY_PATH, 'content', 'application/json', 'examples', 'example2']],
afterDeclarationPaths: [[...REQUEST_BODY_CONTENT_EXAMPLES_PATH, 'example2']],
type: annotation,
}),
]))
Expand All @@ -43,8 +39,8 @@ describe('Openapi3 Request Body Examples', () => {
expect(result).toEqual(diffsMatcher([
expect.objectContaining({
action: DiffAction.replace,
beforeDeclarationPaths: [[...REQUEST_BODY_PATH, 'content', 'application/json', 'examples', 'example1', 'value']],
afterDeclarationPaths: [[...REQUEST_BODY_PATH, 'content', 'application/json', 'examples', 'example1', 'value']],
beforeDeclarationPaths: [[...REQUEST_BODY_CONTENT_EXAMPLES_PATH, 'example1', 'value']],
afterDeclarationPaths: [[...REQUEST_BODY_CONTENT_EXAMPLES_PATH, 'example1', 'value']],
type: annotation,
}),
]))
Expand All @@ -56,12 +52,12 @@ describe('Openapi3 Request Body Examples', () => {
expect(result).toEqual(diffsMatcher([
expect.objectContaining({
action: DiffAction.remove,
beforeDeclarationPaths: [[...REQUEST_BODY_PATH, 'content', 'application/json', 'examples', 'example1']],
beforeDeclarationPaths: [[...REQUEST_BODY_CONTENT_EXAMPLES_PATH, 'example1']],
type: annotation,
}),
expect.objectContaining({
action: DiffAction.add,
afterDeclarationPaths: [[...REQUEST_BODY_PATH, 'content', 'application/json', 'examples', 'example0']],
afterDeclarationPaths: [[...REQUEST_BODY_CONTENT_EXAMPLES_PATH, 'example0']],
type: annotation,
}),
]))
Expand All @@ -73,8 +69,8 @@ describe('Openapi3 Request Body Examples', () => {
expect(result).toEqual(diffsMatcher([
expect.objectContaining({
action: DiffAction.replace,
beforeDeclarationPaths: [[...REQUEST_BODY_PATH, 'content', 'application/json', 'examples', 'example1', 'externalValue']],
afterDeclarationPaths: [[...REQUEST_BODY_PATH, 'content', 'application/json', 'examples', 'example1', 'externalValue']],
beforeDeclarationPaths: [[...REQUEST_BODY_CONTENT_EXAMPLES_PATH, 'example1', 'externalValue']],
afterDeclarationPaths: [[...REQUEST_BODY_CONTENT_EXAMPLES_PATH, 'example1', 'externalValue']],
type: annotation,
}),
]))
Expand All @@ -86,7 +82,7 @@ describe('Openapi3 Request Body Examples', () => {
expect(result).toEqual(diffsMatcher([
expect.objectContaining({
action: DiffAction.remove,
beforeDeclarationPaths: [[...REQUEST_BODY_PATH, 'content', 'application/json', 'examples', 'example1', 'externalValue']],
beforeDeclarationPaths: [[...REQUEST_BODY_CONTENT_EXAMPLES_PATH, 'example1', 'externalValue']],
type: annotation,
}),
]))
Expand All @@ -98,7 +94,7 @@ describe('Openapi3 Request Body Examples', () => {
expect(result).toEqual(diffsMatcher([
expect.objectContaining({
action: DiffAction.add,
afterDeclarationPaths: [[...REQUEST_BODY_PATH, 'content', 'application/json', 'examples', 'example1', 'summary']],
afterDeclarationPaths: [[...REQUEST_BODY_CONTENT_EXAMPLES_PATH, 'example1', 'summary']],
type: annotation,
}),
]))
Expand All @@ -110,8 +106,8 @@ describe('Openapi3 Request Body Examples', () => {
expect(result).toEqual(diffsMatcher([
expect.objectContaining({
action: DiffAction.replace,
beforeDeclarationPaths: [[...REQUEST_BODY_PATH, 'content', 'application/json', 'examples', 'example1', 'summary']],
afterDeclarationPaths: [[...REQUEST_BODY_PATH, 'content', 'application/json', 'examples', 'example1', 'summary']],
beforeDeclarationPaths: [[...REQUEST_BODY_CONTENT_EXAMPLES_PATH, 'example1', 'summary']],
afterDeclarationPaths: [[...REQUEST_BODY_CONTENT_EXAMPLES_PATH, 'example1', 'summary']],
type: annotation,
}),
]))
Expand All @@ -123,7 +119,7 @@ describe('Openapi3 Request Body Examples', () => {
expect(result).toEqual(diffsMatcher([
expect.objectContaining({
action: DiffAction.remove,
beforeDeclarationPaths: [[...REQUEST_BODY_PATH, 'content', 'application/json', 'examples', 'example1', 'summary']],
beforeDeclarationPaths: [[...REQUEST_BODY_CONTENT_EXAMPLES_PATH, 'example1', 'summary']],
type: annotation,
}),
]))
Expand All @@ -135,7 +131,7 @@ describe('Openapi3 Request Body Examples', () => {
expect(result).toEqual(diffsMatcher([
expect.objectContaining({
action: DiffAction.add,
afterDeclarationPaths: [[...REQUEST_BODY_PATH, 'content', 'application/json', 'examples', 'example1', 'description']],
afterDeclarationPaths: [[...REQUEST_BODY_CONTENT_EXAMPLES_PATH, 'example1', 'description']],
type: annotation,
}),
]))
Expand All @@ -147,8 +143,8 @@ describe('Openapi3 Request Body Examples', () => {
expect(result).toEqual(diffsMatcher([
expect.objectContaining({
action: DiffAction.replace,
beforeDeclarationPaths: [[...REQUEST_BODY_PATH, 'content', 'application/json', 'examples', 'example1', 'description']],
afterDeclarationPaths: [[...REQUEST_BODY_PATH, 'content', 'application/json', 'examples', 'example1', 'description']],
beforeDeclarationPaths: [[...REQUEST_BODY_CONTENT_EXAMPLES_PATH, 'example1', 'description']],
afterDeclarationPaths: [[...REQUEST_BODY_CONTENT_EXAMPLES_PATH, 'example1', 'description']],
type: annotation,
}),
]))
Expand All @@ -160,9 +156,14 @@ describe('Openapi3 Request Body Examples', () => {
expect(result).toEqual(diffsMatcher([
expect.objectContaining({
action: DiffAction.remove,
beforeDeclarationPaths: [[...REQUEST_BODY_PATH, 'content', 'application/json', 'examples', 'example1', 'description']],
beforeDeclarationPaths: [[...REQUEST_BODY_CONTENT_EXAMPLES_PATH, 'example1', 'description']],
type: annotation,
}),
]))
})
})

const COMPONENTS_EXAMPLES_PATH = ['components', 'examples', 'ex1']
describe('Reference object. Request body examples. Description fields in ref object', () => {
runRefObjectDescriptionTests(SUITE_ID, [...REQUEST_BODY_CONTENT_EXAMPLES_PATH, 'ex1'], COMPONENTS_EXAMPLES_PATH)
})
9 changes: 9 additions & 0 deletions test/compatibility-suites/openapi/request-body.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { runRefObjectDescriptionTests } from './templates/reference-object-31.template'

const SUITE_ID = 'request-body'
const REQUEST_BODY_PATH = ['paths', '/path1', 'post', 'requestBody']
const COMPONENTS_REQUEST_BODY_PATH = ['components', 'requestBodies', 'rb1']

describe('Reference object. Request body. Description fields in ref object', () => {
runRefObjectDescriptionTests(SUITE_ID, REQUEST_BODY_PATH, COMPONENTS_REQUEST_BODY_PATH)
})
42 changes: 24 additions & 18 deletions test/compatibility-suites/openapi/response-body-examples.test.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import { compareFiles } from '../utils'
import { diffsMatcher } from '../../helper/matchers'
import { annotation, DiffAction } from '../../../src'
import { runRefObjectDescriptionTests } from './templates/reference-object-31.template'

const SUITE_ID = 'response-body-examples'

const COMMON_PATH = ['paths', '/path1', 'post', 'responses', '200', 'content', 'application/json']
const RESPONSE_CONTENT_EXAMPLES_PATH = ['paths', '/path1', 'post', 'responses', '200', 'content', 'application/json', 'examples']

describe('Openapi3 Response Body Examples', () => {

Expand All @@ -14,7 +15,7 @@ describe('Openapi3 Response Body Examples', () => {
expect(result).toEqual(diffsMatcher([
expect.objectContaining({
action: DiffAction.add,
afterDeclarationPaths: [[...COMMON_PATH, 'examples', 'example1']],
afterDeclarationPaths: [[...RESPONSE_CONTENT_EXAMPLES_PATH, 'example1']],
type: annotation,
}),
]))
Expand All @@ -26,7 +27,7 @@ describe('Openapi3 Response Body Examples', () => {
expect(result).toEqual(diffsMatcher([
expect.objectContaining({
action: DiffAction.add,
afterDeclarationPaths: [[...COMMON_PATH, 'examples', 'example2']],
afterDeclarationPaths: [[...RESPONSE_CONTENT_EXAMPLES_PATH, 'example2']],
type: annotation,
}),
]))
Expand All @@ -38,8 +39,8 @@ describe('Openapi3 Response Body Examples', () => {
expect(result).toEqual(diffsMatcher([
expect.objectContaining({
action: DiffAction.replace,
beforeDeclarationPaths: [[...COMMON_PATH, 'examples', 'example1', 'value']],
afterDeclarationPaths: [[...COMMON_PATH, 'examples', 'example1', 'value']],
beforeDeclarationPaths: [[...RESPONSE_CONTENT_EXAMPLES_PATH, 'example1', 'value']],
afterDeclarationPaths: [[...RESPONSE_CONTENT_EXAMPLES_PATH, 'example1', 'value']],
type: annotation,
}),
]))
Expand All @@ -51,12 +52,12 @@ describe('Openapi3 Response Body Examples', () => {
expect(result).toEqual(diffsMatcher([
expect.objectContaining({
action: DiffAction.remove,
beforeDeclarationPaths: [[...COMMON_PATH, 'examples', 'example1']],
beforeDeclarationPaths: [[...RESPONSE_CONTENT_EXAMPLES_PATH, 'example1']],
type: annotation,
}),
expect.objectContaining({
action: DiffAction.add,
afterDeclarationPaths: [[...COMMON_PATH, 'examples', 'example0']],
afterDeclarationPaths: [[...RESPONSE_CONTENT_EXAMPLES_PATH, 'example0']],
type: annotation,
}),
]))
Expand All @@ -68,8 +69,8 @@ describe('Openapi3 Response Body Examples', () => {
expect(result).toEqual(diffsMatcher([
expect.objectContaining({
action: DiffAction.replace,
beforeDeclarationPaths: [[...COMMON_PATH, 'examples', 'example1', 'externalValue']],
afterDeclarationPaths: [[...COMMON_PATH, 'examples', 'example1', 'externalValue']],
beforeDeclarationPaths: [[...RESPONSE_CONTENT_EXAMPLES_PATH, 'example1', 'externalValue']],
afterDeclarationPaths: [[...RESPONSE_CONTENT_EXAMPLES_PATH, 'example1', 'externalValue']],
type: annotation,
}),
]))
Expand All @@ -81,7 +82,7 @@ describe('Openapi3 Response Body Examples', () => {
expect(result).toEqual(diffsMatcher([
expect.objectContaining({
action: DiffAction.remove,
beforeDeclarationPaths: [[...COMMON_PATH, 'examples', 'example1', 'externalValue']],
beforeDeclarationPaths: [[...RESPONSE_CONTENT_EXAMPLES_PATH, 'example1', 'externalValue']],
type: annotation,
}),
]))
Expand All @@ -93,7 +94,7 @@ describe('Openapi3 Response Body Examples', () => {
expect(result).toEqual(diffsMatcher([
expect.objectContaining({
action: DiffAction.add,
afterDeclarationPaths: [[...COMMON_PATH, 'examples', 'example1', 'summary']],
afterDeclarationPaths: [[...RESPONSE_CONTENT_EXAMPLES_PATH, 'example1', 'summary']],
type: annotation,
}),
]))
Expand All @@ -105,8 +106,8 @@ describe('Openapi3 Response Body Examples', () => {
expect(result).toEqual(diffsMatcher([
expect.objectContaining({
action: DiffAction.replace,
beforeDeclarationPaths: [[...COMMON_PATH, 'examples', 'example1', 'summary']],
afterDeclarationPaths: [[...COMMON_PATH, 'examples', 'example1', 'summary']],
beforeDeclarationPaths: [[...RESPONSE_CONTENT_EXAMPLES_PATH, 'example1', 'summary']],
afterDeclarationPaths: [[...RESPONSE_CONTENT_EXAMPLES_PATH, 'example1', 'summary']],
type: annotation,
}),
]))
Expand All @@ -118,7 +119,7 @@ describe('Openapi3 Response Body Examples', () => {
expect(result).toEqual(diffsMatcher([
expect.objectContaining({
action: DiffAction.remove,
beforeDeclarationPaths: [[...COMMON_PATH, 'examples', 'example1', 'summary']],
beforeDeclarationPaths: [[...RESPONSE_CONTENT_EXAMPLES_PATH, 'example1', 'summary']],
type: annotation,
}),
]))
Expand All @@ -130,7 +131,7 @@ describe('Openapi3 Response Body Examples', () => {
expect(result).toEqual(diffsMatcher([
expect.objectContaining({
action: DiffAction.add,
afterDeclarationPaths: [[...COMMON_PATH, 'examples', 'example1', 'description']],
afterDeclarationPaths: [[...RESPONSE_CONTENT_EXAMPLES_PATH, 'example1', 'description']],
type: annotation,
}),
]))
Expand All @@ -142,8 +143,8 @@ describe('Openapi3 Response Body Examples', () => {
expect(result).toEqual(diffsMatcher([
expect.objectContaining({
action: DiffAction.replace,
beforeDeclarationPaths: [[...COMMON_PATH, 'examples', 'example1', 'description']],
afterDeclarationPaths: [[...COMMON_PATH, 'examples', 'example1', 'description']],
beforeDeclarationPaths: [[...RESPONSE_CONTENT_EXAMPLES_PATH, 'example1', 'description']],
afterDeclarationPaths: [[...RESPONSE_CONTENT_EXAMPLES_PATH, 'example1', 'description']],
type: annotation,
}),
]))
Expand All @@ -155,9 +156,14 @@ describe('Openapi3 Response Body Examples', () => {
expect(result).toEqual(diffsMatcher([
expect.objectContaining({
action: DiffAction.remove,
beforeDeclarationPaths: [[...COMMON_PATH, 'examples', 'example1', 'description']],
beforeDeclarationPaths: [[...RESPONSE_CONTENT_EXAMPLES_PATH, 'example1', 'description']],
type: annotation,
}),
]))
})
})

const COMPONENTS_EXAMPLES_PATH = ['components', 'examples', 'ex1']
describe('Reference object. Response body examples. Description fields in ref object', () => {
runRefObjectDescriptionTests(SUITE_ID, [...RESPONSE_CONTENT_EXAMPLES_PATH, 'ex1'], COMPONENTS_EXAMPLES_PATH)
})
7 changes: 7 additions & 0 deletions test/compatibility-suites/openapi/response.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { compareFiles } from '../utils'
import { diffsMatcher } from '../../helper/matchers'
import { annotation, breaking, DiffAction, nonBreaking } from '../../../src'
import { runRefObjectDescriptionTests } from './templates/reference-object-31.template'

const SUITE_ID = 'response'

Expand Down Expand Up @@ -252,3 +253,9 @@ describe('Openapi3 Response', () => {
})
})
})

const RESPONSES_POST_PATH = ['paths', '/path1', 'post', 'responses']
const COMPONENTS_RESPONSE_PATH = ['components', 'responses', 'response200']
describe('Reference object. Response. Description fields in ref object', () => {
runRefObjectDescriptionTests(SUITE_ID, [...RESPONSES_POST_PATH, '200'], COMPONENTS_RESPONSE_PATH)
})
Loading