也許我的回答會幫助別人。
如Dilip Krishnan在his answer中,您可以使用io.swagger.annotations.ApiParam
或io.swagger.annotations.ApiImplicitParam
Swagger批註用於精細調整的自定義文檔。
@ApiParam
可以用於註冊方法參數。
@ApiImplicitParam
可以在API參數沒有明確註冊的情況下使用。
@RestController
@RequestMapping(value = "/v1/test", produces = "application/json")
@Api(value = "/v1/test")
public class TestController {
@ApiOperation(value = "Do Something method", tags = "Test method")
@RequestMapping(value = "/doSomeThing", method = RequestMethod.GET)
public Foo doSomeThing(
@ApiParam(value = "Param1 Description", required = true)
@RequestParam String param) {
throw new UnsupportedOperationException("do Some Things");
}
@ApiOperation(value = "Do Something Another method", tags = "Test method")
@ApiImplicitParams({
@ApiImplicitParam(name = "anotherParam1", value = "Another Param1 Description", paramType = "header"),
@ApiImplicitParam(name = "anotherParam1", value = "Another Param1 Description", paramType = "header")
})
@RequestMapping(value = "/doSomeThingAnother", method = RequestMethod.GET)
public Foo doSomeThingAnother(Bar bar) {
throw new UnsupportedOperationException("do Some Thing Another");
}
}
而在最後,你可以看到下面的圖片
不明白爲什麼這個問題是downvoted兩次? – Gandhi