我注意到,当使用JAX-RS和Swagger UI依赖项构建Thorntail REST应用程序时,由Swagger UI生成的REST调用使用 https 而不是 http 。
这是我正在使用的REST服务:
@Path("/time")
@Api(value = "/time", description = "Get the time", tags = "time")
@Produces(MediaType.APPLICATION_JSON)
public class HelloWorldEndpoint {
@GET
@Path("/now")
@ApiOperation(value = "Get the current time",
notes = "Returns the time as a string",
response = String.class
)
@Produces(MediaType.APPLICATION_JSON)
public String get() {
return String.format("{\"value\" : \"The time is %s\"}", new Date());
}
}
以及依赖项:
<dependency>
<groupId>io.thorntail</groupId>
<artifactId>swagger</artifactId>
</dependency>
<dependency>
<groupId>io.thorntail</groupId>
<artifactId>jaxrs</artifactId>
</dependency>
<dependency>
<groupId>io.thorntail</groupId>
<artifactId>swagger-webapp</artifactId>
</dependency>
在这种情况下,生成的REST调用是:
curl -X GET "https://localhost:8080/time/now" -H "accept: application/json"
返回:
curl: (35) SSL received a record that exceeded the maximum permissible length.
是否有任何参数(@Api?)强制使用“ http”而不是“ https”?
答案 0 :(得分:0)
在我这边,我在project-defaults.yml中使用了此配置
thorntail:
deployment:
my-webapp.war:
swagger:
schemes:
- http