Ensure null values are not serialized when fetching workflows in YAML format

Closes #44396

Signed-off-by: Stefan Guilhen <sguilhen@redhat.com>
This commit is contained in:
Stefan Guilhen 2025-11-21 18:47:16 -03:00 committed by Pedro Igor
parent 3ec0dd24fe
commit 3e312d91d8
3 changed files with 5 additions and 3 deletions

View File

@ -8,6 +8,7 @@ import org.keycloak.common.util.MultivaluedHashMap;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
@ -25,6 +26,7 @@ import static org.keycloak.representations.workflows.WorkflowConstants.CONFIG_WI
@JsonPropertyOrder({"id", CONFIG_NAME, CONFIG_USES, CONFIG_ENABLED, CONFIG_ON_EVENT, CONFIG_CONCURRENCY, CONFIG_IF, CONFIG_STEPS, CONFIG_STATE})
@JsonIgnoreProperties(CONFIG_WITH)
@JsonInclude(JsonInclude.Include.NON_NULL)
public final class WorkflowRepresentation extends AbstractWorkflowComponentRepresentation {
public static Builder withName(String name) {
@ -137,7 +139,6 @@ public final class WorkflowRepresentation extends AbstractWorkflowComponentRepre
return false;
}
WorkflowRepresentation that = (WorkflowRepresentation) obj;
// TODO: include state in comparison?
return Objects.equals(getConfig(), that.getConfig()) && Objects.equals(getSteps(), that.getSteps());
}

View File

@ -18,7 +18,7 @@ import static org.keycloak.representations.workflows.WorkflowConstants.CONFIG_US
import static org.keycloak.representations.workflows.WorkflowConstants.CONFIG_WITH;
@JsonPropertyOrder({CONFIG_USES, CONFIG_AFTER, CONFIG_PRIORITY, CONFIG_WITH})
@JsonInclude(JsonInclude.Include.NON_EMPTY)
@JsonInclude(JsonInclude.Include.NON_NULL)
public final class WorkflowStepRepresentation extends AbstractWorkflowComponentRepresentation {
private final String uses;
@ -51,6 +51,7 @@ public final class WorkflowStepRepresentation extends AbstractWorkflowComponentR
@JsonSerialize(using = MultivaluedHashMapValueSerializer.class)
@JsonDeserialize(using = MultivaluedHashMapValueDeserializer.class)
@JsonInclude(value=JsonInclude.Include.NON_EMPTY, content=JsonInclude.Include.NON_NULL)
public MultivaluedHashMap<String, String> getConfig() {
return super.getConfig();
}

View File

@ -55,7 +55,7 @@ public class WorkflowResource {
}
@GET
@Produces({MediaType.APPLICATION_JSON, YAMLMediaTypes.APPLICATION_JACKSON_YAML})
@Produces({YAMLMediaTypes.APPLICATION_JACKSON_YAML, MediaType.APPLICATION_JSON})
public WorkflowRepresentation toRepresentation(
@Parameter(description = "Indicates whether the workflow id should be included in the representation or not - defaults to true") @QueryParam("includeId") Boolean includeId
) {