io.swagger.parser.SwaggerParser.read()方法的使用及代码示例

x33g5p2x  于2022-01-30 转载在 其他  
字(11.0k)|赞(0)|评价(0)|浏览(144)

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

SwaggerParser.read介绍

暂无

代码示例

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

/**
 * Uses the SwaggerParser to read the Swagger source.
 *
 * @param swaggerLocation the location of the Swagger source
 * @return the Swagger model
 */
private Swagger readSwagger(String swaggerLocation) {
  Swagger swagger = new SwaggerParser().read(swaggerLocation);
  if (swagger == null) {
    throw new IllegalArgumentException("Failed to read the Swagger source");
  }
  return swagger;
}

代码示例来源:origin: jooby-project/jooby

private static Swagger parseSwagger(String location) {
 SwaggerParser parser = new SwaggerParser();
 return parser.read(location);
}

代码示例来源:origin: Sayi/swagger-diff

private SwaggerDiff(JsonNode oldSpec, JsonNode newSpec) {
  SwaggerParser swaggerParser = new SwaggerParser();
  oldSpecSwagger = swaggerParser.read(oldSpec, true);
  newSpecSwagger = swaggerParser.read(newSpec, true);
  if (null == oldSpecSwagger || null == newSpecSwagger) { throw new RuntimeException(
    "cannot read api-doc from spec."); }
}

代码示例来源:origin: amazon-archives/aws-apigateway-importer

private Swagger parse(String filePath) {
  final Swagger swagger = parser.read(filePath);
  if (swagger != null && swagger.getPaths() != null) {
    LOG.info("Parsed Swagger with " + swagger.getPaths().size() + " paths");
  }
  return swagger;
}

代码示例来源:origin: RobWin/assertj-swagger

/**
 * Verifies that the actual value is equal to the given one.
 *
 * @param expectedLocation the location of the given value to compare the actual value to.
 * @return {@code this} assertion object.
 * @throws AssertionError if the actual value is not equal to the given one or if the actual value is {@code null}..
 */
public SwaggerAssert isEqualTo(String expectedLocation) {
  return isEqualTo(new SwaggerParser().read(expectedLocation));
}

代码示例来源:origin: RobWin/assertj-swagger

/**
 * Verifies that the actual value is equal to the given one.
 *
 * @param expectedLocation the location of the given value to compare the actual value to.
 * @return {@code this} assertion object.
 * @throws AssertionError if the actual value is not equal to the given one or if the actual value is {@code null}..
 */
public SwaggerAssert satisfiesContract(String expectedLocation) {
  return satisfiesContract(new SwaggerParser().read(expectedLocation));
}

代码示例来源:origin: RobWin/assertj-swagger

/**
   * Creates a new instance of <code>{@link SwaggerAssert}</code>.
   *
   * @param actualLocation the location the actual Swagger value.
   * @return the created assertion object.
   */
  public static SwaggerAssert assertThat(String actualLocation) {
    Validate.notNull(actualLocation, "actualLocation must not be null!");
    return new SwaggerAssert(new SwaggerParser().read(actualLocation));
  }
}

代码示例来源:origin: RobWin/assertj-swagger

@Test
public void shouldHandleExpectedPathsWithPrefix() {
  File implFirstSwaggerLocation = new File(
    SwaggerDocumentationDrivenAssertTest.class.getResource("/swagger_with_path_prefixes.json").getPath());
  File designFirstSwaggerLocation = new File(
    SwaggerDocumentationDrivenAssertTest.class.getResource("/swagger.yaml").getPath());
  Validate.notNull(implFirstSwaggerLocation.getAbsolutePath(), "actualLocation must not be null!");
  new SwaggerAssert(new SwaggerParser().read(implFirstSwaggerLocation.getAbsolutePath()),
    "/assertj-swagger-path-prefix.properties")
    .isEqualTo(designFirstSwaggerLocation.getAbsolutePath());
}

代码示例来源:origin: RobWin/assertj-swagger

@Test
public void shouldHandleDefinitionsUsingAllOf() {
  File implFirstSwaggerLocation = new File(
    SwaggerConsumerDrivenAssertTest.class.getResource("/swagger-allOf-test-flat.json").getPath());
  File designFirstSwaggerLocation = new File(
    SwaggerConsumerDrivenAssertTest.class.getResource("/swagger-allOf-test-inheritance.json").getPath());
  Validate.notNull(implFirstSwaggerLocation.getAbsolutePath(), "actualLocation must not be null!");
  new SwaggerAssert(new SwaggerParser().read(implFirstSwaggerLocation.getAbsolutePath()),
    "/assertj-swagger-allOf.properties")
    .isEqualTo(designFirstSwaggerLocation.getAbsolutePath());
}

代码示例来源:origin: RobWin/assertj-swagger

@Test
public void shouldHandleDefinitionsUsingAllOf() {
  File implFirstSwaggerLocation = new File(SwaggerConsumerDrivenAssertTest.class.getResource("/swagger-allOf-test-flat.json").getPath());
  File designFirstSwaggerLocation = new File(SwaggerConsumerDrivenAssertTest.class.getResource("/swagger-allOf-test-inheritance.json").getPath());
  Validate.notNull(implFirstSwaggerLocation.getAbsolutePath(), "actualLocation must not be null!");
  new SwaggerAssert(new SwaggerParser().read(implFirstSwaggerLocation.getAbsolutePath()), "/assertj-swagger-allOf.properties")
    .satisfiesContract(designFirstSwaggerLocation.getAbsolutePath());
}

代码示例来源:origin: RobWin/assertj-swagger

@Test
public void shouldHandleDefinitionsUsingAllOfForComposition() {
  File implFirstSwaggerLocation = new File(
    SwaggerConsumerDrivenAssertTest.class.getResource("/swagger-allOf-composition-flat.json").getPath());
  File designFirstSwaggerLocation = new File(
    SwaggerConsumerDrivenAssertTest.class.getResource("/swagger-allOf-composition.json").getPath());
  Validate.notNull(implFirstSwaggerLocation.getAbsolutePath(), "actualLocation must not be null!");
  new SwaggerAssert(new SwaggerParser().read(implFirstSwaggerLocation.getAbsolutePath()))
    .isEqualTo(designFirstSwaggerLocation.getAbsolutePath());
}

代码示例来源:origin: RobWin/assertj-swagger

@Test
public void shouldHandleByteArrayValues() {
  File implFirstSwaggerLocation = new File(
    SwaggerConsumerDrivenAssertTest.class.getResource("/swagger-bytearray.json").getPath());
  File designFirstSwaggerLocation = new File(
    SwaggerConsumerDrivenAssertTest.class.getResource("/swagger-bytearray.yaml").getPath());
  Validate.notNull(implFirstSwaggerLocation.getAbsolutePath(), "actualLocation must not be null!");
  new SwaggerAssert(new SwaggerParser().read(implFirstSwaggerLocation.getAbsolutePath()))
    .isEqualTo(designFirstSwaggerLocation.getAbsolutePath());
}

代码示例来源:origin: RobWin/assertj-swagger

@Test(expected = AssertionError.class)
public void shouldFindDifferentByteArrayValues() {
  File implFirstSwaggerLocation = new File(
    SwaggerConsumerDrivenAssertTest.class.getResource("/swagger-bytearray-wrong.json").getPath());
  File designFirstSwaggerLocation = new File(
    SwaggerConsumerDrivenAssertTest.class.getResource("/swagger-bytearray.yaml").getPath());
  Validate.notNull(implFirstSwaggerLocation.getAbsolutePath(), "actualLocation must not be null!");
  new SwaggerAssert(new SwaggerParser().read(implFirstSwaggerLocation.getAbsolutePath()))
    .isEqualTo(designFirstSwaggerLocation.getAbsolutePath());
}

代码示例来源:origin: RobWin/assertj-swagger

@Test
public void shouldRefHandleByteArrayValues() {
  File implFirstSwaggerLocation = new File(
    SwaggerConsumerDrivenAssertTest.class.getResource("/swagger-bytearray-ref.json").getPath());
  File designFirstSwaggerLocation = new File(
    SwaggerConsumerDrivenAssertTest.class.getResource("/swagger-bytearray-ref.yaml").getPath());
  Validate.notNull(implFirstSwaggerLocation.getAbsolutePath(), "actualLocation must not be null!");
  new SwaggerAssert(new SwaggerParser().read(implFirstSwaggerLocation.getAbsolutePath()))
    .isEqualTo(designFirstSwaggerLocation.getAbsolutePath());
}

代码示例来源:origin: RobWin/assertj-swagger

@Test
public void shouldHandleDefinitionsUsingAllOfIncludingCycles() {
  File implFirstSwaggerLocation = new File(SwaggerConsumerDrivenAssertTest.class.getResource("/swagger-allOf-test-flat.json").getPath());
  File designFirstSwaggerLocation = new File(SwaggerConsumerDrivenAssertTest.class.getResource("/swagger-allOf-test-inheritance-cycles.json").getPath());
  Validate.notNull(implFirstSwaggerLocation.getAbsolutePath(), "actualLocation must not be null!");
  new SwaggerAssert(new SwaggerParser().read(implFirstSwaggerLocation.getAbsolutePath()), "/assertj-swagger-allOf.properties")
    .satisfiesContract(designFirstSwaggerLocation.getAbsolutePath());
}

代码示例来源:origin: RobWin/assertj-swagger

@Test
public void shouldHandlePartiallyImplementedApi() {
  File implFirstSwaggerLocation = new File(
    SwaggerDocumentationDrivenAssertTest.class.getResource("/partial_impl_swagger.json").getPath());
  File designFirstSwaggerLocation = new File(
    SwaggerDocumentationDrivenAssertTest.class.getResource("/swagger.yaml").getPath());
  Validate.notNull(implFirstSwaggerLocation.getAbsolutePath(), "actualLocation must not be null!");
  new SwaggerAssert(new SwaggerParser().read(implFirstSwaggerLocation.getAbsolutePath()),
    "/assertj-swagger-partial-impl.properties")
    .isEqualTo(designFirstSwaggerLocation.getAbsolutePath());
}

代码示例来源:origin: RobWin/assertj-swagger

@Test(expected = AssertionError.class)
public void shouldFindDifferentRefByteArrayValues() {
  File implFirstSwaggerLocation = new File(
    SwaggerConsumerDrivenAssertTest.class.getResource("/swagger-bytearray-ref-wrong.json").getPath());
  File designFirstSwaggerLocation = new File(
    SwaggerConsumerDrivenAssertTest.class.getResource("/swagger-bytearray-ref.yaml").getPath());
  Validate.notNull(implFirstSwaggerLocation.getAbsolutePath(), "actualLocation must not be null!");
  new SwaggerAssert(new SwaggerParser().read(implFirstSwaggerLocation.getAbsolutePath()))
    .isEqualTo(designFirstSwaggerLocation.getAbsolutePath());
}

代码示例来源:origin: RobWin/assertj-swagger

@Test(expected = AssertionError.class)
  public void shouldFindDifferentRefEnumValues() {
    File implFirstSwaggerLocation = new File(
      SwaggerConsumerDrivenAssertTest.class.getResource("/swagger-enum-ref-wrong.json").getPath());
    File designFirstSwaggerLocation = new File(
      SwaggerConsumerDrivenAssertTest.class.getResource("/swagger-enum-ref.yaml").getPath());

    Validate.notNull(implFirstSwaggerLocation.getAbsolutePath(), "actualLocation must not be null!");
    new SwaggerAssert(new SwaggerParser().read(implFirstSwaggerLocation.getAbsolutePath()))
      .isEqualTo(designFirstSwaggerLocation.getAbsolutePath());
  }
}

代码示例来源:origin: RobWin/assertj-swagger

@Test
public void shouldHandleExpectedPathsWithPrefix() {
  File implFirstSwaggerLocation = new File(SwaggerConsumerDrivenAssertTest.class.getResource("/swagger_with_path_prefixes.json").getPath());
  File designFirstSwaggerLocation = new File(SwaggerConsumerDrivenAssertTest.class.getResource("/swagger.yaml").getPath());
  Validate.notNull(implFirstSwaggerLocation.getAbsolutePath(), "actualLocation must not be null!");
  new SwaggerAssert(new SwaggerParser().read(implFirstSwaggerLocation.getAbsolutePath()), "/assertj-swagger-path-prefix.properties")
      .satisfiesContract(designFirstSwaggerLocation.getAbsolutePath());
}

代码示例来源:origin: io.gravitee.management/gravitee-management-api-service

private NewApiEntity prepareV2(ImportSwaggerDescriptorEntity swaggerDescriptor) {
  NewApiEntity apiEntity;
  logger.info("Trying to loading a Swagger descriptor in v2");
  if (swaggerDescriptor.getType() == ImportSwaggerDescriptorEntity.Type.INLINE) {
    apiEntity = mapSwagger12ToNewApi(new SwaggerParser().parse(swaggerDescriptor.getPayload()));
  } else {
    apiEntity = mapSwagger12ToNewApi(new SwaggerParser().read(swaggerDescriptor.getPayload()));
  }
  return apiEntity;
}

相关文章

微信公众号

最新文章

更多