本文整理了Java中io.swagger.models.Swagger.setBasePath()
方法的一些代码示例,展示了Swagger.setBasePath()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Swagger.setBasePath()
方法的具体详情如下:
包路径:io.swagger.models.Swagger
类名称:Swagger
方法名:setBasePath
暂无
代码示例来源:origin: apache/servicecomb-java-chassis
protected void correctBasePath() {
String basePath = swagger.getBasePath();
if (StringUtils.isEmpty(basePath)) {
basePath = "/" + cls.getSimpleName();
}
if (!basePath.startsWith("/")) {
basePath = "/" + basePath;
}
swagger.setBasePath(basePath);
}
代码示例来源:origin: apache/servicecomb-java-chassis
public void setBasePath(String basePath) {
basePath = context.resolveStringValue(basePath);
swagger.setBasePath(basePath);
}
代码示例来源:origin: apache/servicecomb-java-chassis
@Override
public void process(Object annotation, SwaggerGenerator swaggerGenerator) {
Swagger swagger = swaggerGenerator.getSwagger();
if (StringUtils.isEmpty(swagger.getBasePath())) {
swagger.setBasePath("/");
}
}
}
代码示例来源:origin: vmware/admiral
/**
* Specify the base path under which all documented services are available.
*
* @param basePath The base path
* @return This instance of {@link SwaggerDocumentationAssembler}
*/
public SwaggerDocumentationAssembler setBasePath(String basePath) {
this.swagger.setBasePath(basePath);
return this;
}
代码示例来源:origin: org.apache.brooklyn/brooklyn-utils-rest-swagger
@Override
public Swagger configure(Swagger swagger) {
swagger.setBasePath("/v1");
return swagger;
}
代码示例来源:origin: io.swagger/swagger-models
public Swagger basePath(String basePath) {
this.setBasePath(basePath);
return this;
}
代码示例来源: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: apache/servicecomb-java-chassis
.getBooleanProperty(REGISTER_URL_PREFIX, false).get()) {
LOGGER.info("Add swagger base path prefix for {} with {}", swagger.getBasePath(), urlPrefix);
swagger.setBasePath(urlPrefix + swagger.getBasePath());
代码示例来源:origin: net.guerlab.spring/guerlab-spring-swagger2-starter
/**
* spring cloud 1.X 下zull的支持,需要在zuul增加zuul.add-host-header=true配置
*/
private boolean setBasePathSpringCloudZuulSupport(Swagger swagger2, String forwardedPrefix) {
if (StringUtils.isNotBlank(forwardedPrefix)) {
swagger2.setBasePath(forwardedPrefix);
return true;
}
return false;
}
代码示例来源:origin: ef-labs/vertx-jersey
@Override
public Swagger configure(Swagger swagger) {
String basePath = context.getContextPath();
if (basePath.endsWith("/")) {
basePath = basePath.substring(0, basePath.length() - 1);
}
swagger.setBasePath(basePath);
return swagger;
}
代码示例来源:origin: Sayi/swagger-dubbo
private void setBashPath(Swagger swagger) {
if (StringUtils.isEmpty(swagger.getBasePath())){
swagger.setBasePath(StringUtils.isEmpty(servletContext.getContextPath()) ? "/" : servletContext.getContextPath());
}
}
代码示例来源:origin: net.guerlab.spring/guerlab-spring-swagger2-starter
/**
* 通用支持,用于支持在服务注册后根据注册名称自动做匹配,适用于1.X的zuul的自动发现和2.X的gateway的自动支持<br>
* 2.X gateway的自动发现请参考<a href=
* "http://cloud.spring.io/spring-cloud-static/Finchley.RC2/single/spring-cloud.html#_discoveryclient_route_definition_locator">http://cloud.spring.io/spring-cloud-static/Finchley.RC2/single/spring-cloud.html#_discoveryclient_route_definition_locator</a>
*/
private void setBasePathGeneralSupport(Swagger swagger2) {
Environment environment = SpringApplicationContextUtil.getContext().getEnvironment();
String appName = environment.getProperty("eureka.instance.appname",
environment.getProperty("spring.application.name"));
if (StringUtils.isNotBlank(appName)) {
swagger2.setBasePath("/" + appName.toUpperCase());
}
}
代码示例来源:origin: org.apache.servicecomb/swagger-generator-core
protected void correctBasePath() {
String basePath = swagger.getBasePath();
if (StringUtils.isEmpty(basePath)) {
basePath = "/" + cls.getSimpleName();
}
if (!basePath.startsWith("/")) {
basePath = "/" + basePath;
}
swagger.setBasePath(basePath);
}
代码示例来源: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: gravitee-io/gravitee-management-rest-api
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: org.apache.servicecomb/swagger-generator-springmvc
@Override
public void process(Object annotation, SwaggerGenerator swaggerGenerator) {
Swagger swagger = swaggerGenerator.getSwagger();
if (StringUtils.isEmpty(swagger.getBasePath())) {
swagger.setBasePath("/");
}
}
}
代码示例来源:origin: io.swagger/swagger-jaxrs
public void scanAndRead() {
Set<Class<?>> classes = classes();
if (classes != null) {
Swagger swagger = reader.read(classes);
if (StringUtils.isNotBlank(host)) {
swagger.setHost(host);
}
if (StringUtils.isNotBlank(basePath)) {
swagger.setBasePath(basePath);
}
updateInfoFromConfig();
}
}
代码示例来源:origin: com.reprezen.genflow/swagger-ui
private void handleOptions(Swagger swagger, SwaggerUi3Options options) {
if (!Strings.isNullOrEmpty(options.getBasePath())) {
swagger.setBasePath(options.getBasePath());
}
if (!Strings.isNullOrEmpty(options.getHost())) {
swagger.setHost(options.getHost());
}
}
代码示例来源:origin: wso2/msf4j
@Override
public void scanAndRead() {
Swagger swagger = reader.read(classes());
if (StringUtils.isNotBlank(getHost())) {
swagger.setHost(getHost());
}
if (StringUtils.isNotBlank(getBasePath())) {
swagger.setBasePath(getBasePath());
}
updateInfoFromConfig();
}
代码示例来源:origin: org.wso2.msf4j/msf4j-swagger
@Override
public void scanAndRead() {
Swagger swagger = reader.read(classes());
if (StringUtils.isNotBlank(getHost())) {
swagger.setHost(getHost());
}
if (StringUtils.isNotBlank(getBasePath())) {
swagger.setBasePath(getBasePath());
}
updateInfoFromConfig();
}
内容来源于网络,如有侵权,请联系作者删除!