2016-07-28 58 views
0

我試圖用swaggeUI創建一個REST方法。SwaggerUi REST方法 - 方法產生和使用完全相同的MIME類型

是SEACH用戶的ID和一個又一個的名字,如下的方法:

@Produces({ MediaType.APPLICATION_JSON }) 
    @Path("/{firstName}") 
    @GET 
    @ApiOperation(value = "Find User by e-mail", notes = "Find User by e-mail", response = User.class) 
    @ApiResponses({ 
     @ApiResponse(code = 404, message = "User with such e-mail doesn't exists")    
    }) 
    public User getUserByFirstName(@ApiParam(value = "E-Mail address to lookup for", required = true) @PathParam("email") final String email); 


@GET 
    @Path("/{userId}") 
    @Nullable 
    @Produces(MediaType.APPLICATION_JSON) 
    User getUserById(@Nonnull @PathParam("userId") Long userId); 
建設我得到這個錯誤代碼時

Following issues have been detected: WARNING: A resource model has ambiguous (sub-)resource method for HTTP method GET and input mime-types as defined by"@Consumes" and "@Produces" annotations at Java methods User getUserByFirstName(java.lang.String) and public abstract User getUserById(java.lang.Long) at matching regular expression /([^/]+). These two methods produces and consumes exactly the same mime-types and therefore their invocation as a resource methods will always fail. WARNING: The (sub)resource method indexUsers in UserService contains empty path annotation.

我是新與REST ,我需要幫助才能解決此問題。

謝謝

回答

1

嘗試更改您的@Path定義。它無法分辨Long是否應該是數字,或者String {firstname}可能是Long。

嘗試:

@Path("/name/{firstname}") 
.... 
@Path("/id/{userid}") 
相關問題