Why is DELETE not supported on to-many-association resources in Spring Data REST?

百般思念 提交于 2019-11-30 16:08:34

I just checked the code and you're right, we're actively rejecting DELETE requests for Maps and collections. The rationale is as follows:

An association that is of Map or collection must never be null in the domain model. Translating this into HTTP resources means that the resource will always be available and in the worst case return an empty representation (empty JSON array, or empty JSON object). Accepting a DELETE request would logically null the relationship in the domain model and thus lead to a state that contradicts the very first assumption.

We generally recommend to simply PUT an empty body with media type text/uri-list to the association resource to empty out the associations as that's semantically more correct. Consider it like the difference between truncating and dropping a database table.

If you think that should change and have good reasons that you can back your request with, feel free to open a ticket in our JIRA.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!