SwaggerToAsciiDocServiceImpl implements SwaggerToAsciiDocService { @Override public String convertSwaggerToAsciiDoc(final String swaggerSchemaPath) { final File swaggerSchemaFile; LOG.info("Converting Swagger Schema to Ascii Doc..."); try { swaggerSchemaFile = getSchemaFile(swaggerSchemaPath); } catch (final FileNotFoundException | URISyntaxException e) { throw new SwaggerConfluenceConfigurationException("Error Locating Swagger Schema", e); } final String swaggerAsciiDoc; try { final Swagger2MarkupConfig config = new Swagger2MarkupConfigBuilder() .withMarkupLanguage(MarkupLanguage.ASCIIDOC) .withOutputLanguage(Language.EN) .withPathsGroupedBy(GroupBy.AS_IS) .withOperationOrdering(OrderBy.AS_IS) .build(); final String swaggerSchema = FileUtils.readFileToString(swaggerSchemaFile, StandardCharsets.UTF_8); swaggerAsciiDoc = Swagger2MarkupConverter.from(swaggerSchema) .withConfig(config) .build() .toString(); } catch (IOException e) { throw new SwaggerConfluenceInternalSystemException( "Error Converting Swagger Schema to AsciiDoc", e); } LOG.info("AsciiDoc Conversion Complete!"); return swaggerAsciiDoc; }  @Override String convertSwaggerToAsciiDoc(final String swaggerSchemaPath);  }
@Test public void testSwaggerToAsciiDocConversionWithValidYamlIsSuccessful() throws IOException { final String asciiDoc = swaggerToAsciiDocService.convertSwaggerToAsciiDoc("/swagger-petstore-example.yaml"); assertNotNull("Swagger Ascii Doc Should Not Be Null!", asciiDoc); }
@Test(expected=RuntimeException.class) public void testSwaggerToAsciiDocConversionWithInvalidFileThrowsException(){ swaggerToAsciiDocService.convertSwaggerToAsciiDoc("/non-existant.yaml"); }