我有带有基本 REST 的 wildfly swarm 服务,我想用它配置 swagger ui。目前它作为 jar 启动
这是主文件
Container container = new Container();
SwaggerWebAppFraction fraction = new SwaggerWebAppFraction();
//fraction.addWebContent(System.getProperty("swarm.swagger.ui.resources"));
//fraction.addWebContent("/");
// fraction.addWebContent("swagger-webapp-ui.war" + Container.VERSION);
container.fraction(fraction);
final JAXRSArchive deployment = ShrinkWrap.create(JAXRSArchive.class);
deployment.addResource(Main.class);
deployment.addResource(TimeResource.class);
deployment.addResource(CORSFilter.class);
deployment.addResource(JAXRSConfiguration.class);
// Enable the swagger bits
final SwaggerArchive archive = deployment.as(SwaggerArchive.class);
// Tell swagger where our resources are
archive.setResourcePackages("org");
//archive.setTitle("Swagger Demo");
container.start();
container.deploy(deployment);
当我访问http://localhost:8080/swagger时,我只看到这种输出
{"swagger":"2.0","info":{},"basePath":"/","tags":[{"name":"time"}],"paths":{"/time/now":{"get":{"tags":["time"],"summary":"Get the current time","description":"Returns the time as a string","operationId":"get","produces":["application/json"],"parameters":[],"responses":{"200":{"description":"successful operation","schema":{"type":"string"}}}}}}}
只是json! http://localhost:8080/swagger-ui无法访问
如何使用 swagger ui 正确配置或启动 wildfly swarm?哪里有错?