Updated documentation

This commit is contained in:
Robert Winkler
2015-04-18 13:36:56 +02:00
parent a5300ceab5
commit e23a649c17

View File

@@ -16,8 +16,7 @@ http://asciidoctor.org/docs/asciidoc-writers-guide/[AsciiDoc] is a text document
You can use Swagger2Markup to convert your design-first Swagger YAML into a human-readable format and mix it with hand-written documentation. As an alternative, you can choose the implementation-first approach and use Swagger2Markup together with https://github.com/springfox/springfox[springfox] and https://github.com/spring-projects/spring-restdocs[spring-restdocs]. See usage guide below and <<integration-with-spring-restdocs, Integration with spring-restdocs>>.
You can generate your HTML5 and PDF documentation via https://github.com/asciidoctor/asciidoctorj[asciidoctorj] or even better via the https://github.com/asciidoctor/asciidoctor-gradle-plugin[asciidoctor-gradle-plugin] or https://github.com/aalmiray/markdown-gradle-plugin[markdown-gradle-plugin].
You can also use https://github.com/jbake-org/jbake[JBake], https://github.com/tomchristie/mkdocs[MkDocs] or https://github.com/rtfd/readthedocs.org[ReadTheDocs] to publish your AsciiDoc or Markdown documentation.
You can generate your HTML5 and PDF documentation via https://github.com/asciidoctor/asciidoctorj[asciidoctorj] or even better via the https://github.com/asciidoctor/asciidoctor-gradle-plugin[asciidoctor-gradle-plugin] or https://github.com/aalmiray/markdown-gradle-plugin[markdown-gradle-plugin]. You can also use https://github.com/jbake-org/jbake[JBake], https://github.com/tomchristie/mkdocs[MkDocs] or https://github.com/rtfd/readthedocs.org[ReadTheDocs] to publish your AsciiDoc or Markdown documentation.
The project requires at least JDK 7.
@@ -61,9 +60,8 @@ compile "io.github.robwin:swagger2markup:0.3.0"
=== Using Swagger2Markup
Using the Swagger2MarkupConverter is simple. For instance, you can generate your AsciiDoc/Markdown documentation using https://github.com/spring-projects/spring-boot[Spring Boot] and https://github.com/springfox/springfox[springfox] during the unit or integration test phase.
See demo project https://github.com/RobWin/spring-swagger2markup-demo[spring-swagger2markup-demo] for more details.
The demo shows how you can generate static docs (HTML5 and PDF) with Swagger2Markup and serve them as static content in a Spring Boot App under http://localhost:9080/docs/index.html and http://localhost:9080/docs/index.pdf.
Using the Swagger2MarkupConverter is simple. For example, you can generate your AsciiDoc/Markdown documentation using https://github.com/spring-projects/spring-boot[Spring Boot] and https://github.com/springfox/springfox[springfox] during the unit or integration test phase.
The quickest way to get started is to look at the demo project https://github.com/RobWin/spring-swagger2markup-demo[spring-swagger2markup-demo]. The demo shows how to generate static docs (HTML5 and PDF) with Swagger2Markup and serve them as static content in a Spring Boot App under http://localhost:9080/docs/index.html and http://localhost:9080/docs/index.pdf.
==== Integration Test
[source,java]
@@ -96,7 +94,11 @@ public class Swagger2MarkupTest {
}
----
==== Unit Test together with spring-restdocs
==== Unit Test
Spring's MVC Test framework can also be used to make a request to the Springfox Swagger endpoint of the RESTful service that you are documenting. A custom ResultHandler is used to automatically convert the Swagger JSON response into an AsciiDoc document.
That way you test that your Springfox Swagger endpoint is working, too.
[source,java]
----
@WebAppConfiguration
@@ -113,15 +115,13 @@ public class CreateAsciiDoc {
@Before
public void setUp() {
this.mockMvc = MockMvcBuilders.webAppContextSetup(this.context)
.apply(new RestDocumentationConfigurer()).build();
this.mockMvc = MockMvcBuilders.webAppContextSetup(this.context).build();
}
@Test
public void createAsciiDoc() throws Exception {
this.mockMvc.perform(get("/v2/api-docs")
.accept(MediaType.APPLICATION_JSON))
.andDo(document("get_swagger_doc"))
.andDo(Swagger2MarkupDocumentation.document("swagger_adoc"))
.andExpect(status().isOk());
}