io.swagger.models.Swagger.setSchemes()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(8.5k)|赞(0)|评价(0)|浏览(185)

本文整理了Java中io.swagger.models.Swagger.setSchemes()方法的一些代码示例,展示了Swagger.setSchemes()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Swagger.setSchemes()方法的具体详情如下:
包路径:io.swagger.models.Swagger
类名称:Swagger
方法名:setSchemes

Swagger.setSchemes介绍

暂无

代码示例

代码示例来源:origin: apache/servicecomb-java-chassis

private void convertSchemes(SwaggerDefinition definitionAnnotation, Swagger swagger) {
 if (definitionAnnotation.schemes() == null) {
  return;
 }
 Stream<io.swagger.annotations.SwaggerDefinition.Scheme> stream =
   Arrays.asList(definitionAnnotation.schemes()).stream();
 List<Scheme> schemes = stream.map(this::convertScheme).collect(Collectors.toList());
 swagger.setSchemes(schemes);
}

代码示例来源:origin: io.swagger/swagger-models

public Swagger schemes(List<Scheme> schemes) {
  this.setSchemes(schemes);
  return this;
}

代码示例来源:origin: vmware/admiral

/**
 * Specify the HTTP schemes to be used in making requests.
 *
 * @param schemes The specified schemes
 * @return This instance of {@link SwaggerDocumentationAssembler}
 */
public SwaggerDocumentationAssembler setSchemes(Scheme[] schemes) {
  this.swagger.setSchemes(Arrays.asList(schemes));
  return this;
}

代码示例来源:origin: org.apache.servicecomb/swagger-generator-core

private void convertSchemes(SwaggerDefinition definitionAnnotation, Swagger swagger) {
 if (definitionAnnotation.schemes() == null) {
  return;
 }
 Stream<io.swagger.annotations.SwaggerDefinition.Scheme> stream =
   Arrays.asList(definitionAnnotation.schemes()).stream();
 List<Scheme> schemes = stream.map(this::convertScheme).collect(Collectors.toList());
 swagger.setSchemes(schemes);
}

代码示例来源:origin: org.wso2.carbon.apimgt/org.wso2.carbon.apimgt.core

private void setSwaggerSchemes(Swagger swagger, Set<String> transports) {
  List<String> swaggerSchemes = Stream.of(Scheme.values()).map(Scheme::name).collect(Collectors.toList());
  List<Scheme> schemes = new ArrayList<>();
  if (transports.size() != 0) {
    for (String transport: transports) {
      if (swaggerSchemes.contains(transport)) {
        schemes.add(Scheme.forValue(transport));
      }
    }
  }
  if (!schemes.isEmpty()) {
    swagger.setSchemes(schemes);
  }
}

代码示例来源:origin: wso2/carbon-apimgt

private void setSwaggerSchemes(Swagger swagger, Set<String> transports) {
  List<String> swaggerSchemes = Stream.of(Scheme.values()).map(Scheme::name).collect(Collectors.toList());
  List<Scheme> schemes = new ArrayList<>();
  if (transports.size() != 0) {
    for (String transport: transports) {
      if (swaggerSchemes.contains(transport)) {
        schemes.add(Scheme.forValue(transport));
      }
    }
  }
  if (!schemes.isEmpty()) {
    swagger.setSchemes(schemes);
  }
}

代码示例来源:origin: io.gravitee.management/gravitee-management-api-service

private Swagger transformV2(String content, Map<String, String> config) {
  Swagger swagger = new SwaggerParser().parse(content);
  if (swagger != null && config != null && config.get("tryItURL") != null) {
    URI newURI = URI.create(config.get("tryItURL"));
    swagger.setSchemes(Collections.singletonList(Scheme.forValue(newURI.getScheme())));
    swagger.setHost((newURI.getPort() != -1) ? newURI.getHost() + ':' + newURI.getPort() : newURI.getHost());
    swagger.setBasePath((newURI.getRawPath().isEmpty()) ? "/" : newURI.getRawPath());
  }
  return swagger;
}

代码示例来源:origin: gravitee-io/gravitee-management-rest-api

private Swagger transformV2(String content, Map<String, String> config) {
  Swagger swagger = new SwaggerParser().parse(content);
  if (swagger != null && config != null && config.get("tryItURL") != null) {
    URI newURI = URI.create(config.get("tryItURL"));
    swagger.setSchemes(Collections.singletonList(Scheme.forValue(newURI.getScheme())));
    swagger.setHost((newURI.getPort() != -1) ? newURI.getHost() + ':' + newURI.getPort() : newURI.getHost());
    swagger.setBasePath((newURI.getRawPath().isEmpty()) ? "/" : newURI.getRawPath());
  }
  return swagger;
}

代码示例来源:origin: io.gravitee.management/gravitee-management-api-service

private Swagger transformV1(String content, Map<String, String> config) {
  // Create temporary file for Swagger parser (only for descriptor version < 2.x)
  File temp = null;
  Swagger swagger = null;
  try {
    temp = createTmpSwagger1File(content);
    swagger = new SwaggerCompatConverter().read(temp.getAbsolutePath());
    if (swagger != null && config != null && config.get("tryItURL") != null) {
      URI newURI = URI.create(config.get("tryItURL"));
      swagger.setSchemes(Collections.singletonList(Scheme.forValue(newURI.getScheme())));
      swagger.setHost((newURI.getPort() != -1) ? newURI.getHost() + ':' + newURI.getPort() : newURI.getHost());
      swagger.setBasePath((newURI.getRawPath().isEmpty()) ? "/" : newURI.getRawPath());
    }
  } catch (IOException ioe) {
    // Fallback to the new parser
  } finally {
    if (temp != null) {
      temp.delete();
    }
  }
  return swagger;
}

代码示例来源:origin: gravitee-io/gravitee-management-rest-api

private Swagger transformV1(String content, Map<String, String> config) {
  // Create temporary file for Swagger parser (only for descriptor version < 2.x)
  File temp = null;
  Swagger swagger = null;
  try {
    temp = createTmpSwagger1File(content);
    swagger = new SwaggerCompatConverter().read(temp.getAbsolutePath());
    if (swagger != null && config != null && config.get("tryItURL") != null) {
      URI newURI = URI.create(config.get("tryItURL"));
      swagger.setSchemes(Collections.singletonList(Scheme.forValue(newURI.getScheme())));
      swagger.setHost((newURI.getPort() != -1) ? newURI.getHost() + ':' + newURI.getPort() : newURI.getHost());
      swagger.setBasePath((newURI.getRawPath().isEmpty()) ? "/" : newURI.getRawPath());
    }
  } catch (IOException ioe) {
    // Fallback to the new parser
  } finally {
    if (temp != null) {
      temp.delete();
    }
  }
  return swagger;
}

代码示例来源:origin: com.vmware.xenon/xenon-swagger

private void prepareSwagger() {
  List<String> json = Collections.singletonList(Operation.MEDIA_TYPE_APPLICATION_JSON);
  this.swagger.setConsumes(json);
  this.swagger.setProduces(json);
  if (this.service.getHost().getSecureListener() != null) {
    this.swagger.setSchemes(Collections.singletonList(Scheme.HTTPS));
    URI uri = this.service.getHost().getSecureUri();
    this.swagger.setHost(uri.getHost() + ":" + uri.getPort());
  } else {
    this.swagger.setSchemes(Collections.singletonList(Scheme.HTTP));
    URI uri = this.service.getHost().getPublicUri();
    this.swagger.setHost(uri.getHost() + ":" + uri.getPort());
  }
  this.swagger.setSchemes(new ArrayList<>());
  this.swagger.setInfo(this.info);
  this.swagger.setBasePath(UriUtils.URI_PATH_CHAR);
}

代码示例来源:origin: org.ballerinalang/ballerina-to-swagger

swagger.setSchemes(schemes);

代码示例来源:origin: outofcoffee/imposter

} else {
  combined.setSchemes(childSchemes);

代码示例来源:origin: FINRAOS/herd

swagger.setSchemes(schemes);

代码示例来源:origin: javagossip/dorado

_swagger.setSchemes(Arrays.asList(Scheme.HTTP, Scheme.HTTPS));

代码示例来源:origin: com.gitblit.fathom/fathom-rest-swagger

swagger.setSchemes(schemes);

代码示例来源:origin: gitblit/fathom

swagger.setSchemes(schemes);

代码示例来源:origin: com.github.phillip-kruger/apiee-core

private Swagger createSwagger(final Set<Class<?>> classes,final URL url){
  Swagger swagger = new Reader(new Swagger()).read(classes);
  
  Info info = getSwaggerInfo(swagger);
  if(info!=null)swagger.setInfo(info);
  
  Map<String, SecuritySchemeDefinition> securityDefinitions = getSecurityDefinitions(swagger);
  if(securityDefinitions!=null)swagger.setSecurityDefinitions(securityDefinitions);
  
  String consumes = whiteLabel.getProperty(CONSUMES, null);
  if(anyIsSet(consumes))swagger.setConsumes(toList(swagger.getConsumes(),consumes));
  
  String produces = whiteLabel.getProperty(PRODUCES, null);
  if(anyIsSet(produces))swagger.setProduces(toList(swagger.getProduces(),produces));
  
  String basePath = whiteLabel.getProperty(BASE_PATH, getBasePath(swagger.getBasePath(), url));
  if(anyIsSet(basePath))swagger.setBasePath(basePath);
  
  String schemes = whiteLabel.getProperty(SCHEMES, url.getProtocol().toUpperCase());
  if(anyIsSet(schemes))swagger.setSchemes(toSchemeList(swagger.getSchemes(),schemes));
      
  String host = whiteLabel.getProperty(HOST, url.getHost() + DOUBLE_POINT + url.getPort());
  if(anyIsSet(host))swagger.setHost(host);
  
  String tags = whiteLabel.getProperty(TAGS, null);
  if(anyIsSet(tags))swagger.setTags(toTagList(swagger.getTags(),tags));
  
  return swagger;
}

代码示例来源:origin: com.reprezen.genflow/genflow-api

@Override
public void swagger(Swagger swagger) {
  swagger.setSchemes(fillList(swagger.getSchemes()));
  swagger.setConsumes(fillList(swagger.getConsumes()));
  swagger.setProduces(fillList(swagger.getProduces()));
  swagger.setPaths(fillMap(swagger.getPaths()));
  swagger.setDefinitions(fillMap(swagger.getDefinitions()));
  swagger.setParameters(fillMap(swagger.getParameters()));
  swagger.setResponses(fillMap(swagger.getResponses()));
  swagger.setSecurityDefinitions(fillMap(swagger.getSecurityDefinitions()));
  swagger.setSecurity(fillList(swagger.getSecurity()));
  swagger.setTags(fillList(swagger.getTags()));
}

相关文章