io.swagger.models.Scheme类的使用及代码示例

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

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

Scheme介绍

暂无

代码示例

代码示例来源:origin: kongchen/swagger-maven-plugin

public AbstractDocumentSource(Log log, ApiSource apiSource) throws MojoFailureException {
  LOG = log;
  this.outputPath = apiSource.getOutputPath();
  this.templatePath = apiSource.getTemplatePath();
  this.swaggerPath = apiSource.getSwaggerDirectory();
  this.modelSubstitute = apiSource.getModelSubstitute();
  this.jsonExampleValues = apiSource.isJsonExampleValues();
  swagger = new Swagger();
  if (apiSource.getSchemes() != null) {
    for (String scheme : apiSource.getSchemes()) {
      swagger.scheme(Scheme.forValue(scheme));
    }
  }
  // read description from file
  if (apiSource.getDescriptionFile() != null) {
    try {
      InputStream is = new FileInputStream(apiSource.getDescriptionFile());
      apiSource.getInfo().setDescription(IOUtils.toString(is));
      is.close();
    } catch (IOException e) {
      throw new MojoFailureException(e.getMessage(), e);
    }
  }
  swagger.setHost(apiSource.getHost());
  swagger.setInfo(apiSource.getInfo());
  swagger.setBasePath(apiSource.getBasePath());
  swagger.setExternalDocs(apiSource.getExternalDocs());
  this.apiSource = apiSource;
}

代码示例来源: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: 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: wso2/msf4j

protected void readSwaggerConfig(Class<?> cls, SwaggerDefinition config) {
    swagger.setBasePath(config.basePath());
    swagger.setHost(config.host());
      swagger.addConsumes(consume);
      swagger.addScheme(Scheme.forValue(scheme.name()));

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

public Swagger getSwagger(final ZenModel model) {
 final Swagger swagger = new Swagger();
 final Function1<com.reprezen.rapidml.Extension, Boolean> _function = (com.reprezen.rapidml.Extension it) -> {
  return Boolean.valueOf(it.getName().startsWith("openAPI.tags."));
   final String description = it.getValue();
   tag.setDescription(description);
   swagger.addTag(tag);
  };
  groups.forEach(_function_1);
  _xifexpression = "/";
 swagger.setBasePath(_xifexpression);
 String _host = uri.getHost();
 String _xifexpression_1 = null;
 boolean _tripleNotEquals = (_scheme != null);
 if (_tripleNotEquals) {
  swagger.addScheme(Scheme.forValue(uri.getScheme()));

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

Swagger swagger = new Swagger();
swagger.setInfo(info);
  swagger.setExternalDocs(externalDocs);
List<Scheme> schemes = new ArrayList<>();
if (configuredSchemes.isEmpty()) {
  Scheme s = Scheme.forValue(settings.getApplicationScheme());
  if (s != null) {
    schemes.add(s);
    Scheme s = Scheme.forValue(scheme.trim());
    if (s != null) {
      schemes.add(s);

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

public Swagger parseRoot(JsonNode node, ParseResult result) {
  String location = "";
  Swagger swagger = new Swagger();
  if (node.getNodeType().equals(JsonNodeType.OBJECT)) {
    ObjectNode on = (ObjectNode)node;
    swagger.setSwagger(value);
      swagger.info(info);
        String s = getString(n, location + ".schemes", result);
        if (s != null) {
          Scheme scheme = Scheme.forValue(s);
          if (scheme != null) {
            swagger.scheme(scheme);

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

Swagger swagger = new Swagger();
swagger.setInfo(new Info().title(title).version(version));
swagger.setBasePath(basePath);
  for (String schemeParameter : schemeParameters)
    Scheme scheme = Scheme.forValue(schemeParameter);
    if (scheme == null)

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

@Override
  public Swagger configure(Swagger swagger) {
    if (schemes != null) {
      for (String scheme : schemes) {
        swagger.scheme(Scheme.forValue(scheme));
      }
    }
    if (filterClass != null) {
      try {
        SwaggerSpecFilter filter = (SwaggerSpecFilter) Class.forName(filterClass).newInstance();
        if (filter != null) {
          FilterFactory.setFilter(filter);
        }
      } catch (Exception e) {
        LOGGER.error("failed to load filter", e);
      }
    }
    return swagger.info(info)
        .host(host)
        .basePath(basePath);
  }
}

代码示例来源:origin: io.swagger/swagger-compat-spec-parser

Swagger swagger = new Swagger()
    .host(host)
    .scheme(Scheme.forValue(scheme))
    .basePath(basePath)
    .info(info)

代码示例来源: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: io.swagger/swagger-jaxrs

private void updateInfoFromConfig() {
  info = getSwagger().getInfo();
  if (info == null) {
    info = new Info();
      reader.getSwagger().scheme(Scheme.forValue(scheme));
  reader.getSwagger().setInfo(info);

代码示例来源:origin: buremba/netty-rest

String trimmed = part.trim();
if (!"".equals(trimmed)) {
  operation.scheme(Scheme.forValue(trimmed));
  if (!"".equals(tag)) {
    operation.tag(tag);
    swagger.tag(new Tag().name(tag));
Path path = swagger.getPath(operationPath);
if (path == null) {
  path = new Path();
  swagger.path(operationPath, path);

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

/* default */ static String determineHost(final Swagger swagger) {
  final Map<String, Object> vendorExtensions = Optional.ofNullable(swagger.getVendorExtensions()).orElse(Collections.emptyMap());
  final URI specificationUrl = (URI) vendorExtensions.get(BaseSwaggerConnectorGenerator.URL_EXTENSION);
  final List<Scheme> schemes = swagger.getSchemes();
  final String schemeToUse;
  if (schemes == null || schemes.isEmpty()) {
  } 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();
  final String host = swagger.getHost();
  String hostToUse;
  if (StringUtils.isEmpty(host)) {

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

private void convertProtocols(String protocols, Operation operation) {
 if (protocols == null) {
  return;
 }
 for (String protocol : protocols.split(SEPARATOR)) {
  if (StringUtils.isEmpty(protocol)) {
   continue;
  }
  operation.addScheme(Scheme.forValue(protocol));
 }
}

代码示例来源: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: 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: 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: org.teiid.connectors/translator-swagger

@Override
public void process(MetadataFactory mf, WSConnection connection) throws TranslatorException {
  Swagger swagger = getSchema(connection);
  String basePath = swagger.getBasePath();
  String scheme = null;
  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();

相关文章