我正在尝试在结果的JSON
或YAML
输出中公开swagger.json。这可能是一个奇怪的请求,但这是由于以下基础结构设置。
Internet > Azure APIM > Internal Websphere setup
Azure APIM允许防火墙规则联系内部WebSphere设置。互联网没有
Internet > Internal Websphere
所有呼叫均会失败,并显示404(未找到)。我们的应用程序在内部Websphere设置上运行,并且可以访问/swagger.json
。这适用于APIM setup
,但是我们的融合作为一个云解决方案运行,需要出于文档目的而访问/swagger.json
。
我能做到这一点的唯一方法是在APIM上可以访问/swagger.json
,而我只是找不到一种将其添加到输出中的方法。 我尝试了以下内容
public ApiRestApplicatie() {
BeanConfig beanConfig = new BeanConfig();
beanConfig.setBasePath("/myapplication/api/v1");
beanConfig.setResourcePackage("be.company.application.rest.resources,io.swagger.jaxrs.listing");
beanConfig.setPrettyPrint(true);
beanConfig.setScan(true);
}
但是,我注意到ApiListingResource
@GET
@Produces({"application/json", "application/yaml"})
@ApiOperation(
value = "The swagger definition in either JSON or YAML",
hidden = true
)
public Response getListing(@Context Application app, @Context ServletConfig sc, @Context HttpHeaders headers, @Context UriInfo uriInfo, @PathParam("type") String type) {
return StringUtils.isNotBlank(type) && type.trim().equalsIgnoreCase("yaml")
? this.getListingYamlResponse(app, this.context, sc, headers, uriInfo)
: this.getListingJsonResponse(app, this.context, sc, headers, uriInfo);
}
该操作已隐藏,我不知道是否可以覆盖该隐藏标志。有人知道我该如何进行吗?也许在
中手动添加@SwaggerDefinition(
info = @Info(
description = "Rest api emulating the customer portal api",
version = "2.0.0",
title = "My Application",
termsOfService = "http://www.company.be/terms.html",
contact = @Contact(
name = "company",
email = "info@company.be",
url = "http://www.company.be"
),
license = @License(
name = "Apache 2.0",
url = "http://www.apache.org/licenses/LICENSE-2.0"
)
),
consumes = {"application/json"},
produces = {"application/json"},
schemes = {SwaggerDefinition.Scheme.HTTPS}
)
public interface MyApplicationApiConfig {
}
如果有可能,我仍在尝试,但可以使用一些见识。