我們有一個用Java編寫的(用Wildfly託管的)其他API。我們的服務以kubernetes(GKE)運行。我們希望利用雲端點來跟蹤API的使用情況和響應速度。這個API並不是什麼新東西,我們一直在運送與它交互多年的軟件。它也相當大(數千種公共方法)。我們的API有Swagger文檔,並且沒有驗證錯誤。當我嘗試使用我們的Swagger時:谷歌雲終端機構陣列
gcloud beta service-management deploy swagger.yaml
這並不成功。我碰到下面的錯誤重複237次:
ERROR: unknown location: http: body field path 'body' must be a non-repeated message.
我已經跟蹤它到237種方法,包括在身體參數JSON數組。在我們的API中,這些是接受或返回對象列表的方法。 有什麼辦法可以讓我接受service-management deploy
?改變我們的API不是一種選擇,但我們真的希望能夠使用端點。
例如,這種方法簽名:
@PUT
@Path ("/foobars/undelete")
@Consumes (MediaType.APPLICATION_JSON)
@Produces (MediaType.APPLICATION_JSON)
@ApiOperation (value = "Undelete foobars")
@ApiResponses (value =
{
@ApiResponse (
code = 200,
message = "foobars undeleted",
response = FooBar.class,
responseContainer = "List"
) , @ApiResponse (
code = 206,
message = "Not all foobars undeleted",
response = FooBar.class,
responseContainer = "List"
) , @ApiResponse (
code = 410,
message = "Not found"
) , @ApiResponse (
code = 500,
message = "Server Error"
)
})
public Response undeleteFooBars (@ApiParam (value = "FooBar ID List") List<UUID> entityIds)
生成此招搖片段:
"/foobars/undelete":
put:
tags:
- foo
summary: Undelete FooBars
description: ''
operationId: undeleteFooBars
consumes:
- application/json
produces:
- application/json
parameters:
- in: body
name: body
description: FooBar ID List
required: false
schema:
type: array
items:
type: string
format: uuid
responses:
'200':
description: Foo Bars undeleted
schema:
type: array
items:
"$ref": "#/definitions/FooBar"
'206':
description: Not all FooBars undeleted
schema:
type: array
items:
"$ref": "#/definitions/FooBar"
'410':
description: Not found
'500':
description: Server Error