Forum Discussion

BATMAN_2008's avatar
New Contributor
3 years ago

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:


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.


No RepliesBe the first to reply