Skip to content

Commit

Permalink
[Fix #380] SwitchPRoperty to SwitchItem
Browse files Browse the repository at this point in the history
Signed-off-by: Francisco Javier Tirado Sarti <[email protected]>
  • Loading branch information
fjtirado committed Jun 27, 2024
1 parent 77746af commit 2fdcdab
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import com.fasterxml.jackson.dataformat.yaml.YAMLFactory;
import com.fasterxml.jackson.dataformat.yaml.YAMLGenerator.Feature;
import io.serverlessworkflow.api.types.CallTask;
import io.serverlessworkflow.api.types.Switch;
import io.serverlessworkflow.api.types.SwitchItem;
import io.serverlessworkflow.api.types.Task;
import io.serverlessworkflow.api.types.TaskItem;

Expand All @@ -48,8 +48,8 @@ private static ObjectMapper configure(ObjectMapper mapper) {
simpleModule.addSerializer(CallTask.class, new CallTaskSerializer());
simpleModule.addDeserializer(TaskItem.class, new TaskItemDeserializer());
simpleModule.addSerializer(TaskItem.class, new TaskItemSerializer());
simpleModule.addSerializer(Switch.class, new SwitchSerializer());
simpleModule.addDeserializer(Switch.class, new SwitchDeserializer());
simpleModule.addSerializer(SwitchItem.class, new SwitchItemSerializer());
simpleModule.addDeserializer(SwitchItem.class, new SwitchItemDeserializer());

return mapper
.configure(SerializationFeature.INDENT_OUTPUT, true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@
import com.fasterxml.jackson.databind.DeserializationContext;
import com.fasterxml.jackson.databind.JsonDeserializer;
import io.serverlessworkflow.api.types.Switch;
import io.serverlessworkflow.api.types.SwitchProperty;
import io.serverlessworkflow.api.types.SwitchItem;
import java.io.IOException;

class SwitchDeserializer extends JsonDeserializer<Switch> {
class SwitchItemDeserializer extends JsonDeserializer<SwitchItem> {

@Override
public Switch deserialize(JsonParser p, DeserializationContext ctxt) throws IOException {
return DeserializeHelper.deserializeItem(p, Switch.class, SwitchProperty.class);
public SwitchItem deserialize(JsonParser p, DeserializationContext ctxt) throws IOException {
return DeserializeHelper.deserializeItem(p, SwitchItem.class, Switch.class);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,16 @@
import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.JsonSerializer;
import com.fasterxml.jackson.databind.SerializerProvider;
import io.serverlessworkflow.api.types.Switch;
import io.serverlessworkflow.api.types.SwitchItem;
import java.io.IOException;

class SwitchSerializer extends JsonSerializer<Switch> {
class SwitchItemSerializer extends JsonSerializer<SwitchItem> {

@Override
public void serialize(Switch value, JsonGenerator gen, SerializerProvider serializers)
public void serialize(SwitchItem value, JsonGenerator gen, SerializerProvider serializers)
throws IOException {
gen.writeStartObject();
gen.writeObjectField(value.getName(), value.getSwitchProperty());
gen.writeObjectField(value.getName(), value.getSwitch());
gen.writeEndObject();
}
}
2 changes: 2 additions & 0 deletions api/src/main/resources/schema/workflow.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -569,10 +569,12 @@ $defs:
minItems: 1
items:
type: object
title: SwitchItem
minProperties: 1
maxProperties: 1
additionalProperties:
type: object
title: Switch
properties:
name:
type: string
Expand Down

0 comments on commit 2fdcdab

Please sign in to comment.