Swagger and RESTful spring hateoas resources

István Békési picture István Békési · Jan 21, 2015 · Viewed 11.3k times · Source

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.)

Answer

Thomas Eizinger picture Thomas Eizinger · Jan 23, 2015

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.