Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SpringDocUI doest add Javadoc into swagger from abstract class #2744

Closed
SashaVolushkova opened this issue Oct 2, 2024 · 0 comments
Closed

Comments

@SashaVolushkova
Copy link

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

@SashaVolushkova SashaVolushkova changed the title JavaDoc doest add into swagger with abstract class JavaDoc doest add into swagger from abstract class Oct 3, 2024
@SashaVolushkova SashaVolushkova changed the title JavaDoc doest add into swagger from abstract class SpringDocUI doest add Javadoc into swagger from abstract class Oct 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant