[英]Spring boot GET and GET with parameter endpoints missing from Swagger docs
我在rest控制器中有两个get映射,一个具有必需的请求参数(项目ID),一个没有具有相同路径的请求参数。
另外,在项目中设置带有UI的基本Swagger。 首先,我从前面描述的2个get映射中随机丢失了一个,然后我用swagger注释正确地对其进行了注释,但是现在不带参数的get不断丢失。
@ApiOperation("Get item with the given ID")
@GetMapping(value="/resource/item", params = "id")
public Item getOne(@ApiParam(value = "the ID of the item want to view") @RequestParam(name = "id") Long id) {
//things...
}
@ApiOperation("Get all item")
@GetMapping(value="/resource/item")
public List<Item> getAll() {
//things...
}
有没有一种方法可以强迫摇摇欲坠地将两个地图都映射到地图?
更新:是的,路径变量可以是一个很好的解决方案,但是由于遗留原因我不能这样做。
我将使用Pathvariable而不是RequestParam
@ApiOperation("Get item with the given ID")
@GetMapping(value="/resource/item/{id}")
public Item getOne(@ApiParam(value = "the ID of the item want to view") @PathVariable Long id) {
//things...
}
这样,您的映射就不同了,并且很有可能会大张旗鼓地显示出来。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.