I'm trying to use Swagger UI to create and deploy my documentation along with the API I've written using Spring Boot. I know Swagger provides some annotations to assist with writing documentation in the actual controller classes, but I'm having trouble trying to get them to do what I need.
My problem is that I have a generic DTO class that gets returned by every call to my API. This DTO has a contents field for generic objects. If I were using the objects directly, I know I could use something like
@ApiResponse(responseCode = "200", description = "Customer found",
content = @Content(
schema = @Schema(implementation = Customer.class)))
in order to give a specification of what the JSON representation of the object should look like. However, because I'm wrapping everything in a specific ResponseDTO class, I need a way to specify what the contents field should look like, and I'm not sure which annotations I can use to accomplish this. I feel like there should definitely be something like
@ApiResponse(responseCode = "200", description = "Customer found",
content = @Content(
schema = @Schema(implementation = DTO.class,
fields = { "contents" = @Schema(implementation = Customer.class)})))
or something similar. I haven't been able to find an explanation of how to really accomplish this. My intuition suggests there should be a way to put a schema inside a schema, but maybe there's another solution I haven't considered. Any help or direction in which to look would be hugely appreciated. Thanks in advance.
