本文整理了Java中io.swagger.models.Swagger.host()
方法的一些代码示例,展示了Swagger.host()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Swagger.host()
方法的具体详情如下:
包路径:io.swagger.models.Swagger
类名称:Swagger
方法名:host
暂无
代码示例来源:origin: Swagger2Markup/swagger2markup
@Test
public void testUriSchemeComponent() throws URISyntaxException {
Swagger swagger = new Swagger().host("http://localhost").basePath("/v2");
swagger.addScheme(Scheme.HTTP);
swagger.addScheme(Scheme.HTTPS);
Swagger2MarkupConverter.Context context = createContext();
MarkupDocBuilder markupDocBuilder = context.createMarkupDocBuilder();
markupDocBuilder = new UriSchemeComponent(context).apply(markupDocBuilder, UriSchemeComponent.parameters(swagger, OverviewDocument.SECTION_TITLE_LEVEL));
markupDocBuilder.writeToFileWithoutExtension(outputDirectory, StandardCharsets.UTF_8);
Path expectedFile = getExpectedFile(COMPONENT_NAME);
DiffUtils.assertThatFileIsEqual(expectedFile, outputDirectory, getReportName(COMPONENT_NAME));
}
}
代码示例来源: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: net.guerlab.spring/guerlab-spring-swagger2-starter
swagger2.host(forwardedHost);
setBasePath(swagger2, servletRequest.getHeader("x-forwarded-prefix"));
} else {
swagger2.host(hostName(uriComponents));
代码示例来源:origin: com.github.xiaoymin/swagger-bootstrap-ui
swagger.host(hostName(uriComponents));
代码示例来源: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.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-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 shouldDetermineFromHostsContainingPorts() {
assertThat(determineHost(new Swagger().host("54.152.43.92:8080").scheme(Scheme.HTTPS))).isEqualTo("https://54.152.43.92:8080");
}
代码示例来源: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: com.outbrain.swinfra/ob1k-swagger
private Swagger buildSwagger(final Request request) {
final Swagger swagger = new Swagger();
swagger.host(request.getHeader("Host"));
swagger.info(buildInfo());
代码示例来源: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.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 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: com.haulmont.cuba/cuba-rest-api
protected void init() {
Pair<List<Tag>, Map<String, Path>> tagsAndPaths = generatePaths();
swagger = new Swagger()
.host(getHost())
.basePath(getBasePath())
.consumes(APPLICATION_JSON_VALUE)
.produces(APPLICATION_JSON_VALUE)
.info(generateInfo())
.tags(tagsAndPaths.getFirst())
.paths(tagsAndPaths.getSecond());
swagger.setParameters(parameters);
swagger.setDefinitions(definitions);
}
代码示例来源:origin: openmrs/openmrs-module-webservices.rest
private void initSwagger() {
final Info info = new Info()
.version(OpenmrsConstants.OPENMRS_VERSION_SHORT)
.title("OpenMRS API Docs")
.description("OpenMRS RESTful API documentation generated by Swagger")
.contact(new Contact().name("OpenMRS").url("http://openmrs.org"))
.license(new License().name("MPL-2.0 w/ HD").url("http://openmrs.org/license"));
swagger
.info(info)
.host(this.host)
.basePath(this.basePath)
.schemes(this.schemes)
.securityDefinition("basic_auth", new BasicAuthDefinition())
.security(new SecurityRequirement().requirement("basic_auth"))
.consumes("application/json")
.produces("application/json")
.externalDocs(new ExternalDocs()
.description("Find more info on REST Module Wiki")
.url("https://wiki.openmrs.org/x/xoAaAQ"));
}
代码示例来源: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");
}
}
内容来源于网络,如有侵权,请联系作者删除!