@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"); }
@Test public void testBodyParameterComponent() throws URISyntaxException { //Given Path file = Paths.get(AsciidocConverterTest.class.getResource("/yaml/swagger_petstore.yaml").toURI()); Swagger2MarkupConfig config = new Swagger2MarkupConfigBuilder().withFlatBody().build(); Swagger2MarkupConverter converter = Swagger2MarkupConverter.from(file).withConfig(config).build(); Swagger swagger = converter.getContext().getSwagger(); io.swagger.models.Path path = swagger.getPaths().get("/pets"); List<PathOperation> pathOperations = PathUtils.toPathOperationsList("/pets", path); Swagger2MarkupConverter.Context context = converter.getContext(); MarkupDocBuilder markupDocBuilder = context.createMarkupDocBuilder(); //When markupDocBuilder = new BodyParameterComponent(converter.getContext(), new DefinitionDocumentResolverFromOperation(context)) .apply(markupDocBuilder, BodyParameterComponent.parameters(pathOperations.get(0), new ArrayList<>())); markupDocBuilder.writeToFileWithoutExtension(outputDirectory, StandardCharsets.UTF_8); //Then Path expectedFile = getExpectedFile(COMPONENT_NAME); DiffUtils.assertThatFileIsEqual(expectedFile, outputDirectory, getReportName(COMPONENT_NAME)); } }