我已经为jboss7.2完成了针对泽西REST服务的代码 . 下面是我的REST与swagger anotation . 但是我不能为样本休息服务生成swagger doc . 任何人都可以帮助我逐步使用swagger生成休息文档
@Api(value="Employee" ,description="manage Emnployee")
@Path("/employee")
public class TestServices {
@Path("/get/{id}")
@GET
@Produces(MediaType.APPLICATION_JSON)
@ApiOperation(value="List all people", notes="List all people using paging")
public Response getEmployee(@PathParam("id") String empId){
System.out.println("Employee ID : "+empId);
Empolyee emp= new Empolyee(empId, "SAnjay");
return Response.status(200).entity(emp).build();
}
1 回答
我对swagger-core servlet运气不错,并将swagger-ui指向您映射此servlet的位置 .
对 Jersey 2.X见:https://github.com/swagger-api/swagger-core/wiki/Swagger-Core-Jersey-2.X-Project-Setup#hooking-up-swagger-core-in-your-application
请看:https://github.com/swagger-api/swagger-core/wiki/Java-JAXRS-Quickstart
为了生成静态文档,你需要maven-plugin https://github.com/kongchen/swagger-maven-plugin
我从来没有运气这个......我理解静态doc生成的必要性
我使用:https://github.com/teamcarma/swagger-jaxrs-doclet与Maven生成静态Swagger-UI文件
此外,该项目基于JAX-RS注释和JavaDoc生成swagger-ui的文件,因此不需要Swagger注释