Skip to content

Commit 62e9d0f

Browse files
committed
feat: Updated paths compatibility-suites tests
1 parent af2efb1 commit 62e9d0f

File tree

7 files changed

+46
-66
lines changed

7 files changed

+46
-66
lines changed

test/compatibility-suites/openapi/headers.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { runRefObjectDescriptionTests } from './templates/reference-object-31.template'
22

33
const SUITE_ID = 'headers'
4-
const PATH_TO_HEADER_DESCRIPTION = ['paths', '/user/login', 'get', 'responses', '200', 'headers', 'X-Rate-Limit']
4+
const PATH_TO_HEADER_DESCRIPTION = ['paths', '/path1', 'get', 'responses', '200', 'headers', 'X-Rate-Limit']
55
const PATH_TO_COMPONENT_DESCRIPTION = ['components', 'headers', 'X-Rate-Limit', 'description']
66

77
describe('Reference object. Headers. Description fields in ref object', () => {

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -725,9 +725,7 @@ describe('Openapi3 Operation Parameters', () => {
725725
})
726726
})
727727

728-
const PATH_TO_OPERATION_PARAMETERS_DESCRIPTION = ['paths', '/pet/findByStatus', 'get', 'parameters', 0]
729728
const PATH_TO_COMPONENT_DESCRIPTION = ['components', 'parameters', 'status', 'description']
730-
731729
describe('Reference object. Operation parameters. Description fields in ref object', () => {
732-
runRefObjectDescriptionTests(SUITE_ID, PATH_TO_OPERATION_PARAMETERS_DESCRIPTION, PATH_TO_COMPONENT_DESCRIPTION)
730+
runRefObjectDescriptionTests(SUITE_ID, [...OPERATION_PARAMETERS_PATH, 0], PATH_TO_COMPONENT_DESCRIPTION)
733731
})

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

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,7 @@ import { runRefObjectDescriptionTests, runRefObjectSummaryTests } from './templa
55

66
const SUITE_ID = 'parameters-examples'
77

8-
const PARAMETERS_EXAMPLES_PATH = [
9-
'paths',
10-
'/path1',
11-
'post',
12-
'parameters',
13-
0,
14-
'examples',
15-
]
8+
const PARAMETERS_EXAMPLES_PATH = ['paths', '/path1', 'post', 'parameters', 0, 'examples']
169

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

@@ -170,11 +163,9 @@ describe('Openapi3 Parameters Examples', () => {
170163
})
171164
})
172165

173-
const PATH_TO_RESPONSES_DESCRIPTION = ['paths', '/pet/findByTags', 'get', 'parameters', 0, 'examples', 'ex1']
174166
const PATH_TO_COMPONENTS = ['components', 'examples', 'ex1']
175-
176167
describe('Reference object. Parameters examples. Description and Summary fields in ref object', () => {
177-
runRefObjectDescriptionTests(SUITE_ID, PATH_TO_RESPONSES_DESCRIPTION, [...PATH_TO_COMPONENTS, 'description'])
178-
runRefObjectSummaryTests(SUITE_ID, PATH_TO_RESPONSES_DESCRIPTION, [...PATH_TO_COMPONENTS, 'summary'])
168+
runRefObjectDescriptionTests(SUITE_ID, [...PARAMETERS_EXAMPLES_PATH, 'ex1'], [...PATH_TO_COMPONENTS, 'description'])
169+
runRefObjectSummaryTests(SUITE_ID, [...PARAMETERS_EXAMPLES_PATH, 'ex1'], [...PATH_TO_COMPONENTS, 'summary'])
179170
})
180171

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

Lines changed: 19 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,7 @@ import { runRefObjectDescriptionTests } from './templates/reference-object-31.te
55

66
const SUITE_ID = 'request-body-examples'
77

8-
const REQUEST_BODY_PATH = [
9-
'paths',
10-
'/path1',
11-
'post',
12-
'requestBody',
13-
]
8+
const REQUEST_BODY_PATH = ['paths', '/path1', 'post', 'requestBody', 'content', 'application/json', 'examples']
149

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

@@ -20,7 +15,7 @@ describe('Openapi3 Request Body Examples', () => {
2015
expect(result).toEqual(diffsMatcher([
2116
expect.objectContaining({
2217
action: DiffAction.add,
23-
afterDeclarationPaths: [[...REQUEST_BODY_PATH, 'content', 'application/json', 'examples', 'example1']],
18+
afterDeclarationPaths: [[...REQUEST_BODY_PATH, 'example1']],
2419
type: annotation,
2520
}),
2621
]))
@@ -32,7 +27,7 @@ describe('Openapi3 Request Body Examples', () => {
3227
expect(result).toEqual(diffsMatcher([
3328
expect.objectContaining({
3429
action: DiffAction.add,
35-
afterDeclarationPaths: [[...REQUEST_BODY_PATH, 'content', 'application/json', 'examples', 'example2']],
30+
afterDeclarationPaths: [[...REQUEST_BODY_PATH, 'example2']],
3631
type: annotation,
3732
}),
3833
]))
@@ -44,8 +39,8 @@ describe('Openapi3 Request Body Examples', () => {
4439
expect(result).toEqual(diffsMatcher([
4540
expect.objectContaining({
4641
action: DiffAction.replace,
47-
beforeDeclarationPaths: [[...REQUEST_BODY_PATH, 'content', 'application/json', 'examples', 'example1', 'value']],
48-
afterDeclarationPaths: [[...REQUEST_BODY_PATH, 'content', 'application/json', 'examples', 'example1', 'value']],
42+
beforeDeclarationPaths: [[...REQUEST_BODY_PATH, 'example1', 'value']],
43+
afterDeclarationPaths: [[...REQUEST_BODY_PATH, 'example1', 'value']],
4944
type: annotation,
5045
}),
5146
]))
@@ -57,12 +52,12 @@ describe('Openapi3 Request Body Examples', () => {
5752
expect(result).toEqual(diffsMatcher([
5853
expect.objectContaining({
5954
action: DiffAction.remove,
60-
beforeDeclarationPaths: [[...REQUEST_BODY_PATH, 'content', 'application/json', 'examples', 'example1']],
55+
beforeDeclarationPaths: [[...REQUEST_BODY_PATH, 'example1']],
6156
type: annotation,
6257
}),
6358
expect.objectContaining({
6459
action: DiffAction.add,
65-
afterDeclarationPaths: [[...REQUEST_BODY_PATH, 'content', 'application/json', 'examples', 'example0']],
60+
afterDeclarationPaths: [[...REQUEST_BODY_PATH, 'example0']],
6661
type: annotation,
6762
}),
6863
]))
@@ -74,8 +69,8 @@ describe('Openapi3 Request Body Examples', () => {
7469
expect(result).toEqual(diffsMatcher([
7570
expect.objectContaining({
7671
action: DiffAction.replace,
77-
beforeDeclarationPaths: [[...REQUEST_BODY_PATH, 'content', 'application/json', 'examples', 'example1', 'externalValue']],
78-
afterDeclarationPaths: [[...REQUEST_BODY_PATH, 'content', 'application/json', 'examples', 'example1', 'externalValue']],
72+
beforeDeclarationPaths: [[...REQUEST_BODY_PATH, 'example1', 'externalValue']],
73+
afterDeclarationPaths: [[...REQUEST_BODY_PATH, 'example1', 'externalValue']],
7974
type: annotation,
8075
}),
8176
]))
@@ -87,7 +82,7 @@ describe('Openapi3 Request Body Examples', () => {
8782
expect(result).toEqual(diffsMatcher([
8883
expect.objectContaining({
8984
action: DiffAction.remove,
90-
beforeDeclarationPaths: [[...REQUEST_BODY_PATH, 'content', 'application/json', 'examples', 'example1', 'externalValue']],
85+
beforeDeclarationPaths: [[...REQUEST_BODY_PATH, 'example1', 'externalValue']],
9186
type: annotation,
9287
}),
9388
]))
@@ -99,7 +94,7 @@ describe('Openapi3 Request Body Examples', () => {
9994
expect(result).toEqual(diffsMatcher([
10095
expect.objectContaining({
10196
action: DiffAction.add,
102-
afterDeclarationPaths: [[...REQUEST_BODY_PATH, 'content', 'application/json', 'examples', 'example1', 'summary']],
97+
afterDeclarationPaths: [[...REQUEST_BODY_PATH, 'example1', 'summary']],
10398
type: annotation,
10499
}),
105100
]))
@@ -111,8 +106,8 @@ describe('Openapi3 Request Body Examples', () => {
111106
expect(result).toEqual(diffsMatcher([
112107
expect.objectContaining({
113108
action: DiffAction.replace,
114-
beforeDeclarationPaths: [[...REQUEST_BODY_PATH, 'content', 'application/json', 'examples', 'example1', 'summary']],
115-
afterDeclarationPaths: [[...REQUEST_BODY_PATH, 'content', 'application/json', 'examples', 'example1', 'summary']],
109+
beforeDeclarationPaths: [[...REQUEST_BODY_PATH, 'example1', 'summary']],
110+
afterDeclarationPaths: [[...REQUEST_BODY_PATH, 'example1', 'summary']],
116111
type: annotation,
117112
}),
118113
]))
@@ -124,7 +119,7 @@ describe('Openapi3 Request Body Examples', () => {
124119
expect(result).toEqual(diffsMatcher([
125120
expect.objectContaining({
126121
action: DiffAction.remove,
127-
beforeDeclarationPaths: [[...REQUEST_BODY_PATH, 'content', 'application/json', 'examples', 'example1', 'summary']],
122+
beforeDeclarationPaths: [[...REQUEST_BODY_PATH, 'example1', 'summary']],
128123
type: annotation,
129124
}),
130125
]))
@@ -136,7 +131,7 @@ describe('Openapi3 Request Body Examples', () => {
136131
expect(result).toEqual(diffsMatcher([
137132
expect.objectContaining({
138133
action: DiffAction.add,
139-
afterDeclarationPaths: [[...REQUEST_BODY_PATH, 'content', 'application/json', 'examples', 'example1', 'description']],
134+
afterDeclarationPaths: [[...REQUEST_BODY_PATH, 'example1', 'description']],
140135
type: annotation,
141136
}),
142137
]))
@@ -148,8 +143,8 @@ describe('Openapi3 Request Body Examples', () => {
148143
expect(result).toEqual(diffsMatcher([
149144
expect.objectContaining({
150145
action: DiffAction.replace,
151-
beforeDeclarationPaths: [[...REQUEST_BODY_PATH, 'content', 'application/json', 'examples', 'example1', 'description']],
152-
afterDeclarationPaths: [[...REQUEST_BODY_PATH, 'content', 'application/json', 'examples', 'example1', 'description']],
146+
beforeDeclarationPaths: [[...REQUEST_BODY_PATH, 'example1', 'description']],
147+
afterDeclarationPaths: [[...REQUEST_BODY_PATH, 'example1', 'description']],
153148
type: annotation,
154149
}),
155150
]))
@@ -161,16 +156,15 @@ describe('Openapi3 Request Body Examples', () => {
161156
expect(result).toEqual(diffsMatcher([
162157
expect.objectContaining({
163158
action: DiffAction.remove,
164-
beforeDeclarationPaths: [[...REQUEST_BODY_PATH, 'content', 'application/json', 'examples', 'example1', 'description']],
159+
beforeDeclarationPaths: [[...REQUEST_BODY_PATH, 'example1', 'description']],
165160
type: annotation,
166161
}),
167162
]))
168163
})
169164
})
170165

171-
const PATH_TO_REQUEST_BODY_DESCRIPTION = ['paths', '/pet', 'post', 'requestBody', 'content', 'application/json', 'examples', 'ex1']
172166
const PATH_TO_COMPONENTS_DESCRIPTION = ['components', 'examples', 'ex1', 'description']
173167

174168
describe('Reference object. Request body examples. Description fields in ref object', () => {
175-
runRefObjectDescriptionTests(SUITE_ID, PATH_TO_REQUEST_BODY_DESCRIPTION, PATH_TO_COMPONENTS_DESCRIPTION)
169+
runRefObjectDescriptionTests(SUITE_ID, [...REQUEST_BODY_PATH, 'ex1'], PATH_TO_COMPONENTS_DESCRIPTION)
176170
})

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { runRefObjectDescriptionTests } from './templates/reference-object-31.template'
22

33
const SUITE_ID = 'request-body'
4-
const PATH_TO_HEADER_DESCRIPTION = ['paths', '/store/order', 'post', 'requestBody']
4+
const PATH_TO_HEADER_DESCRIPTION = ['paths', '/path1', 'post', 'requestBody']
55
const PATH_TO_COMPONENTS_DESCRIPTION = ['components', 'requestBodies', 'rb1', 'description']
66

77
describe('Reference object. Request body. Description fields in ref object', () => {

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

Lines changed: 19 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { runRefObjectDescriptionTests } from './templates/reference-object-31.te
55

66
const SUITE_ID = 'response-body-examples'
77

8-
const COMMON_PATH = ['paths', '/path1', 'post', 'responses', '200', 'content', 'application/json']
8+
const COMMON_PATH = ['paths', '/path1', 'post', 'responses', '200', 'content', 'application/json', 'examples']
99

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

@@ -15,7 +15,7 @@ describe('Openapi3 Response Body Examples', () => {
1515
expect(result).toEqual(diffsMatcher([
1616
expect.objectContaining({
1717
action: DiffAction.add,
18-
afterDeclarationPaths: [[...COMMON_PATH, 'examples', 'example1']],
18+
afterDeclarationPaths: [[...COMMON_PATH, 'example1']],
1919
type: annotation,
2020
}),
2121
]))
@@ -27,7 +27,7 @@ describe('Openapi3 Response Body Examples', () => {
2727
expect(result).toEqual(diffsMatcher([
2828
expect.objectContaining({
2929
action: DiffAction.add,
30-
afterDeclarationPaths: [[...COMMON_PATH, 'examples', 'example2']],
30+
afterDeclarationPaths: [[...COMMON_PATH, 'example2']],
3131
type: annotation,
3232
}),
3333
]))
@@ -39,8 +39,8 @@ describe('Openapi3 Response Body Examples', () => {
3939
expect(result).toEqual(diffsMatcher([
4040
expect.objectContaining({
4141
action: DiffAction.replace,
42-
beforeDeclarationPaths: [[...COMMON_PATH, 'examples', 'example1', 'value']],
43-
afterDeclarationPaths: [[...COMMON_PATH, 'examples', 'example1', 'value']],
42+
beforeDeclarationPaths: [[...COMMON_PATH, 'example1', 'value']],
43+
afterDeclarationPaths: [[...COMMON_PATH, 'example1', 'value']],
4444
type: annotation,
4545
}),
4646
]))
@@ -52,12 +52,12 @@ describe('Openapi3 Response Body Examples', () => {
5252
expect(result).toEqual(diffsMatcher([
5353
expect.objectContaining({
5454
action: DiffAction.remove,
55-
beforeDeclarationPaths: [[...COMMON_PATH, 'examples', 'example1']],
55+
beforeDeclarationPaths: [[...COMMON_PATH, 'example1']],
5656
type: annotation,
5757
}),
5858
expect.objectContaining({
5959
action: DiffAction.add,
60-
afterDeclarationPaths: [[...COMMON_PATH, 'examples', 'example0']],
60+
afterDeclarationPaths: [[...COMMON_PATH, 'example0']],
6161
type: annotation,
6262
}),
6363
]))
@@ -69,8 +69,8 @@ describe('Openapi3 Response Body Examples', () => {
6969
expect(result).toEqual(diffsMatcher([
7070
expect.objectContaining({
7171
action: DiffAction.replace,
72-
beforeDeclarationPaths: [[...COMMON_PATH, 'examples', 'example1', 'externalValue']],
73-
afterDeclarationPaths: [[...COMMON_PATH, 'examples', 'example1', 'externalValue']],
72+
beforeDeclarationPaths: [[...COMMON_PATH, 'example1', 'externalValue']],
73+
afterDeclarationPaths: [[...COMMON_PATH, 'example1', 'externalValue']],
7474
type: annotation,
7575
}),
7676
]))
@@ -82,7 +82,7 @@ describe('Openapi3 Response Body Examples', () => {
8282
expect(result).toEqual(diffsMatcher([
8383
expect.objectContaining({
8484
action: DiffAction.remove,
85-
beforeDeclarationPaths: [[...COMMON_PATH, 'examples', 'example1', 'externalValue']],
85+
beforeDeclarationPaths: [[...COMMON_PATH, 'example1', 'externalValue']],
8686
type: annotation,
8787
}),
8888
]))
@@ -94,7 +94,7 @@ describe('Openapi3 Response Body Examples', () => {
9494
expect(result).toEqual(diffsMatcher([
9595
expect.objectContaining({
9696
action: DiffAction.add,
97-
afterDeclarationPaths: [[...COMMON_PATH, 'examples', 'example1', 'summary']],
97+
afterDeclarationPaths: [[...COMMON_PATH, 'example1', 'summary']],
9898
type: annotation,
9999
}),
100100
]))
@@ -106,8 +106,8 @@ describe('Openapi3 Response Body Examples', () => {
106106
expect(result).toEqual(diffsMatcher([
107107
expect.objectContaining({
108108
action: DiffAction.replace,
109-
beforeDeclarationPaths: [[...COMMON_PATH, 'examples', 'example1', 'summary']],
110-
afterDeclarationPaths: [[...COMMON_PATH, 'examples', 'example1', 'summary']],
109+
beforeDeclarationPaths: [[...COMMON_PATH, 'example1', 'summary']],
110+
afterDeclarationPaths: [[...COMMON_PATH, 'example1', 'summary']],
111111
type: annotation,
112112
}),
113113
]))
@@ -119,7 +119,7 @@ describe('Openapi3 Response Body Examples', () => {
119119
expect(result).toEqual(diffsMatcher([
120120
expect.objectContaining({
121121
action: DiffAction.remove,
122-
beforeDeclarationPaths: [[...COMMON_PATH, 'examples', 'example1', 'summary']],
122+
beforeDeclarationPaths: [[...COMMON_PATH, 'example1', 'summary']],
123123
type: annotation,
124124
}),
125125
]))
@@ -131,7 +131,7 @@ describe('Openapi3 Response Body Examples', () => {
131131
expect(result).toEqual(diffsMatcher([
132132
expect.objectContaining({
133133
action: DiffAction.add,
134-
afterDeclarationPaths: [[...COMMON_PATH, 'examples', 'example1', 'description']],
134+
afterDeclarationPaths: [[...COMMON_PATH, 'example1', 'description']],
135135
type: annotation,
136136
}),
137137
]))
@@ -143,8 +143,8 @@ describe('Openapi3 Response Body Examples', () => {
143143
expect(result).toEqual(diffsMatcher([
144144
expect.objectContaining({
145145
action: DiffAction.replace,
146-
beforeDeclarationPaths: [[...COMMON_PATH, 'examples', 'example1', 'description']],
147-
afterDeclarationPaths: [[...COMMON_PATH, 'examples', 'example1', 'description']],
146+
beforeDeclarationPaths: [[...COMMON_PATH, 'example1', 'description']],
147+
afterDeclarationPaths: [[...COMMON_PATH, 'example1', 'description']],
148148
type: annotation,
149149
}),
150150
]))
@@ -156,16 +156,14 @@ describe('Openapi3 Response Body Examples', () => {
156156
expect(result).toEqual(diffsMatcher([
157157
expect.objectContaining({
158158
action: DiffAction.remove,
159-
beforeDeclarationPaths: [[...COMMON_PATH, 'examples', 'example1', 'description']],
159+
beforeDeclarationPaths: [[...COMMON_PATH, 'example1', 'description']],
160160
type: annotation,
161161
}),
162162
]))
163163
})
164164
})
165165

166-
const PATH_TO_RESPONSES_DESCRIPTION = ['paths', '/pet', 'post', 'responses', '200', 'content', 'application/json', 'examples', 'ex1']
167166
const PATH_TO_COMPONENTS_DESCRIPTION = ['components', 'examples', 'ex1', 'description']
168-
169167
describe('Reference object. Response body examples. Description fields in ref object', () => {
170-
runRefObjectDescriptionTests(SUITE_ID, PATH_TO_RESPONSES_DESCRIPTION, PATH_TO_COMPONENTS_DESCRIPTION)
168+
runRefObjectDescriptionTests(SUITE_ID, [...COMMON_PATH, 'ex1'], PATH_TO_COMPONENTS_DESCRIPTION)
171169
})

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -254,9 +254,8 @@ describe('Openapi3 Response', () => {
254254
})
255255
})
256256

257-
const PATH_TO_RESPONSES_DESCRIPTION = ['paths', '/pet', 'post', 'responses', '200']
257+
const RESPONSES_POST_PATH = ['paths', '/path1', 'post', 'responses']
258258
const PATH_TO_COMPONENTS_DESCRIPTION = ['components', 'responses', 'response200', 'description']
259-
260259
describe('Reference object. Response. Description fields in ref object', () => {
261-
runRefObjectDescriptionTests(SUITE_ID, PATH_TO_RESPONSES_DESCRIPTION, PATH_TO_COMPONENTS_DESCRIPTION)
260+
runRefObjectDescriptionTests(SUITE_ID, [...RESPONSES_POST_PATH, '200'], PATH_TO_COMPONENTS_DESCRIPTION)
262261
})

0 commit comments

Comments
 (0)