资源内的 Swagger(喷)路径参数 url

Swagger (spray) path parameters inside resource url

假设我有一个参数化资源 url 就像

/customers/{CUSTOMER-ID}/ownedItems/{ITEM-ID}

我应该如何 annotatate/split 我的喷涂路线(使用 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,虽然在 { } 中被报告,但只是一个字符串。

我想要两个都是路径参数的东西。

有什么想法吗?

customers 是您的@Api 入口点,而不是路径参数。路径参数只能用于@Api操作如下(示例较多):

@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")