本文整理了Java中io.swagger.models.Swagger.getSchemes()
方法的一些代码示例,展示了Swagger.getSchemes()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Swagger.getSchemes()
方法的具体详情如下:
包路径:io.swagger.models.Swagger
类名称:Swagger
方法名:getSchemes
暂无
代码示例来源:origin: Swagger2Markup/swagger2markup
@Override
public MarkupDocBuilder apply(MarkupDocBuilder markupDocBuilder, Parameters params) {
Swagger swagger = params.swagger;
if (isNotBlank(swagger.getHost()) || isNotBlank(swagger.getBasePath()) || isNotEmpty(swagger.getSchemes())) {
markupDocBuilder.sectionTitleLevel(params.titleLevel, labels.getLabel(Labels.URI_SCHEME));
MarkupDocBuilder paragraphBuilder = copyMarkupDocBuilder(markupDocBuilder);
if (isNotBlank(swagger.getHost())) {
paragraphBuilder.italicText(labels.getLabel(Labels.HOST))
.textLine(COLON + swagger.getHost());
}
if (isNotBlank(swagger.getBasePath())) {
paragraphBuilder.italicText(labels.getLabel(Labels.BASE_PATH))
.textLine(COLON + swagger.getBasePath());
}
if (isNotEmpty(swagger.getSchemes())) {
List<String> schemes = swagger.getSchemes().stream()
.map(Enum::toString)
.collect(Collectors.toList());
paragraphBuilder.italicText(labels.getLabel(Labels.SCHEMES))
.textLine(COLON + join(schemes, ", "));
}
markupDocBuilder.paragraph(paragraphBuilder.toString(), true);
}
return markupDocBuilder;
}
代码示例来源: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: 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: 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: AresS31/swurg
private void validateSpecification(Swagger swagger, String resource) {
if (Strings.isNullOrEmpty(swagger.getHost())) {
throw new IllegalArgumentException(
String.format(
"The OpenAPI specification contained in %s is missing the mandatory field: 'host'",
resource));
}
if (CollectionUtils.isEmpty(swagger.getSchemes())) {
throw new IllegalArgumentException(
String.format(
"The OpenAPI specification contained in %s is missing the mandatory field: 'schemes'",
resource));
}
if (MapUtils.isEmpty(swagger.getPaths())) {
throw new IllegalArgumentException(
String.format(
"The OpenAPI specification contained in %s is missing the mandatory field: 'paths'",
resource));
}
}
}
代码示例来源:origin: com.reprezen.genflow/swagger-doc
private Object getScheme(final Swagger swagger) {
Object _xblockexpression = null;
{
final Function1<Scheme, String> _function = (Scheme it) -> {
return it.toString().toLowerCase();
};
final List<String> schemes = ListExtensions.<Scheme, String>map(swagger.getSchemes(), _function);
for (final String preferredScheme : Collections.<String>unmodifiableList(CollectionLiterals.<String>newArrayList("https", "http"))) {
boolean _contains = schemes.contains(preferredScheme);
if (_contains) {
return preferredScheme;
}
}
Object _xifexpression = null;
int _size = schemes.size();
boolean _greaterThan = (_size > 0);
if (_greaterThan) {
_xifexpression = swagger.getSchemes().get(0);
} else {
_xifexpression = "http";
}
_xblockexpression = ((Object)_xifexpression);
}
return _xblockexpression;
}
代码示例来源:origin: io.syndesis.rest/rest-connector-generator
final URI specificationUrl = (URI) vendorExtensions.get(BaseSwaggerConnectorGenerator.URL_EXTENSION);
final List<Scheme> schemes = swagger.getSchemes();
final String schemeToUse;
if (schemes == null || schemes.isEmpty()) {
代码示例来源:origin: io.syndesis/connector-generator
final URI specificationUrl = (URI) vendorExtensions.get(BaseSwaggerConnectorGenerator.URL_EXTENSION);
final List<Scheme> schemes = swagger.getSchemes();
final String schemeToUse;
if (schemes == null || schemes.isEmpty()) {
代码示例来源:origin: org.teiid.connectors/translator-swagger
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();
scheme = swagger.getSchemes().get(0).toValue();
代码示例来源: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: 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: org.apache.camel/camel-rest-swagger
final String swaggerScheme = pickBestScheme(specificationUri.getScheme(), swagger.getSchemes());
final String swaggerHost = swagger.getHost();
代码示例来源:origin: io.github.swagger2markup/swagger2markup
@Override
public MarkupDocBuilder apply(MarkupDocBuilder markupDocBuilder, Parameters params) {
Swagger swagger = params.swagger;
if (isNotBlank(swagger.getHost()) || isNotBlank(swagger.getBasePath()) || isNotEmpty(swagger.getSchemes())) {
markupDocBuilder.sectionTitleLevel(params.titleLevel, labels.getLabel(Labels.URI_SCHEME));
MarkupDocBuilder paragraphBuilder = copyMarkupDocBuilder(markupDocBuilder);
if (isNotBlank(swagger.getHost())) {
paragraphBuilder.italicText(labels.getLabel(Labels.HOST))
.textLine(COLON + swagger.getHost());
}
if (isNotBlank(swagger.getBasePath())) {
paragraphBuilder.italicText(labels.getLabel(Labels.BASE_PATH))
.textLine(COLON + swagger.getBasePath());
}
if (isNotEmpty(swagger.getSchemes())) {
List<String> schemes = swagger.getSchemes().stream()
.map(Enum::toString)
.collect(Collectors.toList());
paragraphBuilder.italicText(labels.getLabel(Labels.SCHEMES))
.textLine(COLON + join(schemes, ", "));
}
markupDocBuilder.paragraph(paragraphBuilder.toString(), true);
}
return markupDocBuilder;
}
代码示例来源:origin: AresS31/swurg
public void populateTable(Swagger swagger) {
DefaultTableModel defaultTableModel = (DefaultTableModel) this.table.getModel();
List<Scheme> schemes = swagger.getSchemes();
代码示例来源:origin: outofcoffee/imposter
consumes.addAll(getOrEmpty(spec.getConsumes()));
produces.addAll(getOrEmpty(spec.getProduces()));
childSchemes.addAll(getOrEmpty(spec.getSchemes()));
security.addAll(getOrEmpty(spec.getSecurity()));
securityDefinitions.putAll(getOrEmpty(spec.getSecurityDefinitions()));
代码示例来源:origin: io.syndesis.server/server-api-generator
final List<Scheme> schemes = swagger.getSchemes();
if (schemes == null || schemes.isEmpty()) {
if (specificationUrl == null) {
代码示例来源:origin: io.syndesis.server/server-connector-generator
final List<Scheme> schemes = swagger.getSchemes();
if (schemes == null || schemes.isEmpty()) {
if (specificationUrl == null) {
代码示例来源:origin: AresS31/swurg
logger.info("Host: " + swagger.getHost());
logger.info("Base path: " + swagger.getBasePath());
logger.info("Schemes: " + swagger.getSchemes());
logger.info("Consumes: " + swagger.getConsumes());
logger.info("Produces: " + swagger.getProduces());
代码示例来源: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()));
}
内容来源于网络,如有侵权,请联系作者删除!