Swagger and RESTful spring resources

In my RESTful API, all resources extend the Spring ResourceSupport base to provide hateful principles for design. For instance:

public class PoolResource extends ResourceSupport { private String name; ... } 

I also use Swagger, and I was wondering: is there any way to configure swagger-ui to ignore properties coming from ResourceSupport?

enter image description here

(Swagger-ui provides a nice and convenient API. As one of the main advantages of using the Swagger API, it’s easy to understand and play with the API for those who are not even familiar with the REST API ... as long as the links are in the picture and "rels".)

+5
source share
5 answers

I would suggest dropping the swagger and using a restclient like Postman . The postman makes the links provided by spring-hateoas clickable, so you can quickly navigate the API. If you want to provide additional information / documentation, you can save these requests to the request collection in Postman and export it for distribution. After I tried several documentation tools for leisure apis, including raml, swagger, apiary and finally the Postman collection combined with hate, I found that the latter is the one I am very pleased with.

+6
source

The only sensible way to hide this would be to hide it from the model itself (there are several ways to do this, but if you are using Spring MVC, I'm not sure if swagger-springmvc is supported).

You could theoretically hack swagger.js to hide it, but it's a whole adventure.

0
source

With Spring Data REST 2.4.0.RELEASE, you now have several forms of metadata:

  • ALPS
  • JSON Schema
  • Install the HAL browser through the spring -data-rest-hal-browser module and search through hypermedia
0
source

Spring RestDocs was created with hyermedia in mind. It works to provide the same benefits as waving in the "generated documents" area, but is not so URL-based.

http://docs.spring.io/spring-restdocs/docs/current/reference/html5/#getting-started-build-configuration

Seeks to output something more consistent with githubs (Hyermedia'd) docs.

https://developer.github.com/v3/#current-version

0
source

Any HAL browser looked

http://api.opensupporter.org/hb2/browser.html#/api/v1

It helps to visualize the network of relationships between resources, so it does not necessarily display sample queries for a resource, but it has areas for displaying documentation.

My thoughts are that this would be an easier way to get your own Hateos documentation. And perhaps one of these hypermedia links may be a website or Valid values ​​may be in the documents mentioned above.

0
source

Source: https://habr.com/ru/post/1211613/


All Articles