0
我正在用swagger來記錄我的休息apis。Swagger不採用空值的方法
一個例子:
@RequestMapping(value = "/abc/api/fruit", produces = "application/json")
@Controller
@Api(value = "Fruit", description = "api for fruits", produces = "application/json")
public class FruitResource {
@RequestMapping(method = RequestMethod.GET, value = "")
@ResponseBody
@ApiOperation(httpMethod = "GET", value = "Resource to get fruits", produces = "application/json", notes = "get fruits", response=Fruit.class)
public ResponseEntity<Fruit> getFruits() throws Exception {
return new ResponseEntity<Fruit>(someServiceCallToGetFruits(), HttpStatus.OK);
}
}
如上所見,在RequestMapping
的value
上述方法是空的( 「」)。
正因爲如此,這個班級和方法沒有被大肆宣揚。
但是,當我改變RequestMapping線上面的方法如下:
@RequestMapping(method = RequestMethod.GET, value = "/")
它開始工作。
這是一個錯誤?我怎樣才能讓swagger與""
路徑值一起工作。我不想把"/"
放在所有這些方法之上。
你試過不指定空值?像'@RequestMapping(method = RequestMethod.GET)'或'@GetMapping()'? –
這裏是@ @ RequestMapping,是一個註釋?當它與value =「/」一起工作時,swagger上顯示的完整路徑是什麼? – nullpointer
@AlekseiBudiak:工作..謝謝! – Nik