Updated documentation

This commit is contained in:
Robert Winkler
2015-02-19 11:09:02 +01:00
parent 0ca91ea930
commit e6f7372c9f
4 changed files with 18 additions and 14 deletions

View File

@@ -62,16 +62,19 @@ public class Swagger2MarkupTest {
public void convertSwaggerToMarkup() {
//Remote
Swagger2MarkupConverter.from("http://localhost:8080/api-docs").
toAsciiDoc("src/docs/asciidoc/example.adoc");
withMarkupLanguage(MarkupLanguage.MARKDOWN).
withExamples("docs/generated").withSchemas("docs/schemas").build()
.intoFolder("src/docs/markdown");
Swagger2MarkupConverter.from("http://localhost:8080/api-docs").
toMarkdown("src/docs/markdown/example.md");
withExamples("docs").withSchemas("docs/schemas").build()
.intoFolder("src/docs/asciidoc");
//Local
File file = new File(Swagger2MarkupTest.class.getResource("/json/swagger.json").getFile());
Swagger2MarkupConverter.from(file.getAbsolutePath()).toAsciiDoc("src/docs/asciidoc/swagger.adoc")
Swagger2MarkupConverter.from(file.getAbsolutePath()).build()
.intoFolder("src/docs/asciidoc");
}
}
----
@@ -132,14 +135,12 @@ image::images/mkdocs_html.PNG[mkdocs_html]
image::images/asciidoc_pdf.PNG[asciidoc_pdf]
== Document Builder
The converter allows to build an AsciiDoc or Markdown document via the Builder pattern:
The Swagger2Markup library allows to build an AsciiDoc or Markdown document via the Builder pattern:
[source,java]
----
String asciiDoc = new AsciiDocBuilder().documentTitle("Title")
.sectionTitleLevel1("Section1").paragraph("Text text")
.sectionTitleLevel2("Code examples").listing("Code example").toString();
DocumentBuilder builder = DocumentBuilders.documentBuilder(MarkupLanguage.ASCIIDOC);
builder.documentTitle("Test title").textLine("Text line").writeToFile("/tmp", "test.adoc", StandardCharsets.UTF_8);
String markdown = new MarkdownBuilder().documentTitle("Title")
.sectionTitleLevel1("Section1").paragraph("Text text")
.sectionTitleLevel2("Code examples").listing("Code example").toString();
DocumentBuilder builder = DocumentBuilders.documentBuilder(MarkupLanguage.MARKDOWN);
builder.documentTitle("Test title").textLine("Text line").writeToFile("/tmp", "test.adoc", StandardCharsets.UTF_8);
----

View File

@@ -2,3 +2,6 @@
== Version 0.1.0
* Initial version with support for AsciiDoc and Markdown
== Version 0.2.0
* This version is not downward compatible. This version supports includes of example files and JSON/XML Schema files. See documentation.

View File

@@ -13,7 +13,7 @@ buildscript {
}
}
description = 'swagger2markup Build'
version = '0.2.0'
version = '0.2.1'
group = 'io.github.robwin'
apply plugin: 'java'

View File

@@ -183,7 +183,7 @@ public class PathsDocument extends MarkupDocument {
if(examplesEnabled){
String summary = operation.getSummary();
if(StringUtils.isNotBlank(summary)) {
String exampleFolder = summary.replace(" ", "_").toLowerCase();
String exampleFolder = summary.replace(".", "").replace(" ", "_").toLowerCase();
example(EXAMPLE_REQUEST, exampleFolder, REQUEST_EXAMPLE_FILE_NAME);
example(EXAMPLE_RESPONSE, exampleFolder, RESPONSE_EXAMPLE_FILE_NAME);
}