本文整理汇总了Java中springfox.documentation.swagger2.web.Swagger2Controller类的典型用法代码示例。如果您正苦于以下问题:Java Swagger2Controller类的具体用法?Java Swagger2Controller怎么用?Java Swagger2Controller使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Swagger2Controller类属于springfox.documentation.swagger2.web包,在下文中一共展示了Swagger2Controller类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: rewriteBasePath
import springfox.documentation.swagger2.web.Swagger2Controller; //导入依赖的package包/类
private String rewriteBasePath(RequestContext context) {
InputStream responseDataStream = context.getResponseDataStream();
String requestUri = RequestContext.getCurrentContext().getRequest().getRequestURI();
try {
String response = CharStreams.toString(new InputStreamReader(responseDataStream));
if (response != null) {
LinkedHashMap<String, Object> map = this.mapper.readValue(response, LinkedHashMap.class);
String basePath = requestUri.replace(Swagger2Controller.DEFAULT_URL,"");
map.put("basePath",basePath);
log.debug("Swagger-docs: rewritten Base URL with correct micro-service route: {}", basePath);
return mapper.writeValueAsString(map);
}
}
catch (IOException e){
log.error("Swagger-docs filter error", e);
}
return null;
}
示例2: rewriteBasePath
import springfox.documentation.swagger2.web.Swagger2Controller; //导入依赖的package包/类
private String rewriteBasePath(RequestContext context) {
InputStream responseDataStream = context.getResponseDataStream();
String requestUri = RequestContext.getCurrentContext().getRequest().getRequestURI();
try {
if (context.getResponseGZipped()) {
responseDataStream = new GZIPInputStream(context.getResponseDataStream());
}
String response = IOUtils.toString(responseDataStream, Charsets.UTF_8);
if (response != null) {
LinkedHashMap<String, Object> map = this.mapper.readValue(response, LinkedHashMap.class);
String basePath = requestUri.replace(Swagger2Controller.DEFAULT_URL,"");
map.put("basePath",basePath);
log.debug("Swagger-docs: rewritten Base URL with correct micro-service route: {}", basePath);
return mapper.writeValueAsString(map);
}
}
catch (IOException e){
log.error("Swagger-docs filter error", e);
}
return null;
}
示例3: rewriteBasePath
import springfox.documentation.swagger2.web.Swagger2Controller; //导入依赖的package包/类
private String rewriteBasePath(RequestContext context) {
InputStream responseDataStream = context.getResponseDataStream();
String requestUri = RequestContext.getCurrentContext().getRequest().getRequestURI();
try {
if (context.getResponseGZipped()) {
responseDataStream = new GZIPInputStream(context.getResponseDataStream());
}
String response = IOUtils.toString(responseDataStream, StandardCharsets.UTF_8);
if (response != null) {
LinkedHashMap<String, Object> map = this.mapper.readValue(response, LinkedHashMap.class);
String basePath = requestUri.replace(Swagger2Controller.DEFAULT_URL,"");
map.put("basePath",basePath);
log.debug("Swagger-docs: rewritten Base URL with correct micro-service route: {}", basePath);
return mapper.writeValueAsString(map);
}
} catch (IOException e) {
log.error("Swagger-docs filter error", e);
}
return null;
}
示例4: rewriteBasePath
import springfox.documentation.swagger2.web.Swagger2Controller; //导入依赖的package包/类
@SuppressWarnings("unchecked")
private String rewriteBasePath(RequestContext context) {
InputStream responseDataStream = context.getResponseDataStream();
String requestUri = RequestContext.getCurrentContext().getRequest().getRequestURI();
try {
if (context.getResponseGZipped()) {
responseDataStream = new GZIPInputStream(context.getResponseDataStream());
}
String response = IOUtils.toString(responseDataStream, StandardCharsets.UTF_8);
if (response != null) {
LinkedHashMap<String, Object> map = this.mapper.readValue(response, LinkedHashMap.class);
String basePath = requestUri.replace(Swagger2Controller.DEFAULT_URL,"");
map.put("basePath",basePath);
log.debug("Swagger-docs: rewritten Base URL with correct micro-service route: {}", basePath);
return mapper.writeValueAsString(map);
}
} catch (IOException e) {
log.error("Swagger-docs filter error", e);
}
return null;
}
示例5: shouldFilter
import springfox.documentation.swagger2.web.Swagger2Controller; //导入依赖的package包/类
/**
* Filter requests to micro-services Swagger docs.
*/
@Override
public boolean shouldFilter() {
return RequestContext.getCurrentContext().getRequest().getRequestURI().endsWith(Swagger2Controller.DEFAULT_URL);
}
开发者ID:oktadeveloper,项目名称:jhipster-microservices-example,代码行数:8,代码来源:SwaggerBasePathRewritingFilter.java