我正在尝试基于swagger文档创建一个JAX-RS Web应用程序。招摇文件的重要部分 定义如下:
"paths": {
"/category": {
"get": {
"operationId": "listCategory",
"summary": "List or find 'Category' objects",
"tags": [
"category"
],
"parameters": [
{
"type": "string",
"required": false,
"in": "query",
"name": "fields",
"description": "Comma separated properties to display in response"
},
{
"name": "lastUpdate",
"format": "date-time",
"required": false,
"in": "query",
"type": "string",
"description": "For filtering: Date and time of the last update"
}
....
"/category/{id}": {
"get": {
"operationId": "retrieveCategory",
"summary": "Retrieves a 'Category' by Id",
"tags": [
"category"
],
"parameters": [
{
"required": true,
"type": "string",
"name": "id",
"in": "path",
"description": "Identifier of the Category"
}
]
.....
我认为上面的两个定义将在JAX-RS中正确表示如下:
@GET
@Produces({MediaType.APPLICATION_JSON})
@Consumes({MediaType.APPLICATION_JSON})
public generated.Error GET(@QueryParam("fields")java.lang.String parm0,
@QueryParam("lastUpdate")java.lang.String parm1)
{
..
}
@GET
@Produces({MediaType.APPLICATION_JSON})
@Consumes({MediaType.APPLICATION_JSON})
@Path("{id}")
public generated.Error GET(@PathParam("id")java.lang.String parm0 )
{
..
}
但是,当我部署我的应用时,我收到一条错误消息,指出上述两种资源之间存在媒体冲突。
我是否错误地实施了JAX-RS或者原始的招摇是不正确的?