diff --git a/behaverse/validators/BehaverseJsonValidator.py b/behaverse/validators/BehaverseJsonValidator.py index 52d4307..0095431 100644 --- a/behaverse/validators/BehaverseJsonValidator.py +++ b/behaverse/validators/BehaverseJsonValidator.py @@ -47,10 +47,15 @@ valid_json_file = "data/samples/nback_demo_v.json" schema_file = "behaverse/validators/nback.schema.json" + valid_json_file = "behaverse/validators/test.json" + schema_file = "behaverse/validators/test.schema.json" + + BehaverseJsonValidator(json_schema_path=schema_file).validate_json_file(valid_json_file) + # load and concat json lines #JsonAggregator().convert(original_json_file, valid_json_file) # load and validate json lines - BehaverseJsonValidator(json_schema_path=schema_file).validate_json_file(valid_json_file) + #BehaverseJsonValidator(json_schema_path=schema_file).validate_json_file(valid_json_file) print("Good news everyone! Behaverse JSON file is valid!") \ No newline at end of file diff --git a/behaverse/validators/BehaverseJsonValidator.py b/behaverse/validators/BehaverseJsonValidator.py index 52d4307..0095431 100644 --- a/behaverse/validators/BehaverseJsonValidator.py +++ b/behaverse/validators/BehaverseJsonValidator.py @@ -47,10 +47,15 @@ valid_json_file = "data/samples/nback_demo_v.json" schema_file = "behaverse/validators/nback.schema.json" + valid_json_file = "behaverse/validators/test.json" + schema_file = "behaverse/validators/test.schema.json" + + BehaverseJsonValidator(json_schema_path=schema_file).validate_json_file(valid_json_file) + # load and concat json lines #JsonAggregator().convert(original_json_file, valid_json_file) # load and validate json lines - BehaverseJsonValidator(json_schema_path=schema_file).validate_json_file(valid_json_file) + #BehaverseJsonValidator(json_schema_path=schema_file).validate_json_file(valid_json_file) print("Good news everyone! Behaverse JSON file is valid!") \ No newline at end of file diff --git a/behaverse/validators/test.json b/behaverse/validators/test.json new file mode 100644 index 0000000..951a254 --- /dev/null +++ b/behaverse/validators/test.json @@ -0,0 +1,7 @@ +{ + "base": {}, + "types": ["c13"], + "custom": { + "c2": "hello" + } +} diff --git a/behaverse/validators/BehaverseJsonValidator.py b/behaverse/validators/BehaverseJsonValidator.py index 52d4307..0095431 100644 --- a/behaverse/validators/BehaverseJsonValidator.py +++ b/behaverse/validators/BehaverseJsonValidator.py @@ -47,10 +47,15 @@ valid_json_file = "data/samples/nback_demo_v.json" schema_file = "behaverse/validators/nback.schema.json" + valid_json_file = "behaverse/validators/test.json" + schema_file = "behaverse/validators/test.schema.json" + + BehaverseJsonValidator(json_schema_path=schema_file).validate_json_file(valid_json_file) + # load and concat json lines #JsonAggregator().convert(original_json_file, valid_json_file) # load and validate json lines - BehaverseJsonValidator(json_schema_path=schema_file).validate_json_file(valid_json_file) + #BehaverseJsonValidator(json_schema_path=schema_file).validate_json_file(valid_json_file) print("Good news everyone! Behaverse JSON file is valid!") \ No newline at end of file diff --git a/behaverse/validators/test.json b/behaverse/validators/test.json new file mode 100644 index 0000000..951a254 --- /dev/null +++ b/behaverse/validators/test.json @@ -0,0 +1,7 @@ +{ + "base": {}, + "types": ["c13"], + "custom": { + "c2": "hello" + } +} diff --git a/behaverse/validators/test.schema.json b/behaverse/validators/test.schema.json new file mode 100644 index 0000000..1d2f26b --- /dev/null +++ b/behaverse/validators/test.schema.json @@ -0,0 +1,53 @@ +{ + "definitions": { + "c1": { + "type": "object", + "additionalProperties": false, + "properties": { + "c1": {"type": "object"} + } + }, + "c2": { + "type": "string" + } + }, + "type": "object", + "properties": { + "base": { + "type": "object" + }, + "types": { + "type": "array", + "minItems": 1, + "items": { + "type": "string", + "enum": ["c1", "c2", "c3"] + } + }, + "custom": { + "oneOf": [ + { + "if": { + "properties": { + "types": { + "type": "array", + "contains": {"type":"string", "enum": ["c1"]}}}}, + "then": { + "$ref": "#/definitions/c1" + } + }, + { + "if": { + "properties": { + "types": { + "type": "array", + "contains": {"type":"string", "enum": ["c2"]}}}}, + "then": { + "$ref": "#/definitions/c2" + } + } + ] + } + }, + "required": [ "base", "types", "custom" ] +} \ No newline at end of file