我们在接口上选择REST定义,如:
public inteface Bitacora { ... }
然后实现:
public class BitacoraResource implements Bitacora { ... }
经过大量测试后,我们看到Swagger只有在定义是一个类而不是接口时才能工作。
是否有解决方案让Swagger使用接口而不是类?
@Provider
@Path("/bitacora")
@Api(value = "/bitacora", description = "API")
public class Bitacora {
@GET
@Produces({MediaType.TEXT_XML,MediaType.APPLICATION_JSON})
@Wrapped(element="bitacora")
@GZIP
@ApiOperation(value = "obtiene info",notes = "obtiene info bitacora",consumes="*/*",produces= "*/*")
@ApiResponses(value = { @ApiResponse(code = 200, message = "ok"),@ApiResponse(code = 400, message = "sinlistar"), @ApiResponse(code = 404, message = "error") })
public Collection<Favorito> listar(@HeaderParam("data") String data) {
return null;
}
}
答案 0 :(得分:0)
如果您无法与REST端点进行交互,则该端点不符合OpenAPI(Swagger)规范。 Swagger应该包含只能通过类而不是接口才能实现的工作端点。
有关其他详细信息,请参考my answer。