Skip to content

SpringDocUI doest add Javadoc into swagger from abstract class #2744

Closed
@SashaVolushkova

Description

@SashaVolushkova

Describe the bug

I turn on javadoc for Swagger. I describe my base class (question) with javadoc. But this description is not added into Swagger (only childs javadoc is viewed)

To Reproduce
Steps to reproduce the behavior:

  • What version of spring-boot you are using: group: 'org.springdoc', name: 'springdoc-openapi-starter-webmvc-ui', version: '2.6.0'
  • What modules and versions of springdoc-openapi are you using: only springdoc-openapi-starter-webmvc-ui
  • What is the actual and the expected result using OpenAPI Description (yml or json): no metter
  • Provide with a sample code (HelloController) or Test that reproduces the problem:
@RestController
public class Controller {

    @PostMapping
    public String post(@RequestBody Test test){
        return test.toString();
    }
}

@NoArgsConstructor
@AllArgsConstructor
@ToString
@Getter
@Setter
public class Test {
    private List<Question> questions;
}

/**
 * base class for all questions in test with polymorphism
 */
@AllArgsConstructor
@NoArgsConstructor
@ToString
@Getter
@Setter
@JsonTypeInfo(
        use = JsonTypeInfo.Id.NAME,
        include = JsonTypeInfo.As.PROPERTY,
        property = "type")
@JsonSubTypes({
        @JsonSubTypes.Type(value = TestQuestion.class, name = "test"),
        @JsonSubTypes.Type(value = TextQuestion.class, name = "text")
})
public abstract class Question {
    private String question;
    private String type;
}
/**
 * test question
 */
@AllArgsConstructor
@NoArgsConstructor
@ToString
@Getter
@Setter
//@Schema(description = "Test", allOf = {Question.class}, type = "object")
public class TestQuestion extends Question {
    /**
     * list of variants
     */
    private List<String> variants;
    /**
     * correct answer
     */
    private int answer;
}
@AllArgsConstructor
@NoArgsConstructor
@ToString
@Getter
@Setter
//@Schema(description = "Text", allOf = {Question.class}, type = "object")
public class TextQuestion extends Question {
    private String answer;
}

Expected behavior

  • Java doc coments should be in swagger and in yaml and json

Screenshots
image

Additional context
if controller has an abstract class as a parameter or return type there is no this problem. Only if an abstract class used as a type of the property in another class

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions