【问题标题】:Tag specified in @ApiOperation not overriding tag specified in @Api swagger ui@ApiOperation 中指定的标签不会覆盖@Api swagger ui 中指定的标签
【发布时间】:2021-05-21 00:50:55
【问题描述】:

我已将类级别的标签指定为“用户”,并在此类下指定了一个 API,标签为“用户详细信息”。但是在 swagger ui 上,我可以看到这个 api 出现在两个标签下。如何仅在“用户详细信息”标签下而不是在“用户”标签下大张旗鼓地显示此 API

@Api(tags = {"Users"}, description = "Manage Users")
@RestController
@RequestMapping("/api/users")
public class UserController {

    @Autowired
    UserService userService;

    @Autowired
    UserRepository userRepository;

    @Autowired
    AuditLogService auditLogService;

    Logger logger = LoggerFactory.getLogger(UserController.class);

    @ApiOperation(tags = {"User Details"})
    @GetMapping("/lastName/{lastName}")
    public List<UserGetResponse> findByLastName(@PathVariable String lastName) throws InterruptedException {
        logger.info("Received request to get users by last name, time: {}", LocalDateTime.now());
        List<UserGetResponse> userGetResponses = userService.getUsersByLastName(lastName);
        logger.info("Received response, Going to publish message to MQ, time: {}", LocalDateTime.now());
        auditLogService.publishMessage();
        return userGetResponses;
    }

【问题讨论】:

    标签: spring swagger-ui


    【解决方案1】:

    我遇到了类似的问题。我正在使用springfox。如果您也在使用 springfox,也许这可能会有所帮助

    https://github.com/springfox/springfox/issues/1257

    简短的回答是它是预期的。原因是这些注解在 springfox 中的使用方式与 swagger-core 使用它的方式非常不同。例如我们不支持 @SwaggerDefinition 之类的构造

    在这种情况下,我的建议是实现您自己的操作插件,根据您的需要覆盖这些值。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-01-01
      • 2020-11-09
      • 2013-03-20
      • 2013-05-19
      • 2021-03-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多