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

x33g5p2x  于2022-01-30 转载在 其他  
字(8.4k)|赞(0)|评价(0)|浏览(104)

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

Scheme.toValue介绍

暂无

代码示例

代码示例来源:origin: AresS31/swurg

public boolean isUseHttps(Scheme scheme) {
 boolean useHttps;
 useHttps = scheme.toValue().toUpperCase().equals("HTTPS") || scheme.toValue().toUpperCase()
   .equals("WSS");
 return useHttps;
}

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

@JsonCreator
public static Scheme forValue(String value) {
  for (Scheme item : Scheme.values()) {
    if (item.toValue().equalsIgnoreCase(value)) {
      return item;
    }
  }
  return null;
}

代码示例来源:origin: io.syndesis.server/server-api-generator

private static String determineSchemeToUse(final Swagger swagger, final URI specificationUrl) {
  final List<Scheme> schemes = swagger.getSchemes();
  final boolean noSchemes = schemes == null || schemes.isEmpty();
  if (noSchemes && specificationUrl == null) {
    return null;
  }
  final String schemeToUse;
  if (noSchemes && specificationUrl != null) {
    schemeToUse = specificationUrl.getScheme();
  } else if (schemes.contains(Scheme.HTTPS)) {
    schemeToUse = "https";
  } else {
    schemeToUse = schemes.stream()//
      .filter(s -> s.toValue().startsWith("http"))//
      .map(s -> s.toValue())//
      .findFirst()//
      .orElse(null);
  }
  return schemeToUse;
}

代码示例来源:origin: io.syndesis.server/server-connector-generator

private static String determineSchemeToUse(final Swagger swagger, final URI specificationUrl) {
  final List<Scheme> schemes = swagger.getSchemes();
  final boolean noSchemes = schemes == null || schemes.isEmpty();
  if (noSchemes && specificationUrl == null) {
    return null;
  }
  final String schemeToUse;
  if (noSchemes && specificationUrl != null) {
    schemeToUse = specificationUrl.getScheme();
  } else if (schemes.contains(Scheme.HTTPS)) {
    schemeToUse = "https";
  } else {
    schemeToUse = schemes.stream()//
      .filter(s -> s.toValue().startsWith("http"))//
      .map(s -> s.toValue())//
      .findFirst()//
      .orElse(null);
  }
  return schemeToUse;
}

代码示例来源:origin: AresS31/swurg

public int getPort(
  Swagger swagger, Scheme scheme
) {
 int port;
 if (swagger.getHost().split(":").length > 1) {
  port = Integer.valueOf(swagger.getHost().split(":")[1]);
 } else {
  if (scheme.toValue().toUpperCase().equals("HTTPS")) {
   port = 443;
  } else {
   port = 80;
  }
 }
 return port;
}

代码示例来源:origin: io.syndesis.rest/rest-connector-generator

} else if (schemes.size() == 1) {
  final Scheme scheme = schemes.get(0);
  schemeToUse = scheme.toValue();
} else if (schemes.contains(Scheme.HTTPS)) {
  schemeToUse = "https";
} else {
    .filter(s -> s.toValue().startsWith("http"))//
    .toValue();

代码示例来源:origin: io.syndesis/connector-generator

} else if (schemes.size() == 1) {
  final Scheme scheme = schemes.get(0);
  schemeToUse = scheme.toValue();
} else if (schemes.contains(Scheme.HTTPS)) {
  schemeToUse = "https";
} else {
    .filter(s -> s.toValue().startsWith("http"))//
    .toValue();

代码示例来源:origin: swagger-api/swagger-parser

private List<Server> convert(List<Scheme> schemes, String host, String basePath) {
  List<Server> servers = new ArrayList<>();
  String baseUrl;
  if (StringUtils.isNotEmpty(basePath)) {
    baseUrl = basePath;
  } else {
    baseUrl = "/";
  }
  if (StringUtils.isNotEmpty(host)) {
    baseUrl = host + baseUrl;
  }
  if (!StringUtils.startsWith(baseUrl, "/") && schemes != null && !schemes.isEmpty()) {
    for (Scheme scheme : schemes) {
      Server server = new Server();
      server.setUrl(scheme.toValue() + "://" + baseUrl);
      servers.add(server);
    }
  } else {
    if (!"/".equals(baseUrl)) {
      baseUrl = "//" + baseUrl;
    }
    Server server = new Server();
    server.setUrl(baseUrl);
    servers.add(server);
  }
  return servers;
}

代码示例来源:origin: io.swagger.parser.v3/swagger-parser-v2-converter

private List<Server> convert(List<Scheme> schemes, String host, String basePath) {
  List<Server> servers = new ArrayList<>();
  String baseUrl;
  if (StringUtils.isNotEmpty(basePath)) {
    baseUrl = basePath;
  } else {
    baseUrl = "/";
  }
  if (StringUtils.isNotEmpty(host)) {
    baseUrl = host + baseUrl;
  }
  if (!StringUtils.startsWith(baseUrl, "/") && schemes != null && !schemes.isEmpty()) {
    for (Scheme scheme : schemes) {
      Server server = new Server();
      server.setUrl(scheme.toValue() + "://" + baseUrl);
      servers.add(server);
    }
  } else {
    if (!"/".equals(baseUrl)) {
      baseUrl = "//" + baseUrl;
    }
    Server server = new Server();
    server.setUrl(baseUrl);
    servers.add(server);
  }
  return servers;
}

代码示例来源:origin: org.openapitools.swagger.parser/swagger-parser-v2-converter

private List<Server> convert(List<Scheme> schemes, String host, String basePath) {
  List<Server> servers = new ArrayList<>();
  String baseUrl;
  if (StringUtils.isNotEmpty(basePath)) {
    baseUrl = basePath;
  } else {
    baseUrl = "/";
  }
  if (StringUtils.isNotEmpty(host)) {
    baseUrl = host + baseUrl;
  }
  if (!StringUtils.startsWith(baseUrl, "/") && schemes != null && !schemes.isEmpty()) {
    for (Scheme scheme : schemes) {
      Server server = new Server();
      server.setUrl(scheme.toValue() + "://" + baseUrl);
      servers.add(server);
    }
  } else {
    if (!"/".equals(baseUrl)) {
      baseUrl = "//" + baseUrl;
    }
    Server server = new Server();
    server.setUrl(baseUrl);
    servers.add(server);
  }
  return servers;
}

代码示例来源:origin: castlemock/castlemock

/**
 * The method extracts the forward address from the {@link Swagger} model.
 * @param swagger The {@link Swagger} model contains information about the source address.
 * @return The extracted source address configured in {@link Swagger}.
 */
private String getForwardAddress(final Swagger swagger){
  String schemas = "http";
  if(swagger.getSchemes() != null && !swagger.getSchemes().isEmpty()){
    schemas = swagger.getSchemes().get(0).toValue();
  }
  return schemas + "://" + swagger.getHost() + swagger.getBasePath();
}

代码示例来源:origin: org.teiid.connectors/translator-swagger

if(swagger.getSchemes().size() > 0) {
  if (this.preferredScheme == null) {
    scheme = swagger.getSchemes().get(0).toValue();
  } else {
    for (Scheme s : swagger.getSchemes()) {
      if (s.toValue().equalsIgnoreCase(this.preferredScheme)) {
        scheme = s.toValue();
        break;
      scheme = swagger.getSchemes().get(0).toValue();

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

private NewApiEntity mapSwagger12ToNewApi(Swagger swagger) {
  if (swagger == null || swagger.getInfo() == null) {
    return null;
  }
  NewApiEntity apiEntity = new NewApiEntity();
  apiEntity.setName(swagger.getInfo().getTitle());
  apiEntity.setDescription(swagger.getInfo().getDescription());
  apiEntity.setVersion(swagger.getInfo().getVersion());
  String scheme = (swagger.getSchemes() == null || swagger.getSchemes().isEmpty()) ? defaultScheme :
      swagger.getSchemes().iterator().next().toValue();
  apiEntity.setEndpoint(scheme + "://" + swagger.getHost() + swagger.getBasePath());
  apiEntity.setPaths(new ArrayList<>(
      swagger.getPaths().keySet()
          .stream()
          .map(path -> path.replaceAll("\\{(.[^/]*)\\}", ":$1"))
          .collect(Collectors.toList())));
  return apiEntity;
}

代码示例来源:origin: AresS31/swurg

operation.getKey().toString(),
swagger.getHost().split(":")[0],
scheme.toValue().toUpperCase(),
swagger.getBasePath(),
path.getKey(),

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

private NewApiEntity mapSwagger12ToNewApi(Swagger swagger) {
  if (swagger == null || swagger.getInfo() == null) {
    return null;
  }
  NewApiEntity apiEntity = new NewApiEntity();
  apiEntity.setName(swagger.getInfo().getTitle());
  apiEntity.setDescription(swagger.getInfo().getDescription());
  apiEntity.setVersion(swagger.getInfo().getVersion());
  String scheme = (swagger.getSchemes() == null || swagger.getSchemes().isEmpty()) ? defaultScheme :
      swagger.getSchemes().iterator().next().toValue();
  apiEntity.setEndpoint(scheme + "://" + swagger.getHost() + swagger.getBasePath());
  apiEntity.setPaths(new ArrayList<>(
      swagger.getPaths().keySet()
          .stream()
          .map(path -> path.replaceAll("\\{(.[^/]*)\\}", ":$1"))
          .collect(Collectors.toList())));
  return apiEntity;
}

代码示例来源:origin: io.syndesis.server/server-connector-generator

.filter(s -> s.toValue().startsWith("http"))//
  .findFirst().isPresent();
if (!hasHttpSchemes) {
    .message("Unable to determine the scheme to use: no supported scheme found within the OpenAPI specification. "
      + "Schemes given in the specification: "
      + schemes.stream().map(s -> s.toValue()).collect(Collectors.joining(", ")))
    .build());

代码示例来源:origin: io.syndesis.server/server-api-generator

.filter(s -> s.toValue().startsWith("http"))//
  .findFirst().isPresent();
if (!hasHttpSchemes) {
    .message("Unable to determine the scheme to use: no supported scheme found within the OpenAPI specification. "
      + "Schemes given in the specification: "
      + schemes.stream().map(s -> s.toValue()).collect(Collectors.joining(", ")))
    .build());

相关文章