From d7565906783c29061a5a6ffeaeed4a88bb28ddfc Mon Sep 17 00:00:00 2001 From: rmzelle Date: Thu, 21 Feb 2019 00:27:59 -0500 Subject: [PATCH] Update CSL JSON schemas to draft-04 Took changes to test suite from https://github.com/citation-style-language/schema/pull/161 (and https://github.com/citation-style-language/schema/pull/161/commits/b3543 2493553c10532dbbc9b7150c7ed303d2ddd specifically) --- .gitignore | 1 + csl-citation.json | 11 +++++------ csl-data.json | 11 +++++------ tests/requirements.txt | 4 ++-- tests/test_json.py | 6 ++---- 5 files changed, 15 insertions(+), 18 deletions(-) diff --git a/.gitignore b/.gitignore index c1360a75..69463804 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ __pycache__/ .cache .pytest_cache/ +venv/ diff --git a/csl-citation.json b/csl-citation.json index 726c3c15..ac44a75a 100644 --- a/csl-citation.json +++ b/csl-citation.json @@ -1,12 +1,11 @@ { "description": "JSON schema for CSL citation objects", - "$schema" : "http://json-schema.org/draft-03/schema#", + "$schema" : "http://json-schema.org/draft-04/schema#", "id": "https://github.com/citation-style-language/schema/raw/master/csl-citation.json", "type": "object", "properties": { "schema": { "type": "string", - "required": true, "enum" : [ "https://github.com/citation-style-language/schema/raw/master/csl-citation.json" ] @@ -15,8 +14,7 @@ "type": [ "string", "number" - ], - "required": true + ] }, "citationItems": { "type": "array", @@ -27,8 +25,7 @@ "type": [ "string", "number" - ], - "required": true + ] }, "itemData": { "$ref": "csl-data.json/#/items" @@ -84,6 +81,7 @@ } } }, + "required": ["id"], "additionalProperties" : false } }, @@ -97,5 +95,6 @@ "additionalProperties" : false } }, + "required": ["schema", "citationID"], "additionalProperties" : false } diff --git a/csl-data.json b/csl-data.json index fc82a8e4..82a8310f 100644 --- a/csl-data.json +++ b/csl-data.json @@ -1,6 +1,6 @@ { "description": "JSON schema for CSL input data", - "$schema" : "http://json-schema.org/draft-03/schema#", + "$schema" : "http://json-schema.org/draft-04/schema#", "id": "https://github.com/citation-style-language/schema/raw/master/csl-data.json", "type": "array", "items": { @@ -8,7 +8,6 @@ "properties": { "type": { "type": "string", - "required": true, "enum" : [ "article", "article-journal", @@ -51,8 +50,7 @@ "type": [ "string", "number" - ], - "required": true + ] }, "categories": { "type": "array", @@ -73,7 +71,7 @@ "type": "array", "items": { "id": "name-variable", - "type": [ + "anyOf": [ { "properties": { "family" : { @@ -195,7 +193,7 @@ }, "accessed": { "id": "date-variable", - "type": [ + "anyOf": [ { "properties": { "date-parts": { @@ -426,6 +424,7 @@ "type": "string" } }, + "required": ["type", "id"], "additionalProperties" : false } } diff --git a/tests/requirements.txt b/tests/requirements.txt index 2195d5f7..68f14ce8 100644 --- a/tests/requirements.txt +++ b/tests/requirements.txt @@ -1,2 +1,2 @@ -jsonref -jsonschema +jsonschema>=3.0.0a3 +pytest diff --git a/tests/test_json.py b/tests/test_json.py index 3f3cffb1..43ca87de 100644 --- a/tests/test_json.py +++ b/tests/test_json.py @@ -1,7 +1,6 @@ import json import pathlib -import jsonref import jsonschema import pytest @@ -33,15 +32,14 @@ def json_schema(request): """ path = root.joinpath(request.param) text = path.read_text() - # Dereference schemas as workaround for https://github.com/Julian/jsonschema/issues/447 - schema = jsonref.loads(text, jsonschema=True) + schema = json.loads(text) return schema @pytest.fixture def csl_data_validator(): text = root.joinpath('csl-data.json').read_text() - schema = jsonref.loads(text, jsonschema=True) + schema = json.loads(text) Validator = jsonschema.validators.validator_for(schema) return Validator(schema)