diff --git a/build.gradle b/build.gradle index 1d64df3f..fc8c9cba 100644 --- a/build.gradle +++ b/build.gradle @@ -13,7 +13,7 @@ buildscript { } } description = 'swagger2markup Build' -version = '0.4.0' +version = '0.5.0' group = 'io.github.robwin' apply plugin: 'java' diff --git a/src/docs/asciidoc/paths/add_a_new_pet_to_the_store/curl-request.adoc b/src/docs/asciidoc/paths/add_a_new_pet_to_the_store/curl-request.adoc new file mode 100644 index 00000000..f2037c3c --- /dev/null +++ b/src/docs/asciidoc/paths/add_a_new_pet_to_the_store/curl-request.adoc @@ -0,0 +1,6 @@ + +[source,bash] +---- +$ curl 'http://localhost:8080/api/pet/' -i -X POST -H 'Content-Type: application/json' -H 'Content-Length: 111' -d '{"id":1,"category":{"id":1,"name":"Hund"},"name":"Wuffy","photoUrls":[],"tags":[],"status":null,"identifier":1}' +---- + diff --git a/src/docs/asciidoc/paths/add_a_new_pet_to_the_store/http-request.adoc b/src/docs/asciidoc/paths/add_a_new_pet_to_the_store/http-request.adoc new file mode 100644 index 00000000..399a5187 --- /dev/null +++ b/src/docs/asciidoc/paths/add_a_new_pet_to_the_store/http-request.adoc @@ -0,0 +1,10 @@ + +[source,http] +---- +POST /api/pet/ HTTP/1.1 +Content-Type: application/json +Content-Length: 111 + +{"id":1,"category":{"id":1,"name":"Hund"},"name":"Wuffy","photoUrls":[],"tags":[],"status":null,"identifier":1} +---- + diff --git a/src/docs/asciidoc/paths/add_a_new_pet_to_the_store/http-response.adoc b/src/docs/asciidoc/paths/add_a_new_pet_to_the_store/http-response.adoc new file mode 100644 index 00000000..533825fe --- /dev/null +++ b/src/docs/asciidoc/paths/add_a_new_pet_to_the_store/http-response.adoc @@ -0,0 +1,10 @@ + +[source,http] +---- +HTTP/1.1 200 OK +Content-Type: application/json +Content-Length: 7 + +SUCCESS +---- + diff --git a/src/main/java/io/github/robwin/swagger2markup/Swagger2MarkupConverter.java b/src/main/java/io/github/robwin/swagger2markup/Swagger2MarkupConverter.java index 72395d31..d52a8ca1 100644 --- a/src/main/java/io/github/robwin/swagger2markup/Swagger2MarkupConverter.java +++ b/src/main/java/io/github/robwin/swagger2markup/Swagger2MarkupConverter.java @@ -92,6 +92,7 @@ public class Swagger2MarkupConverter { * * @param swagger the Swagger YAML or JSON String. * @return a Swagger2MarkupConverter + * @throws java.io.IOException if String can not be parsed */ public static Builder fromString(String swagger) throws IOException { Validate.notEmpty(swagger, "swagger must not be null!"); @@ -127,6 +128,7 @@ public class Swagger2MarkupConverter { * Builds the document with the given markup language and returns it as a String * * @return a the document as a String + * @throws java.io.IOException if files can not be read */ public String asString() throws IOException{ return buildDocuments(); diff --git a/src/test/java/io/github/robwin/swagger2markup/Swagger2MarkupConverterTest.java b/src/test/java/io/github/robwin/swagger2markup/Swagger2MarkupConverterTest.java index 51d85d42..c7cf37c1 100644 --- a/src/test/java/io/github/robwin/swagger2markup/Swagger2MarkupConverterTest.java +++ b/src/test/java/io/github/robwin/swagger2markup/Swagger2MarkupConverterTest.java @@ -50,14 +50,15 @@ public class Swagger2MarkupConverterTest { } @Test - public void testSwagger2AsciiDocConversionWithDescriptions() throws IOException { + public void testSwagger2AsciiDocConversionWithDescriptionsAndExamples() throws IOException { //Given File file = new File(Swagger2MarkupConverterTest.class.getResource("/json/swagger.json").getFile()); File outputDirectory = new File("build/docs/asciidoc/generated"); FileUtils.deleteQuietly(outputDirectory); //When - Swagger2MarkupConverter.from(file.getAbsolutePath()).withDescriptions("src/docs/asciidoc").build() + Swagger2MarkupConverter.from(file.getAbsolutePath()).withDescriptions("src/docs/asciidoc") + .withExamples("src/docs/asciidoc/paths").build() .intoFolder(outputDirectory.getAbsolutePath()); //Then