当前位置: 首页>>代码示例>>Java>>正文


Java Swagger2Controller类代码示例

本文整理汇总了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;
}
 
开发者ID:xetys,项目名称:jhipster-ribbon-hystrix,代码行数:20,代码来源:SwaggerBasePathRewritingFilter.java

示例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;
}
 
开发者ID:axel-halin,项目名称:Thesis-JHipster,代码行数:23,代码来源:_SwaggerBasePathRewritingFilter.java

示例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;
}
 
开发者ID:jhipster,项目名称:jhipster-registry,代码行数:22,代码来源:SwaggerBasePathRewritingFilter.java

示例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;
}
 
开发者ID:jhipster,项目名称:generator-jhipster,代码行数:23,代码来源:_SwaggerBasePathRewritingFilter.java

示例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


注:本文中的springfox.documentation.swagger2.web.Swagger2Controller类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。