Support for including hand-written descriptions instead of using Swagger Annotations for descriptions
This commit is contained in:
@@ -13,7 +13,7 @@ buildscript {
|
||||
}
|
||||
}
|
||||
description = 'swagger2markup Build'
|
||||
version = '0.4.0'
|
||||
version = '0.5.0'
|
||||
group = 'io.github.robwin'
|
||||
|
||||
apply plugin: 'java'
|
||||
|
||||
@@ -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}'
|
||||
----
|
||||
|
||||
@@ -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}
|
||||
----
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
|
||||
[source,http]
|
||||
----
|
||||
HTTP/1.1 200 OK
|
||||
Content-Type: application/json
|
||||
Content-Length: 7
|
||||
|
||||
SUCCESS
|
||||
----
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user