首页 > 解决方案 > 隐藏 uri 别名,使其不出现在打开的 api 规范/文档中

问题描述

我有一个带有 2 条路径的控制器,如下所示,@PostMapping(path = {"/user/vehicle", "/user/car"}) public UserVehicle getUserVehicle(

但我只想将“/user/vehicle”包含在 open api 文档中(并隐藏“/user/car”)在 open api specs/doc 中。有没有办法做到这一点?

(我正在从代码生成开放 api 规范。)

标签: spring-bootswaggeropenapispringdoc

解决方案


在注解中设置hidden参数为,如下例所示true@Operation

@Operation(hidden = true)
@PostMapping(path = {"/user/vehicle", "/user/car"})

推荐阅读