[英]swagger-core v3 ignore my configurations in javax.ws.rs.core.Application
Using swagger-core v3 2.1.6 these three configurations produce same openapi.json result.使用 swagger-core v3 2.1.6 这三个配置产生相同的 openapi.json 结果。
No configuration:无配置:
@ApplicationPath("/rest")
public class AuthRestConfig extends Application {
public AuthRestConfig() {
}
}
Server Configuration, I need to use this kind of conf:服务器配置,我需要使用这种conf:
@ApplicationPath("/rest")
public class AuthRestConfig extends Application {
public AuthRestConfig(@Context ServletConfig servletConfig) {
super();
OpenAPI oas = new OpenAPI();
Info info = new Info()
.title("Suma Automaton OpenAPI")
.description("This is a sample server Petstore server. You can find out more about Swagger "
+ "at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, "
+ "you can use the api key `special-key` to test the authorization filters.")
.termsOfService("http://swagger.io/terms/")
.contact(new Contact()
.email("baldodavi@gmail.com"));
oas.info(info);
String url = "/suma-automaton-ms";
List<Server> servers = new ArrayList<>();
Server server = new Server();
server.setUrl(url);
servers.add(server);
oas.setServers(servers);
SwaggerConfiguration oasConfig = new SwaggerConfiguration()
.openAPI(oas)
.prettyPrint(true)
.resourcePackages(Stream.of("io.swagger.sample.resource").collect(Collectors.toSet()));
try {
new JaxrsOpenApiContextBuilder<>()
.servletConfig(servletConfig)
.application(this)
.openApiConfiguration(oasConfig)
.buildContext(true);
} catch (OpenApiConfigurationException e) {
throw new RuntimeException(e.getMessage(), e);
}
}
}
Any suggestion about this behavior?关于这种行为有什么建议吗? Is there something I misunderstood?
有什么我误解了吗? Consider I've the same behaviour also using standard configuration reported in https://github.com/swagger-api/swagger-core/wiki/Swagger-2.X---Integration-and-configuration#jax-rs-application
考虑到我也使用https://github.com/swagger-api/swagger-core/wiki/Swagger-2.X---Integration-and-configuration#jax-rs-application中报告的标准配置也有相同的行为
Add this to your AuthRestConfig class:将此添加到您的 AuthRestConfig class:
import io.swagger.v3.jaxrs2.integration.resources.OpenApiResource;
@Override
public Set<Class<?>> getClasses() {
Set<Class<?>> resources = new HashSet<>();
resources.add(OpenApiResource.class);
return resources;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.