繁体   English   中英

Swagger (Springfox) 只找到控制器 @RequestBody (Spring Boot) 中使用的模型

[英]Swagger (Springfox) only finding Models used in Controller @RequestBody (Spring Boot)

基本上,我感兴趣的是 Swagger 在 swagger-ui 中显示的唯一模型是否是 RestController 方法中使用的模型。 它检测到我用@RequestBody 填充的两个 DTO,但它没有检测到用户模型,即使使用 ApiModel 注释也是如此。 如何在不制作虚拟控制器方法的情况下解决这个问题?

例如:

@PostMapping("/signin")
@ApiOperation
public String login(
        @ApiParam(value = "The login credentials DTO (username and password)", required = true) 
        @RequestBody
        @Valid LoginCredentialsDTO loginCredentialsDTO) {
    return userService.login(loginCredentialsDTO);
}

它检测模型“LoginCredentialsDTO”,因为这里在控制器方法中使用了它。

由于我只在我的控制器中使用 DTO,它没有检测到我的主模型(用户)。 我不想仅仅为了 Swagger 能够检测我的所有模型而制作一个虚拟方法。

Swagger 描述了 api 的外部接口。 当您的 User 模型未在外部使用时,将不可见。 另见 swagger.io/docs/specification/2-0/basic-structure

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM