@@ -146,7 +146,7 @@ class BaseExamplesProcessor {
146
146
// Convert to prettified JSON string
147
147
example . value = JSON . stringify ( example . value , null , 2 )
148
148
}
149
- examples [ exampleName ] = example
149
+ examples . set ( exampleName , example )
150
150
}
151
151
return examples
152
152
}
@@ -189,7 +189,10 @@ class RequestExamplesProcessor extends BaseExamplesProcessor {
189
189
const examplesRequestSubfolder = this . getExamplesRequestSubfolder ( examplesFolder )
190
190
// If there is an examples/request folder, add the request examples to the model.
191
191
if ( examplesRequestSubfolder !== undefined ) {
192
- requestDefinition . examples = this . getExampleMap ( examplesRequestSubfolder )
192
+ const examples = this . getExampleMap ( examplesRequestSubfolder )
193
+ if ( examples . size > 0 ) {
194
+ requestDefinition . examples = Object . fromEntries ( examples )
195
+ }
193
196
}
194
197
}
195
198
}
@@ -223,7 +226,7 @@ class ResponseExamplesProcessor extends BaseExamplesProcessor {
223
226
const subfolders = this . getSubfolders ( examplesSubfolder )
224
227
// If we have a "response" subfolder, stop there and return.
225
228
// We should not have a mix of response and {nnn}_response folders.
226
- if ( 'response' in subfolders ) {
229
+ if ( subfolders . includes ( 'response' ) ) {
227
230
const responseSubfolder = path . join ( examplesSubfolder , 'response' )
228
231
return new Map ( [ [ '200' , responseSubfolder ] ] )
229
232
}
@@ -255,7 +258,10 @@ class ResponseExamplesProcessor extends BaseExamplesProcessor {
255
258
// If there is an examples/response or examples/200_response folder,
256
259
// add the response examples to the model.
257
260
if ( examples200ResponseSubfolder !== undefined ) {
258
- responseDefinition . examples = this . getExampleMap ( examples200ResponseSubfolder )
261
+ const examples = this . getExampleMap ( examples200ResponseSubfolder )
262
+ if ( examples . size > 0 ) {
263
+ responseDefinition . examples = Object . fromEntries ( examples )
264
+ }
259
265
}
260
266
}
261
267
}
0 commit comments