Skip to content

Commit

Permalink
fix: append validation rules instead of replacing pre-existing
Browse files Browse the repository at this point in the history
  • Loading branch information
hbruch committed Jan 4, 2025
1 parent 67aeb3a commit d2cabf5
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,9 @@ public DocumentContext addRule(DocumentContext rawSchemaDocumentContext, Map<Str

JSONObject vehicleItemsSchema = rawSchemaDocumentContext.read(requiredPath);
if (vehicleTypesFeed != null) {
vehicleItemsSchema.put("required", new JSONArray().put("vehicle_type_id"));
vehicleItemsSchema.append("required", "vehicle_type_id");
JSONArray vehicleTypeIds = JsonPath.parse(vehicleTypesFeed).read("$.data.vehicle_types[*].vehicle_type_id");
vehicleItemsSchema.put( "properties", new JSONObject().put("vehicle_type_id", new JSONObject().put("enum", vehicleTypeIds)));
vehicleItemsSchema.getJSONObject( "properties").getJSONObject("vehicle_type_id").put("enum", vehicleTypeIds);
}
return rawSchemaDocumentContext.set(requiredPath, vehicleItemsSchema);
}
Expand Down

0 comments on commit d2cabf5

Please sign in to comment.