@@ -5,12 +5,7 @@ import { runRefObjectDescriptionTests } from './templates/reference-object-31.te
55
66const  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
1510describe ( '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' ] 
172166const  PATH_TO_COMPONENTS_DESCRIPTION  =  [ 'components' ,  'examples' ,  'ex1' ,  'description' ] 
173167
174168describe ( '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} ) 
0 commit comments