[英]springdoc-openapi generic controller type parameters support
I have the following controller code:我有以下控制器代码:
public abstract class BaseController<TClientModel extents BaseClientModel> {
@Operation
@GetMapping
Page<TClientModel> get()
}
@Data
public abstract class BaseClientModel {
int id;
}
@RestController
public class SpecificController extends BaseController<SpecificClientModel> {}
@Data
public class SpecificClientModel extends BaseClientModel {
String name;
}
Problem: When open-api markup is generated for SpecificController in Swagger, client model in the response is BaseClientModel, not SpecificClientModel and only has id field, and not id+name.问题:当Swagger为SpecificController生成open-api标记时,响应中的客户端模型是BaseClientModel,而不是SpecificClientModel,只有id字段,没有id+name。
Actual:实际的:
{
"id": 0,
}
Expected:预期的:
{
"id": 0,
"name": "string",
}
Given I have 40+ specific controllers, is there any way I can make springdoc open-api generate correct markup based on specific generic parameters?鉴于我有 40 多个特定的控制器,有什么办法可以让 springdoc open-api 根据特定的通用参数生成正确的标记?
The support is now part of v1.2.33 of springdoc-openapi.该支持现在是 springdoc-openapi v1.2.33 的一部分。 For example, if you are using spring-mvc, you can declare:例如,如果您使用的是 spring-mvc,则可以声明:
<dependency>
<groupId>org.springdoc</groupId>
<artifactId>springdoc-openapi-ui</artifactId>
<version>1.2.33</version>
</dependency>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.