如何使用 Jersey 禁用 OpenAPI 规范中的 /application.wadl
设置
我使用 来自 Initializr 的 Spring Boot 应用程序包含 Jersey 依赖项,并添加 io.swagger.core.v3:swagger-jaxrs2:2.1.13 作为附加依赖项。然后,我创建以下 ResourceConfig(为简洁起见,省略了注册其他资源类):
@Component
public class JerseyConfig extends ResourceConfig {
public JerseyConfig() {
this.registerClasses(
OpenApiResource.class
);
}
}
当我启动应用程序并在 http://localhost:8080/openapi.json 查看生成的 API 规范时,我发现两个路径
- : >GET /application.wadl/{path} 和
GET /application.wadl
在 Swagger UI 中,它看起来像这样:
当我向 WADL 端点发送请求时,我得到此设置中的 404 响应。我已经尝试使用此行禁用 WADL 功能,但规范仍然包含两个路径:
this.property(ServerProperties.WADL_FEATURE_DISABLE, true);
问题
如何正确禁用或隐藏 OpenAPI 规范中的这两个路径?
Setup
I use a Spring Boot app from the Initializr with Jersey dependency included and add io.swagger.core.v3:swagger-jaxrs2:2.1.13
as an additional dependency. Then I create the following ResourceConfig (registering other resource classes omitted for brevity):
@Component
public class JerseyConfig extends ResourceConfig {
public JerseyConfig() {
this.registerClasses(
OpenApiResource.class
);
}
}
When I start the application and have a look at the generated API spec at http://localhost:8080/openapi.json, I find two paths:
GET /application.wadl/{path}
andGET /application.wadl
In Swagger UI, it looks like this:
When I send a request to the WADL endpoint, I get a 404 response in this setup. I already tried to disable the WADL feature with this line, but the spec still contains the two paths:
this.property(ServerProperties.WADL_FEATURE_DISABLE, true);
Question
How do I disable or hide these two paths in the OpenAPI spec properly?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
spring 文档不支持开箱即用的 jersey/JAX-RS。
您需要在 Jersey 资源配置中控制 openapi.json 生成逻辑。
The spring doc doesn't support jersey/JAX-RS out of box.
You will need to control the openapi.json generation logic in Jersey resource configuration.
也许你可以尝试
packages-to-scan
属性May be you can try
packages-to-scan
property