2

I have a Spring Boot application with a REST API that returns the following object:

public class Response {
    private DTO data;
    private Error error;
}

DTO is an abstract class for all DTOs:

public abstract class DTO { }

The subclass:

public class CountryDTO extends DTO {
  private Long id;
  private String code;
  private String name;
}

pom.xml:

<dependency>
  <groupId>io.springfox</groupId>
  <artifactId>springfox-boot-starter</artifactId>
  <version>3.0.0</version>
</dependency>

When I check the API documentation in Swagger UI, it does not show the details of the real DTO that I send as part of the response. Instead, Swagger UI just shows:

{
  "data": {},
  "error": {
    "message": "string"
  }
}

Is there a way to tell Swagger UI to show the correct the correct DTO JSON that I will return as part of this API?

user3586286
  • 321
  • 1
  • 3
  • 9
  • Can you post the DTO class with the relevant annotations? What language and library do you use (e.g. Java+Springfox, Java+Springdoc, .NET+Swashbuckle.AspNetCore, etc.)? – Helen Mar 30 '23 at 12:01
  • io.springfox springfox-boot-starter 3.0.0 spring boot application and the dto class: public abstract class DTO { } while the subclass ``` public class CountryDTO extends DTO{ private Long id; private String code; private String name; } ``` – user3586286 Mar 30 '23 at 13:18

0 Answers0