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

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

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

Swagger.basePath介绍

暂无

代码示例

代码示例来源:origin: Swagger2Markup/swagger2markup

public void apply(Swagger swagger) {
    swagger.setHost("newHostName"); //<1>
    swagger.basePath("newBasePath");

    Map<String, Path> paths = swagger.getPaths(); //<2>
    paths.remove("/remove");
    swagger.setPaths(paths);
  }
}

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

.basePath("/")
.tags(ImmutableList.copyOf(tags))
.securityDefinition("write_key", new ApiKeyAuthDefinition().in(In.HEADER).name("write_key"))

代码示例来源: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: com.github.xiaoymin/swagger-bootstrap-ui

swagger.basePath(Strings.isNullOrEmpty(uriComponents.getPath()) ? "/" : uriComponents.getPath());
if (isNullOrEmpty(swagger.getHost())) {
  swagger.host(hostName(uriComponents));

代码示例来源:origin: net.guerlab.spring/guerlab-spring-swagger2-starter

setBasePath(swagger2, servletRequest.getHeader("x-forwarded-prefix"));
} else {
  swagger2.basePath(StringUtils.isBlank(uriComponents.getPath()) ? "/" : uriComponents.getPath());

代码示例来源:origin: outofcoffee/imposter

combined.basePath(basePath);

代码示例来源: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: io.syndesis.integration/integration-project-generator

@Test
  public void shouldNormalizeSwaggerBasePaths() {
    final Swagger swagger = new Swagger().path("/path", new Path().get(new Operation()));

    assertThat(ProjectGeneratorHelper.normalizePaths(swagger).getPaths()).containsOnlyKeys("/path");
    assertThat(ProjectGeneratorHelper.normalizePaths(swagger.basePath("/api")).getPaths()).containsOnlyKeys("/api/path");
  }
}

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

.host(host)
    .scheme(Scheme.forValue(scheme))
    .basePath(basePath)
    .info(info)
    .basePath(basePath);
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: vmware/admiral

.basePath("/")
.host("host")
.schemes(Arrays.asList(new Scheme[] {Scheme.HTTP}));

相关文章