Swagger and RESTful spring hateoas resources

11,879

Solution 1

I would suggest to throw away swagger and use a restclient like Postman. Postman makes the links provided by spring-hateoas clickable, so you can navigate through the API pretty quickly. If you want to provide some additional information/documentation, you can save those requests into a request collection in Postman and export it for distribution. After I have tried several documentation tools for rest apis, including raml, swagger, apiary and finally Postman-collections in combination with hateaos, I have found the latter to be the one I am most satisfied with.

Solution 2

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

  • ALPS
  • JSON Schema
  • Install the HAL Browser via spring-data-rest-hal-browser module and surf via the hypermedia
Share:
11,879
István Békési
Author by

István Békési

Updated on August 17, 2022

Comments

  • István Békési
    István Békési over 1 year

    In my RESTful API, all resources are extending the Spring's ResourceSupport base, in order to ensure hateoas principals by design. For example:

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

    I'm also using Swagger, and i was wondering: is it possible to configure the swagger-ui somehow, to ignore the properties coming from ResourceSupport?

    enter image description here

    (Swagger-ui provides a nice and easy frontend of the API. As one of the major benefits of using Swagger, the API is easy to understand and play around with the API for those, who are not even familiar with the REST API... as long as the "links" and "rels" come into the picture.)