Contributions
How to load all Examples and add it to the @ExampleObject without specifying the ref?
I am developing a simple application where I would like to read the files from a remote URL and add them to the `@ExampleObject`. I am able to achieve this using CustomClass `SchemaFileReader implements OASFilter` but the only problem is that I need to manually specify the `name` of the file in the ref such as `@ExampleObject(name = "Example1", ref = "Example1.json")`. Since I am reading the URL there can be many files and I do not know the name of all the files so I need an approach where I can add the `@ExampleObject` dynamically directly without specifying `ref`. Rather it should read all the data from the `examples`. Can someone please specify some logic on how to achieve this? I have posted my complete code on GitHub: https://github.com/Aravinda93/code-with-quarkus. As of now, I have added 2 files to my `@ExampleObject` but I need a dynamic approach to add all the 3 files present in the `resourses/jsonfiles` without providing the `ref` for all the files individually. To run the application, please follow the following steps: 1. Open the terminal for the project and run `mvn compile quarkus:dev` 2. Press `d` in the command line this should open the `Swagger-UI`. 3. Select `swagger-ui` from `SmallRye OpenAPI` 4. Expand `api/generate` and there we will see only 2 files under examples. I need an approach to get all 3 field without specifying the `ref` for all of them.718Views0likes0CommentsSwagger 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: 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.png1.2KViews0likes0Comments