mirror of
https://github.com/spring-projects/spring-boot.git
synced 2026-09-17 12:09:16 +00:00
Add spring.data.rest.return-body-on-delete configuration property
This commit adds the missing returnBodyOnDelete property to DataRestProperties, completing the symmetric configuration for controlling response body behavior across all CRUD operations. The property maps to RepositoryRestConfiguration.setReturnBodyOnDelete() which was added in Spring Data REST 4.1. Signed-off-by: paullee714 <woolba714@kakao.com> See gh-48872
This commit is contained in:
committed by
Andy Wilkinson
parent
7d0d003786
commit
1e458eff63
+14
@@ -85,6 +85,11 @@ public class DataRestProperties {
|
||||
*/
|
||||
private @Nullable Boolean returnBodyOnUpdate;
|
||||
|
||||
/**
|
||||
* Whether to return a response body after deleting an entity.
|
||||
*/
|
||||
private @Nullable Boolean returnBodyOnDelete;
|
||||
|
||||
/**
|
||||
* Whether to enable enum value translation through the Spring Data REST default
|
||||
* resource bundle.
|
||||
@@ -171,6 +176,14 @@ public class DataRestProperties {
|
||||
this.returnBodyOnUpdate = returnBodyOnUpdate;
|
||||
}
|
||||
|
||||
public @Nullable Boolean getReturnBodyOnDelete() {
|
||||
return this.returnBodyOnDelete;
|
||||
}
|
||||
|
||||
public void setReturnBodyOnDelete(@Nullable Boolean returnBodyOnDelete) {
|
||||
this.returnBodyOnDelete = returnBodyOnDelete;
|
||||
}
|
||||
|
||||
public @Nullable Boolean getEnableEnumTranslation() {
|
||||
return this.enableEnumTranslation;
|
||||
}
|
||||
@@ -191,6 +204,7 @@ public class DataRestProperties {
|
||||
map.from(this::getDefaultMediaType).to(rest::setDefaultMediaType);
|
||||
map.from(this::getReturnBodyOnCreate).to(rest::setReturnBodyOnCreate);
|
||||
map.from(this::getReturnBodyOnUpdate).to(rest::setReturnBodyOnUpdate);
|
||||
map.from(this::getReturnBodyOnDelete).to(rest::setReturnBodyOnDelete);
|
||||
map.from(this::getEnableEnumTranslation).to(rest::setEnableEnumTranslation);
|
||||
}
|
||||
|
||||
|
||||
+2
-1
@@ -91,7 +91,7 @@ class DataRestAutoConfigurationTests {
|
||||
"spring.data.rest.sort-param-name:_sort", "spring.data.rest.detection-strategy=visibility",
|
||||
"spring.data.rest.default-media-type:application/my-json",
|
||||
"spring.data.rest.return-body-on-create:false", "spring.data.rest.return-body-on-update:false",
|
||||
"spring.data.rest.enable-enum-translation:true");
|
||||
"spring.data.rest.return-body-on-delete:false", "spring.data.rest.enable-enum-translation:true");
|
||||
assertThat(getContext().getBean(RepositoryRestMvcConfiguration.class)).isNotNull();
|
||||
RepositoryRestConfiguration bean = getContext().getBean(RepositoryRestConfiguration.class);
|
||||
assertThat(bean.getDefaultPageSize()).isEqualTo(42);
|
||||
@@ -108,6 +108,7 @@ class DataRestAutoConfigurationTests {
|
||||
private void assertReturnBody(RepositoryRestConfiguration bean) {
|
||||
assertThat(bean.returnBodyOnCreate(null)).isFalse();
|
||||
assertThat(bean.returnBodyOnUpdate(null)).isFalse();
|
||||
assertThat(bean.returnBodyOnDelete(null)).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
Reference in New Issue
Block a user