Skip to content
Merged
Show file tree
Hide file tree
Changes from 6 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": "feature-ref-obj",
"@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": "feature-reference-object",
"@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 PATH_TO_HEADER_DESCRIPTION = ['paths', '/path1', 'get', 'responses', '200', 'headers', 'X-Rate-Limit', 'description']
const PATH_TO_COMPONENT_DESCRIPTION = ['components', 'headers', 'X-Rate-Limit', 'description']

describe('Reference object. Headers. Description fields in ref object', () => {
runRefObjectDescriptionTests(SUITE_ID, PATH_TO_HEADER_DESCRIPTION, PATH_TO_COMPONENT_DESCRIPTION)
})
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 PATH_TO_COMPONENT_DESCRIPTION = ['components', 'parameters', 'status', 'description']
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

_PATH

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

describe('Reference object. Operation parameters. Description fields in ref object', () => {
runRefObjectDescriptionTests(SUITE_ID, [...OPERATION_PARAMETERS_PATH, 0, 'description'], PATH_TO_COMPONENT_DESCRIPTION)
})
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 PATH_TO_COMPONENTS = ['components', 'examples', 'ex1']
describe('Reference object. Parameters examples. Description and Summary fields in ref object', () => {
runRefObjectDescriptionTests(SUITE_ID, [...PARAMETERS_EXAMPLES_PATH, 'ex1', 'description'], [...PATH_TO_COMPONENTS, 'description'])
runRefObjectSummaryTests(SUITE_ID, [...PARAMETERS_EXAMPLES_PATH, 'ex1', 'summary'], [...PATH_TO_COMPONENTS, 'summary'])
})

48 changes: 25 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_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_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_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_PATH, 'example1', 'value']],
afterDeclarationPaths: [[...REQUEST_BODY_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_PATH, 'example1']],
type: annotation,
}),
expect.objectContaining({
action: DiffAction.add,
afterDeclarationPaths: [[...REQUEST_BODY_PATH, 'content', 'application/json', 'examples', 'example0']],
afterDeclarationPaths: [[...REQUEST_BODY_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_PATH, 'example1', 'externalValue']],
afterDeclarationPaths: [[...REQUEST_BODY_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_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_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_PATH, 'example1', 'summary']],
afterDeclarationPaths: [[...REQUEST_BODY_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_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_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_PATH, 'example1', 'description']],
afterDeclarationPaths: [[...REQUEST_BODY_PATH, 'example1', 'description']],
type: annotation,
}),
]))
Expand All @@ -160,9 +156,15 @@ 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_PATH, 'example1', 'description']],
type: annotation,
}),
]))
})
})

const PATH_TO_COMPONENTS_DESCRIPTION = ['components', 'examples', 'ex1', 'description']

describe('Reference object. Request body examples. Description fields in ref object', () => {
runRefObjectDescriptionTests(SUITE_ID, [...REQUEST_BODY_PATH, 'ex1', 'description'], PATH_TO_COMPONENTS_DESCRIPTION)
})
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 PATH_TO_HEADER_DESCRIPTION = ['paths', '/path1', 'post', 'requestBody', 'description']
const PATH_TO_COMPONENTS_DESCRIPTION = ['components', 'requestBodies', 'rb1', 'description']

describe('Reference object. Request body. Description fields in ref object', () => {
runRefObjectDescriptionTests(SUITE_ID, PATH_TO_HEADER_DESCRIPTION, PATH_TO_COMPONENTS_DESCRIPTION)
})
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 COMMON_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: [[...COMMON_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: [[...COMMON_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: [[...COMMON_PATH, 'example1', 'value']],
afterDeclarationPaths: [[...COMMON_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: [[...COMMON_PATH, 'example1']],
type: annotation,
}),
expect.objectContaining({
action: DiffAction.add,
afterDeclarationPaths: [[...COMMON_PATH, 'examples', 'example0']],
afterDeclarationPaths: [[...COMMON_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: [[...COMMON_PATH, 'example1', 'externalValue']],
afterDeclarationPaths: [[...COMMON_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: [[...COMMON_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: [[...COMMON_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: [[...COMMON_PATH, 'example1', 'summary']],
afterDeclarationPaths: [[...COMMON_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: [[...COMMON_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: [[...COMMON_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: [[...COMMON_PATH, 'example1', 'description']],
afterDeclarationPaths: [[...COMMON_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: [[...COMMON_PATH, 'example1', 'description']],
type: annotation,
}),
]))
})
})

const PATH_TO_COMPONENTS_DESCRIPTION = ['components', 'examples', 'ex1', 'description']
describe('Reference object. Response body examples. Description fields in ref object', () => {
runRefObjectDescriptionTests(SUITE_ID, [...COMMON_PATH, 'ex1', 'description'], PATH_TO_COMPONENTS_DESCRIPTION)
})
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 PATH_TO_COMPONENTS_DESCRIPTION = ['components', 'responses', 'response200', 'description']
describe('Reference object. Response. Description fields in ref object', () => {
runRefObjectDescriptionTests(SUITE_ID, [...RESPONSES_POST_PATH, '200', 'description'], PATH_TO_COMPONENTS_DESCRIPTION)
})
Loading