Skip to content

Commit

Permalink
Revert "#228 rm input empty string default value (#705)"
Browse files Browse the repository at this point in the history
This reverts commit d4e0af7.
  • Loading branch information
simonhir committed Oct 12, 2023
1 parent d4e0af7 commit 60fe051
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,11 @@ private Map<String, Object> initalizeData(final ServiceDefinitionDetail definiti
//3. simulate previous data for merging and removing JSON.null values
final JSONObject previousData = this.serializationService.initialize(new JSONObject(definition.getJsonSchema()).toString());
final Map<String, Object> clearedData = this.serializationService.merge(filteredData, previousData);
//4. merge with default values
final JSONObject defaultValue = this.serializationService.initialize(new JSONObject(definition.getJsonSchema()).toString());
final Map<String, Object> serializedData = this.serializationService.merge(new JSONObject(clearedData), defaultValue);
//5. map to engine data and return
return this.engineDataMapper.mapObjectsToVariables(clearedData);
return this.engineDataMapper.mapObjectsToVariables(serializedData);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,10 @@ public Map<String, Object> validateAndSerialize(JsonSchema schema, Task task, Ma
val taskData = this.engineDataMapper.mapToData(task.getPayload());
val targetData = this.serializationService.deserializeData(schema.asMap(), taskData);
val serializedData = this.serializationService.merge(filteredData, new JSONObject(targetData));
val defaultValue = this.serializationService.initialize(new JSONObject(schema.getSchema()).toString());
val serializedDataWithDefaultValues = this.serializationService.merge(new JSONObject(serializedData), defaultValue);

return this.engineDataMapper.mapObjectsToVariables(serializedData);
return this.engineDataMapper.mapObjectsToVariables(serializedDataWithDefaultValues);
}

@Override
Expand Down

0 comments on commit 60fe051

Please sign in to comment.