@@ -312,11 +312,16 @@ List<PostmanResponse> getResponseExamples(CodegenResponse codegenResponse, Strin
312
312
String key = entry .getKey ();
313
313
String ref = entry .getValue ().get$ref ();
314
314
315
- if (ref != null ) {
315
+ String response ;
316
+ if (ref != null ) {
317
+ // get example by $ref
316
318
Example example = this .openAPI .getComponents ().getExamples ().get (extractExampleByName (ref ));
317
- String response = new ExampleJsonHelper ().getJsonFromExample (example );
318
- postmanResponses .add (new PostmanResponse (key , codegenResponse , message , response ));
319
+ response = new ExampleJsonHelper ().getJsonFromExample (example );
320
+ } else {
321
+ // get inline example
322
+ response = new ExampleJsonHelper ().getJsonFromExample (entry .getValue ());
319
323
}
324
+ postmanResponses .add (new PostmanResponse (key , codegenResponse , message , response ));
320
325
}
321
326
322
327
} else if (codegenResponse .getContent () != null ) {
@@ -339,19 +344,29 @@ List<PostmanRequestItem> getPostmanRequests(CodegenOperation codegenOperation) {
339
344
items .add (new PostmanRequestItem (codegenOperation .summary , new ExampleJsonHelper ().getJsonFromSchema (codegenOperation .bodyParam )));
340
345
} else {
341
346
// get from examples
342
- if (codegenOperation .bodyParam .example != null ) {
343
- // find in bodyParam example
344
- items .add (new PostmanRequestItem (codegenOperation .summary , new ExampleJsonHelper ().formatJson (codegenOperation .bodyParam .example )));
345
- } else if (codegenOperation .bodyParam .getContent ().get ("application/json" ) != null &&
347
+ if (codegenOperation .bodyParam .getContent ().get ("application/json" ) != null &&
346
348
codegenOperation .bodyParam .getContent ().get ("application/json" ).getExamples () != null ) {
347
349
// find in components/examples
348
350
for (Map .Entry <String , Example > entry : codegenOperation .bodyParam .getContent ().get ("application/json" ).getExamples ().entrySet ()) {
349
351
String exampleRef = entry .getValue ().get$ref ();
350
- Example example = this .openAPI .getComponents ().getExamples ().get (extractExampleByName (exampleRef ));
351
- String exampleAsString = new ExampleJsonHelper ().getJsonFromExample (example );
352
352
353
- items .add (new PostmanRequestItem (example .getSummary (), exampleAsString , entry .getKey ()));
353
+ String exampleAsString ;
354
+ String exampleName ;
355
+ if (exampleRef != null ) {
356
+ // get example by $ref
357
+ Example example = this .openAPI .getComponents ().getExamples ().get (extractExampleByName (exampleRef ));
358
+ exampleAsString = new ExampleJsonHelper ().getJsonFromExample (example );
359
+ exampleName = example .getSummary ();
360
+ } else {
361
+ // get inline example
362
+ exampleAsString = new ExampleJsonHelper ().getJsonFromExample (entry .getValue ());
363
+ exampleName = entry .getValue ().getSummary ();
364
+ }
365
+ items .add (new PostmanRequestItem (exampleName , exampleAsString , entry .getKey ()));
354
366
}
367
+ } else if (codegenOperation .bodyParam .example != null ) {
368
+ // find in bodyParam example
369
+ items .add (new PostmanRequestItem (codegenOperation .summary , new ExampleJsonHelper ().formatJson (codegenOperation .bodyParam .example )));
355
370
} else if (codegenOperation .bodyParam .getSchema () != null ) {
356
371
// find in schema example
357
372
String exampleAsString = new ExampleJsonHelper ().formatJson (codegenOperation .bodyParam .getSchema ().getExample ());
0 commit comments