Is it possible to use spring-auto-restdocs with Swagger/SpringFox?

583 views Asked by At

Is it possible to use spring-auto-restdocs with Swagger/SpringFox, swagger2markup?

I'd like to: - Use Swagger/SpringFox to provide the test area BUT then I want the examples in that UI to be similar to what - spring-restdoc does to provide the sample code snippets AND - Use spring-auto-restdocs to get the documentation from POJO that represents your JSON object, by just adding Javadoc to the fields and not the swagger annotations

1

There are 1 answers

1
Florian Benz On

I see no simple way of achieving this. Without using any Swagger code (either annotations or the SpringFox DSL), SpringFox or swagger2markup are not very useful. If you have both Swagger annotations and Spring (Auto) REST Docs, it might be possible to include the AsciiDoc snippets generated by Spring (Auto) REST Docs into the AsciiDoc used for swagger2markup. AsciiDoc supports including other AsciiDoc files and this feature is also used when including the Spring REST Docs snippets into hand-written documentation.

I looked into generating a Swagger/OpenAPI files out of REST Docs snippets and wrote a guide on how to do so https://github.com/fbenz/restdocs-to-swagger However, it is a combination of tools rather than a simple integration. Furthermore, the field and method documentation does not make it into the Swagger files/UI.