spring - @ApiOperation 中指定的标签不会覆盖@Api swagger ui 中指定的标签
问题描述
我已将类级别的标签指定为“用户”,并在此类下指定了一个 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;
}
解决方案
我遇到了类似的问题。我正在使用springfox。如果您也在使用 springfox,也许这可能会有所帮助
https://github.com/springfox/springfox/issues/1257
简短的回答是这是意料之中的。原因是这些注解在 springfox 中的使用方式与 swagger-core 使用它的方式非常不同。例如,我们不支持像 @SwaggerDefinition 这样的结构
在这种情况下,我的建议是实现您自己的操作插件,根据您的需要覆盖这些值。
推荐阅读
- css - 你如何在反应中 mpa 一个 json const 并设置它的样式?
- python - pip install mysql-python 失败,缺少 config-win.h
- stenciljs - 如何在 StencilJS 中使用 getter/setter 处理 @Prop() 逻辑
- c++ - 如何改进以下 lambda 函数以查找向量中的前 4 个元素
- asp.net - ChangePassword 控件忽略自定义模板并呈现默认值
- pandas - 如何从熊猫“编码”数据框的列
- excel - VBA 在 Excel 中创建带有表格和签名的电子邮件
- python - 如何使用参数获取和设置属性
- localization - Is it a good idea to cascade localization translation files?
- azure - Coexistence between Azure P2S VPN and Expressroute