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?
(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.)
What is HATEOAS? HATEOAS is a constraint on REST that says that a client of a REST application need only know a single fixed URL to access it. Any and all resources should be discoverable dynamically from that URL through hyperlinks included in the representations of returned resources.
HATEOAS stands for Hypermedia as the Engine of Application State and it is a component of RESTful API architecture and design.
To implement HATEOAS, we would need to include related resources in the response. Instead of Student we use a return type of EntityModel<Student> . EntityModel is a simple class wrapping a domain object and allows adding links to it. We create a new resource.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With