@ModelAttribute表演像身体一样招摇

发布于 2025-02-13 03:58:31 字数 753 浏览 0 评论 0原文

我使用org.springdoc:springdoc-openapi-ui:1.6.9

我有控制器:

@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;
}

我需要模型绘制以显示为

但是是真实的表演,形式为 body

如果添加@schema(name =”这是字段”)字段 - 结果

请告诉我。我需要做什么,以使我的@modelattribute显示为参数字段?

I use org.springdoc:springdoc-openapi-ui:1.6.9

I have controller:

@GetMapping
public ResponseEntity<String> getApplications(@ModelAttribute ApplicationFilter applicationFilter){return null;}

And have class param:

@Getter
@Setter
@NoArgsConstructor
public class ApplicationFilter {

  @Parameter(name = "ids", required = true)
  private List<Long> ids;
}

I need ModelAttribute to be displayed as parameter fields in Swagger.

But is real show in the form of body

If add @Schema(name = "This is field") over field - result

Please tell me. What do I need to do so that my @ModelAttribute is displayed as parameter fields?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

方觉久 2025-02-20 03:58:31

找到了适合我的解决方案:

@GetMapping
public ResponseEntity<String> getApplications(@ParameterObject @ModelAttribute ApplicationFilter applicationFilter){return null;}

添加注释@parameterObject

Found a solution that suits me:

@GetMapping
public ResponseEntity<String> getApplications(@ParameterObject @ModelAttribute ApplicationFilter applicationFilter){return null;}

add annotation @ParameterObject

昔梦 2025-02-20 03:58:31

请注意,您还使用@parameterObject对类注释,无需在Controller的参数中指定该注释。

Note that you also annotate your class with @ParameterObject, there is no need to to specify that annotation in controller's arguments.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文