Skip to content

Commit

Permalink
strict objectmapper to detect misspelled fields
Browse files Browse the repository at this point in the history
  • Loading branch information
abyrd committed Oct 2, 2024
1 parent c417eee commit e3094f8
Showing 1 changed file with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import com.conveyal.r5.analyst.progress.ProgressInputStream;
import com.conveyal.r5.analyst.cluster.TransportNetworkConfig;
import com.conveyal.r5.analyst.progress.Task;
import com.conveyal.r5.common.JsonUtilities;
import com.conveyal.r5.streets.OSMCache;
import com.conveyal.r5.util.ExceptionUtils;
import com.mongodb.QueryBuilder;
Expand Down Expand Up @@ -136,8 +137,9 @@ private Bundle create (Request req, Response res) {
if (files.get("config") != null) {
// For validation, rather than reading as freeform JSON, deserialize into a model class instance.
// However, only the instance fields specifying things other than OSM and GTFS IDs will be retained.
// Use strict object mapper (from the strict/lenient pair) to fail on misspelled field names.
String configString = files.get("config").get(0).getString();
bundle.config = JsonUtil.objectMapper.readValue(configString, TransportNetworkConfig.class);
bundle.config = JsonUtilities.objectMapper.readValue(configString, TransportNetworkConfig.class);
}
UserPermissions userPermissions = UserPermissions.from(req);
bundle.accessGroup = userPermissions.accessGroup;
Expand Down

0 comments on commit e3094f8

Please sign in to comment.