diff --git a/integration/admin-client-jee/src/main/java/org/keycloak/admin/client/JacksonProvider.java b/integration/admin-client-jee/src/main/java/org/keycloak/admin/client/JacksonProvider.java index 58317b9bac..39785aab2b 100644 --- a/integration/admin-client-jee/src/main/java/org/keycloak/admin/client/JacksonProvider.java +++ b/integration/admin-client-jee/src/main/java/org/keycloak/admin/client/JacksonProvider.java @@ -1,6 +1,20 @@ package org.keycloak.admin.client; +import javax.ws.rs.core.MediaType; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.databind.ObjectMapper; import org.jboss.resteasy.plugins.providers.jackson.ResteasyJackson2Provider; public class JacksonProvider extends ResteasyJackson2Provider { + + @Override + public ObjectMapper locateMapper(Class type, MediaType mediaType) { + ObjectMapper objectMapper = super.locateMapper(type, mediaType); + + // Same like JSONSerialization class. Makes it possible to use admin-client against older versions of Keycloak server where the properties on representations might be different + objectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL); + + return objectMapper; + } }