本文整理汇总了Java中io.github.swagger2markup.builder.Swagger2MarkupConfigBuilder类的典型用法代码示例。如果您正苦于以下问题:Java Swagger2MarkupConfigBuilder类的具体用法?Java Swagger2MarkupConfigBuilder怎么用?Java Swagger2MarkupConfigBuilder使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Swagger2MarkupConfigBuilder类属于io.github.swagger2markup.builder包,在下文中一共展示了Swagger2MarkupConfigBuilder类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: test
import io.github.swagger2markup.builder.Swagger2MarkupConfigBuilder; //导入依赖的package包/类
@Test
public void test() throws URISyntaxException {
//Given
Path file = Paths.get(SwaggerToAsciiDocMarkdownConfluence.class.getResource(resource).toURI());
Path outputDirectory = Paths.get(BUILD_SWAGGER_2_MARKUP_PATH + outputPath);
FileUtils.deleteQuietly(outputDirectory.toFile());
//When
Swagger2MarkupConfig config = new Swagger2MarkupConfigBuilder()
.withPathsGroupedBy(GroupBy.TAGS)
.withOutputLanguage(Language.EN)
.withMarkupLanguage(markupLanguage)
.build();
Swagger2MarkupConverter.from(file)
.withConfig(config)
.build()
.toFolder(outputDirectory);
}
示例2: testOrderByAsIs
import io.github.swagger2markup.builder.Swagger2MarkupConfigBuilder; //导入依赖的package包/类
@Test
public void testOrderByAsIs() throws IOException, URISyntaxException {
//Given
Path file = Paths.get(AsciidocConverterTest.class.getResource("/yaml/swagger_ordering.yaml").toURI());
Path outputDirectory = Paths.get("build/test/asciidoc/ordering_asis");
FileUtils.deleteQuietly(outputDirectory.toFile());
//When
Swagger2MarkupConfig config = new Swagger2MarkupConfigBuilder()
.withTagOrdering(OrderBy.AS_IS)
.withParameterOrdering(OrderBy.AS_IS)
.withOperationOrdering(OrderBy.AS_IS)
.withDefinitionOrdering(OrderBy.AS_IS)
.withPathsGroupedBy(GroupBy.TAGS)
.build();
Swagger2MarkupConverter.from(file).withConfig(config).build()
.toFolder(outputDirectory);
//Then
String[] files = outputDirectory.toFile().list();
assertThat(files).hasSize(4).containsAll(expectedFiles);
Path expectedFilesDirectory = Paths.get(AsciidocConverterTest.class.getResource("/expected/asciidoc/ordering_asis").toURI());
DiffUtils.assertThatAllFilesAreEqual(expectedFilesDirectory, outputDirectory, "testOrderingAsIs.html");
}
示例3: testOrderByNatural
import io.github.swagger2markup.builder.Swagger2MarkupConfigBuilder; //导入依赖的package包/类
@Test
public void testOrderByNatural() throws IOException, URISyntaxException {
//Given
Path file = Paths.get(AsciidocConverterTest.class.getResource("/yaml/swagger_ordering.yaml").toURI());
Path outputDirectory = Paths.get("build/test/asciidoc/ordering_natural");
FileUtils.deleteQuietly(outputDirectory.toFile());
Swagger2MarkupConfig config = new Swagger2MarkupConfigBuilder()
.withTagOrdering(OrderBy.NATURAL)
.withParameterOrdering(OrderBy.NATURAL)
.withOperationOrdering(OrderBy.NATURAL)
.withPathsGroupedBy(GroupBy.TAGS)
.build();
//When
Swagger2MarkupConverter.from(file).withConfig(config).build()
.toFolder(outputDirectory);
//Then
String[] files = outputDirectory.toFile().list();
assertThat(files).hasSize(4).containsAll(expectedFiles);
Path expectedFilesDirectory = Paths.get(AsciidocConverterTest.class.getResource("/expected/asciidoc/ordering_natural").toURI());
DiffUtils.assertThatAllFilesAreEqual(expectedFilesDirectory, outputDirectory, "testOrderingNatural.html");
}
示例4: testOrderByRegex
import io.github.swagger2markup.builder.Swagger2MarkupConfigBuilder; //导入依赖的package包/类
@Test
public void testOrderByRegex() throws IOException, URISyntaxException {
//Given
Path file = Paths.get(AsciidocConverterTest.class.getResource("/yaml/swagger_ordering_regex.yaml").toURI());
Path outputDirectory = Paths.get("build/test/asciidoc/ordering_regex");
FileUtils.deleteQuietly(outputDirectory.toFile());
Swagger2MarkupConfig config = new Swagger2MarkupConfigBuilder()
.withTagOrdering(OrderBy.NATURAL)
.withParameterOrdering(OrderBy.NATURAL)
.withOperationOrdering(OrderBy.NATURAL)
.withPathsGroupedBy(GroupBy.REGEX)
.withHeaderRegex("\\/(\\w+)(\\/|\\w)*$")
.build();
//When
Swagger2MarkupConverter.from(file).withConfig(config).build()
.toFolder(outputDirectory);
//Then
String[] files = outputDirectory.toFile().list();
assertThat(files).hasSize(4).containsAll(expectedFiles);
Path expectedFilesDirectory = Paths.get(AsciidocConverterTest.class.getResource("/expected/asciidoc/ordering_regex").toURI());
DiffUtils.assertThatAllFilesAreEqual(expectedFilesDirectory, outputDirectory, "testOrderingRegex.html");
}
示例5: testMarkupRenderingInInstagram
import io.github.swagger2markup.builder.Swagger2MarkupConfigBuilder; //导入依赖的package包/类
@Test
public void testMarkupRenderingInInstagram() throws IOException, URISyntaxException {
//Given
Path file = Paths.get(AsciidocConverterTest.class.getResource("/yaml/swagger_instagram.yaml").toURI());
Path outputDirectory = Paths.get("build/test/asciidoc/instagram");
FileUtils.deleteQuietly(outputDirectory.toFile());
//When
Swagger2MarkupConfig config = new Swagger2MarkupConfigBuilder()
.withTagOrdering(OrderBy.AS_IS)
.build();
Swagger2MarkupConverter.from(file).withConfig(config).build()
.toFolder(outputDirectory);
//Then
String[] files = outputDirectory.toFile().list();
assertThat(files).hasSize(4).containsAll(expectedFiles);
Path expectedFilesDirectory = Paths.get(AsciidocConverterTest.class.getResource("/expected/asciidoc/instagram").toURI());
DiffUtils.assertThatAllFilesAreEqual(expectedFilesDirectory, outputDirectory, "testMarkupRenderingInInstagram.html");
}
示例6: testInterDocumentCrossReferences
import io.github.swagger2markup.builder.Swagger2MarkupConfigBuilder; //导入依赖的package包/类
@Test
public void testInterDocumentCrossReferences() throws IOException, URISyntaxException {
//Given
Path file = Paths.get(AsciidocConverterTest.class.getResource("/yaml/swagger_petstore.yaml").toURI());
Path outputDirectory = Paths.get("build/test/asciidoc/idxref");
FileUtils.deleteQuietly(outputDirectory.toFile());
//When
Swagger2MarkupConfig config = new Swagger2MarkupConfigBuilder()
.withInterDocumentCrossReferences()
.build();
Swagger2MarkupConverter.from(file).withConfig(config).build()
.toFolder(outputDirectory);
//Then
String[] files = outputDirectory.toFile().list();
assertThat(files).hasSize(4).containsAll(expectedFiles);
Path expectedFilesDirectory = Paths.get(AsciidocConverterTest.class.getResource("/expected/asciidoc/idxref").toURI());
DiffUtils.assertThatAllFilesAreEqual(expectedFilesDirectory, outputDirectory, "testInterDocumentCrossReferences.html");
}
示例7: testWithBasePathPrefix
import io.github.swagger2markup.builder.Swagger2MarkupConfigBuilder; //导入依赖的package包/类
@Test
public void testWithBasePathPrefix() throws IOException, URISyntaxException {
//Given
Path file = Paths.get(AsciidocConverterTest.class.getResource("/json/swagger_examples.json").toURI());
Path outputDirectory = Paths.get("build/test/asciidoc/basepathprefix");
FileUtils.deleteQuietly(outputDirectory.toFile());
//When
Swagger2MarkupConfig config = new Swagger2MarkupConfigBuilder()
.withBasePathPrefix()
.withGeneratedExamples()
.build();
Swagger2MarkupConverter.from(file).withConfig(config).build()
.toFolder(outputDirectory);
//Then
String[] files = outputDirectory.toFile().list();
assertThat(files).hasSize(4).containsAll(expectedFiles);
Path expectedFilesDirectory = Paths.get(AsciidocConverterTest.class.getResource("/expected/asciidoc/basepathprefix").toURI());
DiffUtils.assertThatAllFilesAreEqual(expectedFilesDirectory, outputDirectory, "testWithBasePathPrefix.html");
}
示例8: testWithExamples
import io.github.swagger2markup.builder.Swagger2MarkupConfigBuilder; //导入依赖的package包/类
@Test
public void testWithExamples() throws IOException, URISyntaxException {
//Given
String swaggerJsonString = IOUtils.toString(getClass().getResourceAsStream("/json/swagger_examples.json"));
Path outputDirectory = Paths.get("build/test/asciidoc/examples");
FileUtils.deleteQuietly(outputDirectory.toFile());
//When
Swagger2MarkupConfig config = new Swagger2MarkupConfigBuilder()
.build();
Swagger2MarkupConverter.from(swaggerJsonString)
.withConfig(config)
.build()
.toFolder(outputDirectory);
//Then
String[] files = outputDirectory.toFile().list();
assertThat(files).hasSize(4).containsAll(expectedFiles);
Path expectedFilesDirectory = Paths.get(AsciidocConverterTest.class.getResource("/expected/asciidoc/examples").toURI());
DiffUtils.assertThatAllFilesAreEqual(expectedFilesDirectory, outputDirectory, "testWithExamples.html");
}
示例9: testWithGeneratedExamples
import io.github.swagger2markup.builder.Swagger2MarkupConfigBuilder; //导入依赖的package包/类
@Test
public void testWithGeneratedExamples() throws IOException, URISyntaxException {
//Given
String swaggerJsonString = IOUtils.toString(getClass().getResourceAsStream("/json/swagger_examples.json"));
Path outputDirectory = Paths.get("build/test/asciidoc/generated_examples");
FileUtils.deleteQuietly(outputDirectory.toFile());
//When
Swagger2MarkupConfig config = new Swagger2MarkupConfigBuilder()
.withGeneratedExamples()
.build();
Swagger2MarkupConverter.from(swaggerJsonString)
.withConfig(config)
.build()
.toFolder(outputDirectory);
//Then
String[] files = outputDirectory.toFile().list();
assertThat(files).hasSize(4).containsAll(expectedFiles);
Path expectedFilesDirectory = Paths.get(AsciidocConverterTest.class.getResource("/expected/asciidoc/generated_examples").toURI());
DiffUtils.assertThatAllFilesAreEqual(expectedFilesDirectory, outputDirectory, "testWithGeneratedExamples.html");
}
示例10: testWithGeneratedRecursiveExamples
import io.github.swagger2markup.builder.Swagger2MarkupConfigBuilder; //导入依赖的package包/类
@Test
public void testWithGeneratedRecursiveExamples() throws IOException, URISyntaxException {
// Given
String swaggerJsonString = IOUtils.toString(getClass().getResourceAsStream("/json/swagger_recursion.json"));
Path outputDirectory = Paths.get("build/test/asciidoc/generated_recursion_examples");
FileUtils.deleteQuietly(outputDirectory.toFile());
// When
Swagger2MarkupConfig config = new Swagger2MarkupConfigBuilder().withoutInlineSchema().withGeneratedExamples().build();
Swagger2MarkupConverter.from(swaggerJsonString).withConfig(config).build().toFolder(outputDirectory);
// Then
String[] files = outputDirectory.toFile().list();
assertThat(files).hasSize(4).containsAll(expectedFiles);
Path expectedFilesDirectory = Paths.get(AsciidocConverterTest.class.getResource("/expected/asciidoc/generated_recursion_examples").toURI());
DiffUtils.assertThatAllFilesAreEqual(expectedFilesDirectory, outputDirectory, "testWithGeneratedRecursiveExamples.html");
}
示例11: testWithInlineSchema
import io.github.swagger2markup.builder.Swagger2MarkupConfigBuilder; //导入依赖的package包/类
@Test
public void testWithInlineSchema() throws IOException, URISyntaxException {
//Given
Path file = Paths.get(AsciidocConverterTest.class.getResource("/yaml/swagger_inlineSchema.yaml").toURI());
Path outputDirectory = Paths.get("build/test/asciidoc/inline_schema");
FileUtils.deleteQuietly(outputDirectory.toFile());
//When
Swagger2MarkupConfig config = new Swagger2MarkupConfigBuilder()
.build();
Swagger2MarkupConverter.from(file)
.withConfig(config)
.build()
.toFolder(outputDirectory);
//Then
String[] files = outputDirectory.toFile().list();
assertThat(files).hasSize(4).containsAll(expectedFiles);
Path expectedFilesDirectory = Paths.get(AsciidocConverterTest.class.getResource("/expected/asciidoc/inline_schema").toURI());
DiffUtils.assertThatAllFilesAreEqual(expectedFilesDirectory, outputDirectory, "testWithInlineSchema.html");
}
示例12: testWithInlineSchemaAndFlatBody
import io.github.swagger2markup.builder.Swagger2MarkupConfigBuilder; //导入依赖的package包/类
@Test
public void testWithInlineSchemaAndFlatBody() throws IOException, URISyntaxException {
//Given
Path file = Paths.get(AsciidocConverterTest.class.getResource("/yaml/swagger_inlineSchema.yaml").toURI());
Path outputDirectory = Paths.get("build/test/asciidoc/inline_schema_flat_body");
FileUtils.deleteQuietly(outputDirectory.toFile());
//When
Swagger2MarkupConfig config = new Swagger2MarkupConfigBuilder()
.withFlatBody()
.build();
Swagger2MarkupConverter.from(file)
.withConfig(config)
.build()
.toFolder(outputDirectory);
//Then
String[] files = outputDirectory.toFile().list();
assertThat(files).hasSize(4).containsAll(expectedFiles);
Path expectedFilesDirectory = Paths.get(AsciidocConverterTest.class.getResource("/expected/asciidoc/inline_schema_flat_body").toURI());
DiffUtils.assertThatAllFilesAreEqual(expectedFilesDirectory, outputDirectory, "testWithInlineSchemaAndFlatBody.html");
}
示例13: testGroupedByTags
import io.github.swagger2markup.builder.Swagger2MarkupConfigBuilder; //导入依赖的package包/类
@Test
public void testGroupedByTags() throws IOException, URISyntaxException {
//Given
Path file = Paths.get(AsciidocConverterTest.class.getResource("/yaml/swagger_petstore.yaml").toURI());
Path outputDirectory = Paths.get("build/test/asciidoc/group_by_tags");
FileUtils.deleteQuietly(outputDirectory.toFile());
//When
Swagger2MarkupConfig config = new Swagger2MarkupConfigBuilder()
.withPathsGroupedBy(GroupBy.TAGS)
.build();
Swagger2MarkupConverter.from(file)
.withConfig(config)
.build()
.toFolder(outputDirectory);
//Then
String[] files = outputDirectory.toFile().list();
assertThat(files).hasSize(4).containsAll(expectedFiles);
Path expectedFilesDirectory = Paths.get(AsciidocConverterTest.class.getResource("/expected/asciidoc/group_by_tags").toURI());
DiffUtils.assertThatAllFilesAreEqual(expectedFilesDirectory, outputDirectory, "testGroupedByTags.html");
}
示例14: testByTagsWithMissingTag
import io.github.swagger2markup.builder.Swagger2MarkupConfigBuilder; //导入依赖的package包/类
@Test
public void testByTagsWithMissingTag() throws IOException, URISyntaxException {
//Given
Path file = Paths.get(AsciidocConverterTest.class.getResource("/json/swagger_missing_tag.json").toURI());
Path outputDirectory = Paths.get("build/test/asciidoc/generated");
FileUtils.deleteQuietly(outputDirectory.toFile());
//When
try {
Swagger2MarkupConfig config = new Swagger2MarkupConfigBuilder()
.withPathsGroupedBy(GroupBy.TAGS)
.build();
Swagger2MarkupConverter.from(file)
.withConfig(config)
.build()
.toFolder(outputDirectory);
// If NullPointerException was not thrown, test would fail the specified message
failBecauseExceptionWasNotThrown(NullPointerException.class);
} catch (Exception e) {
assertThat(e).hasMessage("Can't GroupBy.TAGS. Operation 'updatePet' has no tags");
}
}
示例15: testWithSeparatedDefinitions
import io.github.swagger2markup.builder.Swagger2MarkupConfigBuilder; //导入依赖的package包/类
@Test
public void testWithSeparatedDefinitions() throws IOException, URISyntaxException {
//Given
Path file = Paths.get(AsciidocConverterTest.class.getResource("/yaml/swagger_petstore.yaml").toURI());
Path outputDirectory = Paths.get("build/test/asciidoc/generated");
FileUtils.deleteQuietly(outputDirectory.toFile());
//When
Swagger2MarkupConfig config = new Swagger2MarkupConfigBuilder()
.withSeparatedDefinitions()
.build();
Swagger2MarkupConverter.from(file).withConfig(config).build()
.toFolder(outputDirectory);
//Then
String[] files = outputDirectory.toFile().list();
expectedFiles.add("definitions");
assertThat(files).hasSize(5).containsAll(expectedFiles);
Path definitionsDirectory = outputDirectory.resolve("definitions");
String[] definitions = definitionsDirectory.toFile().list();
assertThat(definitions).hasSize(5).containsAll(
asList("Category.adoc", "Order.adoc", "Pet.adoc", "Tag.adoc", "User.adoc"));
}