Skip to content

Commit 905f974

Browse files
committed
ACC-2104 let curies link relation render as array when there are embedded resources
spring-hateoas automatically adds the curies link relation on resources with curied links and also makes sure this curies link relation is rendered as an array. But spring-hateoas doesn't add the curies link relation when there are embedded resources with curied links, we add them manually with SpringDataEmbeddedCuriesResourceProcessor, but this wasn't rendering the link relation as an array.
1 parent 36afc57 commit 905f974

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

contentgrid-appserver-rest/src/main/java/com/contentgrid/appserver/rest/links/curie/ContentGridCurieConfiguration.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,11 @@
44
import org.springframework.context.annotation.Bean;
55
import org.springframework.context.annotation.Configuration;
66
import org.springframework.hateoas.CollectionModel;
7+
import org.springframework.hateoas.mediatype.MediaTypeConfigurationCustomizer;
78
import org.springframework.hateoas.mediatype.hal.CurieProvider;
9+
import org.springframework.hateoas.mediatype.hal.HalConfiguration;
10+
import org.springframework.hateoas.mediatype.hal.HalConfiguration.RenderSingleLinks;
11+
import org.springframework.hateoas.mediatype.hal.HalLinkRelation;
812
import org.springframework.hateoas.server.LinkRelationProvider;
913
import org.springframework.hateoas.server.RepresentationModelProcessor;
1014

@@ -16,6 +20,12 @@
1620
@Configuration(proxyBeanMethods = false)
1721
public class ContentGridCurieConfiguration {
1822

23+
@Bean
24+
MediaTypeConfigurationCustomizer<HalConfiguration> contentGridCuriesMediaTypeConfigurationCustomizer() {
25+
return halConfiguration -> halConfiguration
26+
.withRenderSingleLinksFor(HalLinkRelation.CURIES, RenderSingleLinks.AS_ARRAY);
27+
}
28+
1929
@Bean
2030
CurieProvider contentGridCurieProvider(ObjectProvider<CurieProviderCustomizer> customizers) {
2131
CurieProviderBuilder curieProvider = new ContentGridCurieProvider();

0 commit comments

Comments
 (0)