Skip to content

Commit

Permalink
Update CSL JSON schemas to draft-04
Browse files Browse the repository at this point in the history
Took changes to test suite from
#161 (and
https://github.com/citation-style-language/schema/pull/161/commits/b3543
2493553c10532dbbc9b7150c7ed303d2ddd specifically)
  • Loading branch information
rmzelle committed Feb 21, 2019
1 parent f01ba9c commit d756590
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 18 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
__pycache__/
.cache
.pytest_cache/
venv/
11 changes: 5 additions & 6 deletions csl-citation.json
Original file line number Diff line number Diff line change
@@ -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"
]
Expand All @@ -15,8 +14,7 @@
"type": [
"string",
"number"
],
"required": true
]
},
"citationItems": {
"type": "array",
Expand All @@ -27,8 +25,7 @@
"type": [
"string",
"number"
],
"required": true
]
},
"itemData": {
"$ref": "csl-data.json/#/items"
Expand Down Expand Up @@ -84,6 +81,7 @@
}
}
},
"required": ["id"],
"additionalProperties" : false
}
},
Expand All @@ -97,5 +95,6 @@
"additionalProperties" : false
}
},
"required": ["schema", "citationID"],
"additionalProperties" : false
}
11 changes: 5 additions & 6 deletions csl-data.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
{
"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": {
"type": "object",
"properties": {
"type": {
"type": "string",
"required": true,
"enum" : [
"article",
"article-journal",
Expand Down Expand Up @@ -51,8 +50,7 @@
"type": [
"string",
"number"
],
"required": true
]
},
"categories": {
"type": "array",
Expand All @@ -73,7 +71,7 @@
"type": "array",
"items": {
"id": "name-variable",
"type": [
"anyOf": [
{
"properties": {
"family" : {
Expand Down Expand Up @@ -195,7 +193,7 @@
},
"accessed": {
"id": "date-variable",
"type": [
"anyOf": [
{
"properties": {
"date-parts": {
Expand Down Expand Up @@ -426,6 +424,7 @@
"type": "string"
}
},
"required": ["type", "id"],
"additionalProperties" : false
}
}
4 changes: 2 additions & 2 deletions tests/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
jsonref
jsonschema
jsonschema>=3.0.0a3
pytest
6 changes: 2 additions & 4 deletions tests/test_json.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import json
import pathlib

import jsonref
import jsonschema

import pytest
Expand Down Expand Up @@ -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)

Expand Down

0 comments on commit d756590

Please sign in to comment.