Spring Data ReST ref link omission when null or empty

前端 未结 1 668
攒了一身酷
攒了一身酷 2021-01-15 17:11

I\'ve been scouring the docs and the Restbucks implementation by Oliver but I don\'t seem to be able to configure the links on a generated Spring REST repository resource. (

相关标签:
1条回答
  • 2021-01-15 17:30

    Generally speaking you should be able to remove links by just calling Resource.getLinks() and mess with the List returned. If you think a Resource.removeLink(String rel) makes sense, feel free to create a ticket for that.

    However, I'd argue the links pointing to empty resources makes sense as the presence of links has an important role in telling the client that there's a related resource it can interact with. In other words: if the link is not available, how would the client find out about the possibility to assign a related resource, or to add an element to the currently empty collection.

    Links are not only representing the current state of the resource but affordances to what the client shall/can do next. Take the payment link in the RESTBucks project for example. It's only present, if no payment has been placed yet. Once done, the link even disappears. That's actually the opposite of what you're shooting for :).

    0 讨论(0)
提交回复
热议问题