I have an endpoint with multiple possible request bodies, that have same parent class. I want to be able to switch between different examples (Request bodies/classes/schemas) in Swagger. Currently it only shows 1 body for any of this schemas. How can I set schema (Java class) as an example object in OpenApi Java?
This is what I work with in my controller:
@RequestBody(content = @Content(mediaType = "application/json",
schema = @Schema(oneOf = { ARequest.class, BRequest.class}),
examples = {
@ExampleObject(name = "ARequest", ref = "#/components/schemas/ARequest"),
@ExampleObject(name = "BRequest", ref = "#/components/schemas/BRequest")
}))
What I’ve tried to do is presented on that code block (@ExampleObjec…….)