I have a REST service I want to document for my client developing team.
So I added some Links
from Spring-Hateoas
to my resources API, and plugged into it swagger-springmvc
@Api...
annotations to document everything and make a good API reference for my Angular team to be able to understand my REST service.
The problem is that swagger
is unable to discover what links are possible, and just give me a big array of Links
without saying their possible values.
Here is a (simple) example. Swagger detects :
Model Schema
CollectionListResource {
collections (array[CollectionResource]): All available collections,
links (array[Link]): Relations for next actions
}
CollectionResource {
collectionId (string): Collection Unique Id,
name (string): Human readable collection name,
links (array[Link]): Relations for next actions
}
Link {
rel (string, optional),
templated (boolean, optional),
href (string, optional)
}
And I get in fact in HAL :
{"collections":
[{"collectionId":"5370a206b399c65f05a7c59e",
"name":"default",
"_links":{ [
"self":{
"href":"http://localhost:9080/collections/5370a206b399c65f05a7c59e"
},
"delete":{
"href":"http://localhost:9080/collections/5370a206b399c65f05a7c59e"
}
]}
}, ...]}
I've tried to extend Link
and ResourceSupport
to have annoted version of them but this lead me to nowhere.
Is there a way/tool I could use to generate a good API doc telling that a self
relation is to get the content, and a delete
relation is to delete the collection ?
I liked swagger for its good UI, but I don't mind changing my documentation tool if its help having the doc really complete.
I could eventually think of changing spring-hateoas for another link generator, but I'm not sure there is a better tool available right now.