Description
Is your feature request related to a problem? Please describe.
Hi,
We are working on Java 17 with 'org.springframework.boot' version '3.2.3'.
My problem is that I want to generate an openApi description for one POST endpoint which in request body is using a generic type.
It is easy to generate a schema with @Schema(oneOf = Foo.class, Bar.class) for a generic object
Example:
public class ImportBar<T extends ImportableFoo> {
private UUID uuid;
@Schema(decsription = "where are my examples!?", oneOf = Foo.class, Bar.class)
private T genericItem;
}
I know that Swagger is not your project but if I visualise this in Swagger I will have list of schemas but ony one example of request body with fields given by Foo.class.
But when there is an "examples" field in OpenApi I have a drop down so I can choose an example.
What I would like to have is to obtain something I can do with annotation @ExampleObject - but using my actual java classes not the String. I have 6 implementations of ImportableFoo and each have 25 fields. It is not possible to mantain it using String in annotations.
So my desired OpenApi:
/import/foo:
post:
tags:
- bar-controller
operationId: importFoo
requestBody:
content:
application/json:
schema:
type: array
items:
$ref: '#/components/schemas/ImportRequestImportableFoo'
examples:
MessageItem:
Describe the solution you'd like
I would like that "exaples" would be generated - I think based on the schemas as there I can specify example for each one with annotation @Schema(name = foo, example = "bar") - with some annotation or extended version of @ExampleObject annotation in controller
Describe alternatives you've considered
Using @ExampleObject with serialized class as String is not really a solution for this problem
Additional context