我构建了一个虚拟api,我想在swagger上测试它。已成功生成并执行swagger.json以显示swagger ui。但是404错误无法找到响应部分。我怎样才能解决这个问题?
这是构建的招摇过市用户界面。
这就是代码。
@Service
@Api
public class className () {
@GET
@Path("/oauth2/authorize")
@Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
@Consumes({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
@ApiOperation(value = "Authorization Grant", notes = "Authorization Grant")
@ApiResponses(value = {
@ApiResponse(code = 200, message = "Successfully Granted the Authorization"),
@ApiResponse(code = 400, message = "Missing or invalid request body"),
@ApiResponse(code = 403, message = "Forbidden"),
@ApiResponse(code = 404, message = "Schema not found"),
@ApiResponse(code = 500, message = "Internal error")})
public Response authorizationGrant(
@HeaderParam("X-AUTH-TOKEN") final String token,
@HeaderParam("X-CSRF-TOKEN") final String csrftoken,
@ApiParam(value = "Client ID", required = true) @QueryParam("Client ID") final String clientId,
@ApiParam(value = "Scope", required = true) @QueryParam("Scope") final String scope,
@ApiParam(value = "Redirect Uri", required = true) @QueryParam("Redirect Uri") final String redirectUri,
@ApiParam(value = "Response Type", required = true) @QueryParam("Response Type") final String responseType ) throws AccessDeniedException {
return Response
.status(Response.Status.OK)
.entity("{\"hello\": \"This is a JSON response\"}")
.type(MediaType.APPLICATION_JSON)
.build();
}
}
请告诉我你还需要什么来澄清这个错误。
1条答案
按热度按时间9lowa7mx1#
问题解决了!!!
我希望这个答案能对其他遭受这种麻烦的人有所帮助
错误来自@api定义部分。我应该在那部分定义路径。这是正确的代码。
}
正如您所看到的,@api定义部分需要@path注解。:)