swagger 2.0 - how to solve same response class names in different packages issue in spring boot application
Asked Answered
P

2

6

For example there are two classes with same name Group in different packages. But when referring to models in swagger ui only one model is being shown and even the response mapping is not proper, swagger is incorrectly referring to these models.

Poisonous answered 14/12, 2020 at 5:38 Comment(2)
One workaround is using @ApiModel on both the models. Is there any better solution.Poisonous
Did you find a solution to this problem?Fairspoken
L
14

Yes. Adding the below property solves this issue.

springdoc.use-fqn=true

But after adding this, the schemas in swagger ui start showing up with the complete package name. To avoid this try annotating your model classes with:

@Schema(name = "class name to be displayed")
Lornalorne answered 9/12, 2021 at 17:45 Comment(0)
B
5

I meet the same problem today with springdoc-openapi-ui:1.5.9, and maybe solved it.

Simply add key-value pairs to application.properties.

springdoc.use-fqn=true

Then org.springdoc.core.SpringDocConfigProperties read this value, and pass it to io.swagger.v3.core.jackson.TypeNameResolver.

Boilermaker answered 2/11, 2021 at 14:46 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.