我使用org.springdoc:springdoc-openapi-ui:1.6.9
我有 Controller :
@GetMapping
public ResponseEntity<String> getApplications(@ModelAttribute ApplicationFilter applicationFilter){return null;}
并且有类参数:
@Getter
@Setter
@NoArgsConstructor
public class ApplicationFilter {
@Parameter(name = "ids", required = true)
private List<Long> ids;
}
我需要将 ModelAttribute 显示为 parameter fields Swagger 。
但真实的表现形式是body
如果在字段上添加@Schema(name = "This is field")
- result
请告诉我。我需要做什么才能让我的 @ModelAttribute 显示为参数字段?
最佳答案
找到了适合我的解决方案:
@GetMapping
public ResponseEntity<String> getApplications(@ParameterObject @ModelAttribute ApplicationFilter applicationFilter){return null;}
添加注解@ParameterObject
关于java - @ModelAttribute 像 Swagger 一样显示在 body 中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/72878154/