Forum Discussion

BATMAN_2008's avatar
BATMAN_2008
New Contributor
3 years ago

Swagger UI does not show the externalValue URL contents while using @ExampleObject under @Content

I am developing a Quarkus REST-based application where I would like to display the API on SwaggerUI. Along with that, I would like to display the example schema file on my SwaggerUI.

 

For the Schema file, I would like to read the contents from External URL. So I am using the `external value` of the `@ExampleObject` annotation but for some reason, it does not load the file contents from the URL. It just displays:

{
"additionalProp1": {},
"additionalProp2": {},
"additionalProp3": {}
}

 

Following is the Java Resources file with my `Swagger` annotations:

import javax.ws.rs.*;

import org.eclipse.microprofile.openapi.annotations.media.ExampleObject;
import org.eclipse.microprofile.openapi.annotations.media.Schema;
import org.eclipse.microprofile.openapi.annotations.parameters.Parameter;
import org.eclipse.microprofile.openapi.annotations.parameters.RequestBody;



@Path("/api")
public class Resources{


@POST
@Path("/generate")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
@RequestBody(description = "InputTemplate",
content = @Content(examples = {
@ExampleObject(name = "Schema Example", externalValue = "https://jsonplaceholder.typicode.com/todos/1")
}))
public Multi<String> generateTestData(final Map<String, Object> input){
return null;
}
}

 

Following is the screenshot from the SwaggerUI where it's not displaying my JSON file contents:

 

 

enter image description here

 

1. Can someone please explain to me how to add the External JSON file to the example Request Body?

2. Also, is there a way to loop over the list of files present in the external URL path so it can display them one by one in the drop-down? Like if I have a list of files in
a GitHub folder, I can give the Folder URL so it can loop over files in that folder and display the contents and name in the drop-down of the Swagger UI?

 

I got this link but am unable to understand how to add `Annotations` to my JAVA Class: https://github.com/swagger-api/swagger-ui/issues/5433#issuecomment-901628267


[1]: https://i.stack.imgur.com/MGmXv.png

No RepliesBe the first to reply