Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,10 @@ public DocumentContext addRule(DocumentContext rawSchemaDocumentContext, Map<Str
}
JSONObject pricingPlanIdSchema = rawSchemaDocumentContext.read(requiredPath);

if (pricingPlansFeed != null) {
JSONArray pricingPlanIds = JsonPath.parse(pricingPlansFeed).read("$.data.plans[*].plan_id");
pricingPlanIdSchema.put("enum", pricingPlanIds);
}
JSONArray pricingPlanIds = pricingPlansFeed != null
? JsonPath.parse(pricingPlansFeed).read("$.data.plans[*].plan_id")
: new JSONArray();
pricingPlanIdSchema.put("enum", pricingPlanIds);

return rawSchemaDocumentContext
.set(requiredPath, pricingPlanIdSchema);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,11 @@ public DocumentContext addRule(DocumentContext rawSchemaDocumentContext, Map<Str
JSONObject defaultPricingPlanIdSchema = rawSchemaDocumentContext.read(DEFAULT_PRICING_PLAN_ID_SCHEMA_PATH);
JSONObject pricingPlanIdsSchema = rawSchemaDocumentContext.read(PRICING_PLAN_IDS_SCHEMA_PATH);

if (pricingPlansFeed != null) {
JSONArray pricingPlanIds = JsonPath.parse(pricingPlansFeed).read("$.data.plans[*].plan_id");
defaultPricingPlanIdSchema.put("enum", pricingPlanIds);
pricingPlanIdsSchema.put("enum", pricingPlanIds);
}
JSONArray pricingPlanIds = pricingPlansFeed != null
? JsonPath.parse(pricingPlansFeed).read("$.data.plans[*].plan_id")
: new JSONArray();
defaultPricingPlanIdSchema.put("enum", pricingPlanIds);
pricingPlanIdsSchema.put("enum", pricingPlanIds);

return rawSchemaDocumentContext
.set(DEFAULT_PRICING_PLAN_ID_SCHEMA_PATH, defaultPricingPlanIdSchema)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,13 @@ public DocumentContext addRule(
REGION_IDS_SCHEMA_PATH
);

if (systemRegionsFeed != null) {
JSONArray regionIds = JsonPath
.parse(systemRegionsFeed)
.read("$.data.regions[*].region_id");
regionIdSchema.put("enum", regionIds);
}
JSONArray regionIds = systemRegionsFeed != null
? JsonPath
.parse(systemRegionsFeed)
.read("$.data.regions[*].region_id")
: new JSONArray();

regionIdSchema.put("enum", regionIds);

return rawSchemaDocumentContext
.set(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,12 @@ public DocumentContext addRule(DocumentContext rawSchemaDocumentContext, Map<Str
JSONObject vehicleTypesAvailableVehicleTypeIdSchema = rawSchemaDocumentContext.read(VEHICLE_TYPES_AVAILABLE_VEHICLE_TYPE_ID_SCHEMA_PATH);
JSONObject vehicleDocksAvailableVehiecleTypeIdSchema = rawSchemaDocumentContext.read(VEHICLE_DOCKS_AVAILABLE_VEHICLE_TYPE_IDS_SCHEMA_PATH);

if (vehicleTypesFeed != null) {
JSONArray vehicleTypeIds = JsonPath.parse(vehicleTypesFeed).read("$.data.vehicle_types[*].vehicle_type_id");
vehicleTypesAvailableVehicleTypeIdSchema.put("enum", vehicleTypeIds);
vehicleDocksAvailableVehiecleTypeIdSchema.put("enum", vehicleTypeIds);
}
// If no vehicle_types feed is defined, then any vehicle_type_id would be invalid
JSONArray vehicleTypeIds = vehicleTypesFeed != null
? JsonPath.parse(vehicleTypesFeed).read("$.data.vehicle_types[*].vehicle_type_id")
: new JSONArray();
vehicleTypesAvailableVehicleTypeIdSchema.put("enum", vehicleTypeIds);
vehicleDocksAvailableVehiecleTypeIdSchema.put("enum", vehicleTypeIds);

return rawSchemaDocumentContext
.set(VEHICLE_TYPES_AVAILABLE_VEHICLE_TYPE_ID_SCHEMA_PATH, vehicleTypesAvailableVehicleTypeIdSchema)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,11 @@ public DocumentContext addRule(DocumentContext rawSchemaDocumentContext, Map<Str
JSONObject vehicleItemsSchema = rawSchemaDocumentContext.read(requiredPath);
if (vehicleTypesFeed != null) {
vehicleItemsSchema.append("required", "vehicle_type_id");
JSONArray vehicleTypeIds = JsonPath.parse(vehicleTypesFeed).read("$.data.vehicle_types[*].vehicle_type_id");
vehicleItemsSchema.getJSONObject( "properties").getJSONObject("vehicle_type_id").put("enum", vehicleTypeIds);
}
JSONArray vehicleTypeIds = vehicleTypesFeed != null
? JsonPath.parse(vehicleTypesFeed).read("$.data.vehicle_types[*].vehicle_type_id")
: new JSONArray();
vehicleItemsSchema.getJSONObject( "properties").getJSONObject("vehicle_type_id").put("enum", vehicleTypeIds);
return rawSchemaDocumentContext.set(requiredPath, vehicleItemsSchema);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ void testFailed2_3Validation() {
FileValidationResult result = validator.validateFile("free_bike_status", freeBikeStatus);

Assertions.assertEquals("2.3", result.version());
Assertions.assertEquals(3, result.errorsCount());
Assertions.assertEquals(6, result.errorsCount());
}

@Test
Expand Down
Loading