Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the benefit of using Spring REST Docs comparing to Swagger

Spring REST Docs was released recently and the documentation says:

This approach frees you from the limitations imposed by tools like Swagger

So, I wanted to ask when Spring REST Docs is preferable to use comparing to Swagger and which limitations it frees.

like image 861
evgeniy44 Avatar asked Dec 24 '15 20:12

evgeniy44


People also ask

Is Springdoc better than Springfox?

springdoc is a much more recent library that does not have so much legacy code as Springfox. As a consequence of the first one, springdoc is actually updated regularly and the amount of open issues is relatively small (only 11 vs 270 on Springfox).

What is spring rest docs?

Spring REST Docs helps you to document RESTful services. It combines hand-written documentation written with Asciidoctor and auto-generated snippets produced with Spring MVC Test. This approach frees you from the limitations of the documentation produced by tools like Swagger.

Why do we use Swagger in spring boot?

Swagger2 is an open source project used to generate the REST API documents for RESTful web services. It provides a user interface to access our RESTful web services via the web browser. To enable the Swagger2 in Spring Boot application, you need to add the following dependencies in our build configurations file.


2 Answers

I just saw a presentation here that touches on your question among other topics:

https://www.youtube.com/watch?v=k5ncCJBarRI&t=26m58s

  • Swagger doesn't support hypermedia at all / it's URI centric

  • Swagger's method of inspecting your code can lag behind your code. It's possible make a change in your code that Swagger fails to understand and won't process properly until Swagger gets updated.

  • Swagger requires lot of annotation, and it's painful to include the descriptive text you want in an api document in annotations.

  • There are just some things that Swagger can't figure out from inspecting your code.

In any case, these are just a couple of points. The presenter does a much better job discussing it than I could.

like image 146
Edgar Ngwenya Avatar answered Oct 05 '22 19:10

Edgar Ngwenya


I thought I would chime in to give a little bit more context surrounding Swagger, what it is, and what it is not. I believe this might help answer your question.

Swagger 2.0 is being adopted by a lot of big names and big platforms like Microsoft Azure, Paypal, SwaggerHub.com, DynamicApis.com, etc... Something to keep in mind is that Swagger is very simply a specification. It is not a framework. There are a lot of frameworks out there built to generate Swagger output that crawl through your code looking at your API information in order to build the Swagger 2.0 JSON file that represents your API. The Swagger UI that you see your APIs on is driven directly from this Swagger 2.0 JSON file. fiddler it to check it out

It is important to note that a framework that was created to allow you to "use swagger" is not how Swagger has to work (i.e. it is completely up to the implementation of the 3rd party framework). If the framework you are using to generate your Swagger 2.0 documents and UI is not working for you then you should be able to go find another framework that generates the Swagger artifacts and swap the technologies out.

Hope this helps.

like image 39
Jerrod Horton Avatar answered Oct 05 '22 19:10

Jerrod Horton