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

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

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

Swagger.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: 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: de.taimos/spring-cxf-daemon

private void configureServerURL(Swagger swagger) {
  SplitURL split = URLUtils.splitURL(System.getProperty(SpringCXFProperties.SERVER_URL, "localhost"));
  swagger.scheme(Scheme.forValue(split.getScheme()));
  swagger.host(split.getHost() + ":" + split.getPort());
  swagger.basePath(System.getProperty(SpringCXFProperties.JAXRS_PATH));
}

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

@Test
public void shouldDetermineHostFromSpecification() {
  assertThat(determineHost(new Swagger().host("api.example.com").scheme(Scheme.HTTPS))).isEqualTo("https://api.example.com");
  assertThat(determineHost(new Swagger().host("api.example.com").scheme(Scheme.HTTP).scheme(Scheme.HTTPS)))
    .isEqualTo("https://api.example.com");
  assertThat(determineHost(new Swagger().host("api.example.com").scheme(Scheme.HTTP))).isEqualTo("http://api.example.com");
}

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

@Test
  public void shouldReturnNullIfNoHttpSchemesFound() {
    assertThat(determineHost(new Swagger().scheme(Scheme.WS).scheme(Scheme.WSS))).isNull();
  }
}

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

@Test
  public void shouldReturnNullIfNoHttpSchemesFound() {
    assertThat(determineHost(new Swagger().scheme(Scheme.WS).scheme(Scheme.WSS))).isNull();
  }
}

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

@Test
public void shouldDetermineHostFromSpecification() {
  assertThat(determineHost(new Swagger().host("api.example.com").scheme(Scheme.HTTPS))).isEqualTo("https://api.example.com");
  assertThat(determineHost(new Swagger().host("api.example.com").scheme(Scheme.HTTP).scheme(Scheme.HTTPS)))
    .isEqualTo("https://api.example.com");
  assertThat(determineHost(new Swagger().host("api.example.com").scheme(Scheme.HTTP))).isEqualTo("http://api.example.com");
}

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

@Test
public void shouldDetermineHostFromSpecification() {
  assertThat(determineHost(new Swagger().host("api.example.com").scheme(Scheme.HTTPS))).isEqualTo("https://api.example.com");
  assertThat(determineHost(new Swagger().host("api.example.com").scheme(Scheme.HTTP).scheme(Scheme.HTTPS)))
    .isEqualTo("https://api.example.com");
  assertThat(determineHost(new Swagger().host("api.example.com").scheme(Scheme.HTTP))).isEqualTo("http://api.example.com");
}

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

@Test
public void shouldDetermineHostFromSpecificationUrl() {
  final URI specificationUrl = URI.create("https://api.example.com/swagger.json");
  assertThat(determineHost(new Swagger().vendorExtension(BaseSwaggerConnectorGenerator.URL_EXTENSION, specificationUrl)))
    .isEqualTo("https://api.example.com");
  assertThat(
    determineHost(new Swagger().vendorExtension(BaseSwaggerConnectorGenerator.URL_EXTENSION, specificationUrl).scheme(Scheme.HTTP)))
      .isEqualTo("http://api.example.com");
  assertThat(determineHost(new Swagger().vendorExtension(BaseSwaggerConnectorGenerator.URL_EXTENSION, specificationUrl)
    .host("api2.example.com").scheme(Scheme.HTTP))).isEqualTo("http://api2.example.com");
}

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

@Test
public void shouldDetermineHostFromSpecificationUrl() {
  final URI specificationUrl = URI.create("https://api.example.com/swagger.json");
  assertThat(determineHost(new Swagger().vendorExtension(BaseSwaggerConnectorGenerator.URL_EXTENSION, specificationUrl)))
    .isEqualTo("https://api.example.com");
  assertThat(
    determineHost(new Swagger().vendorExtension(BaseSwaggerConnectorGenerator.URL_EXTENSION, specificationUrl).scheme(Scheme.HTTP)))
      .isEqualTo("http://api.example.com");
  assertThat(determineHost(new Swagger().vendorExtension(BaseSwaggerConnectorGenerator.URL_EXTENSION, specificationUrl)
    .host("api2.example.com").scheme(Scheme.HTTP))).isEqualTo("http://api2.example.com");
}

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

@Test
public void shouldDetermineFromHostsContainingPorts() {
  assertThat(determineHost(new Swagger().host("54.152.43.92:8080").scheme(Scheme.HTTPS))).isEqualTo("https://54.152.43.92:8080");
}

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

@Test
public void shouldDetermineHostFromSpecificationUrl() {
  final URI specificationUrl = URI.create("https://api.example.com/swagger.json");
  assertThat(determineHost(new Swagger().vendorExtension(BaseSwaggerConnectorGenerator.URL_EXTENSION, specificationUrl)))
    .isEqualTo("https://api.example.com");
  assertThat(
    determineHost(new Swagger().vendorExtension(BaseSwaggerConnectorGenerator.URL_EXTENSION, specificationUrl).scheme(Scheme.HTTP)))
      .isEqualTo("http://api.example.com");
  assertThat(determineHost(new Swagger().vendorExtension(BaseSwaggerConnectorGenerator.URL_EXTENSION, specificationUrl)
    .host("api2.example.com").scheme(Scheme.HTTP))).isEqualTo("http://api2.example.com");
}

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

@Test
public void shouldDetermineFromHostsContainingPorts() {
  assertThat(determineHost(new Swagger().host("54.152.43.92:8080").scheme(Scheme.HTTPS))).isEqualTo("https://54.152.43.92:8080");
}

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

@Test
public void shouldFailIfNoHttpSchemesFound() {
  assertThatExceptionOfType(IllegalArgumentException.class)
    .isThrownBy(() -> determineHost(new Swagger().scheme(Scheme.WS).scheme(Scheme.WSS)))
    .withMessageStartingWith("Unable to find a supported scheme");
}

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

@Test
public void shouldReturnNullIfNoHostGivenAnywhere() {
  assertThat(determineHost(new Swagger())).isNull();
  assertThat(determineHost(new Swagger().scheme(Scheme.HTTP))).isNull();
  assertThat(determineHost(new Swagger().host("host"))).isNull();
}

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

@Test
public void shouldReturnNullIfNoHostGivenAnywhere() {
  assertThat(determineHost(new Swagger())).isNull();
  assertThat(determineHost(new Swagger().scheme(Scheme.HTTP))).isNull();
  assertThat(determineHost(new Swagger().host("host"))).isNull();
}

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

@Override
  public Swagger configure(Swagger swagger) {
    if (swagger != null) {
      Info info = swagger.getInfo();
      if (info == null) {
        swagger.info(new Info());
      }

      swagger.basePath(basePath)
          .host(host)
          .getInfo()
          .title(title)
          .version(apiVersion);
      for(String scheme : this.schemes) {
        swagger.scheme(Scheme.forValue(scheme));
      }
    }
    return swagger;
  }
}

代码示例来源:origin: apache/cxf

private void configureSwagger() {
    swagger = new Swagger();
    mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
    mapper.setSerializationInclusion(JsonInclude.Include.NON_EMPTY);
    Info info = new Info();
    Contact swaggerContact = new Contact();
    License swaggerLicense = new License();
    swaggerLicense.name(this.license)
      .url(this.licenseUrl);
    swaggerContact.name(this.contact);
    info.version(this.version)
      .description(this.description)
      .contact(swaggerContact)
      .license(swaggerLicense)
      .title(this.title);
    swagger.setInfo(info);
    if (this.schemes != null) {
      for (String scheme : this.schemes) {
        swagger.scheme(Scheme.forValue(scheme));
      }
    }
    swagger.setHost(this.host);
    swagger.setBasePath(this.basePath);
  }
}

代码示例来源:origin: openmrs/openmrs-module-webservices.rest

@Test
public void swaggerSerializeTest() {
  final Info info = new Info().version("1.0.0").title("Swagger WebServices REST");
  
  Swagger swagger = new Swagger().info(info).securityDefinition("basicAuth", new BasicAuthDefinition())
      .scheme(Scheme.HTTP).consumes("application/json").produces("application/json");
  
  final Model patientModel = ModelConverters.getInstance().read(Patient.class).get("Patient");
  swagger.addDefinition("Patient", patientModel);
  
  final String swaggerJson = Json.pretty(swagger);
  assertNotNull(swaggerJson);
}

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

@Test
  public void shouldFailToDetermineIfNoHostGivenAnywhere() {
    assertThatExceptionOfType(NullPointerException.class).isThrownBy(() -> determineHost(new Swagger()))
      .withMessageStartingWith("Swagger specification does not provide");
    assertThatExceptionOfType(NullPointerException.class).isThrownBy(() -> determineHost(new Swagger().scheme(Scheme.HTTP)))
      .withMessageStartingWith("Swagger specification does not provide");
    assertThatExceptionOfType(NullPointerException.class).isThrownBy(() -> determineHost(new Swagger().host("host")))
      .withMessageStartingWith("Swagger specification does not provide");
  }
}

相关文章