说我有一个像
这样的参数化资源网址/customers/{CUSTOMER-ID}/ownedItems/{ITEM-ID}
我应该如何注释/拆分我的喷涂路径(使用spray-swagger插件)来生成一个文档,将{CUSTOMER-ID}识别为正确的路径参数?
我的问题是顶级@Api注释采用路径但没有参数,而@ApiOperation可以使用路径参数注释,但这些注释会在末尾附加。换句话说,如果我写:
@Api(value = "/customers/{CUSTOMER-ID}")
@ApiOperation(httpMethod = "GET")
@ApiImplicitParams(Array(
new ApiImplicitParam(name = "ITEM-ID", required = true, dataType = "string", paramType = "path"))
我只在UI中使用ITEM-ID作为可测试参数,而在{}中报告的CUSTOMER-ID只是一个字符串。
我希望两者都是路径参数。
有什么想法吗?
答案 0 :(得分:0)
客户是您的@Api入口点,而不是路径参数。路径参数必须仅用于@ApiOperation,如下所示(更多样本):
@Api(value = "/customers")
@ApiOperation(value = "/{CUSTOMER-ID}/ownedItems/{ITEM-ID}", httpMethod = "GET")
@ApiImplicitParams(Array(
new ApiImplicitParam(name = "CUSTOMER-ID", required = true, dataType = "string", paramType = "path"),
new ApiImplicitParam(name = "ITEM-ID", required = true, dataType = "string", paramType = "path"))
@ApiOperation(value = "/{CUSTOMER-ID}", httpMethod = "GET")
@ApiImplicitParams(Array(
new ApiImplicitParam(name = "CUSTOMER-ID", required = true, dataType = "string", paramType = "path"))
@ApiOperation(value = "/", httpMethod = "POST")