Skip to content

Commit

Permalink
input: Convert root into object, require version
Browse files Browse the repository at this point in the history
Convert the root of schema into an object with metadata, and a required
'version' property.

Include optional 'title' and 'description' properties.

Also, update tests.

Close #319
  • Loading branch information
bdarcus committed Jun 3, 2022
1 parent c7cc717 commit ac091cc
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 18 deletions.
38 changes: 31 additions & 7 deletions schemas/input/csl-data.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,38 @@
"title": "CSL JSON/YAML",
"description": "JSON schema for CSL input data",
"$schema": "http://json-schema.org/draft-07/schema#",
"$id": "https://resource.citationstyles.org/schema/latest/input/json/csl-data.json",
"type": "array",
"items": {
"$ref": "#/definitions/refitem"
"$id": "https://resource.citationstyles.org/schema/v1.1/input/json/csl-data.json",
"type": "object",
"required": ["references", "version"],
"properties": {
"version": {
"type": "number",
"enum": [1.1]
},
"title": {
"type": "string"
},
"description": {
"type": "string"
},
"references": {
"type": "array",
"items": {
"$ref": "#/definitions/refitem"
}
}
},
"definitions": {
"title-variable": {
"title": "Title variable",
"description": "Titles are represented as a string or as an object.",
"anyOf": [
{ "$ref": "#/definitions/rich-text-string" },
{ "$ref": "#/definitions/title-object" }
{
"$ref": "#/definitions/rich-text-string"
},
{
"$ref": "#/definitions/title-object"
}
]
},
"title-object": {
Expand Down Expand Up @@ -90,7 +110,11 @@
"type": "object",
"title": "Literal Date",
"description": "A date that should be passed through to the processor as is; for dates that cannot be represented in EDTF.",
"examples": [{ "literal": "Han Dynasty" }],
"examples": [
{
"literal": "Han Dynasty"
}
],
"properties": {
"literal": {
"type": "string"
Expand Down
32 changes: 21 additions & 11 deletions tests/schemas/input/test_json.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,15 @@ def test_schema_is_valid(json_schema):


def test_basic_data_schema_validates(csl_data_validator):
csl = [{
'id': 'example-id',
'type': 'report',
}]
csl = {
'version': 1.1,
'references': [
{
'id': 'example-id',
'type': 'report',
}
]
}
csl_data_validator.validate(csl)


Expand Down Expand Up @@ -129,14 +134,19 @@ def test_citation_schema_compound_locator_validates(csl_citation_validator):
csl_citation_validator.validate(cite)

def test_basic_data_schema_with_author_validates(csl_data_validator):
csl = [{
"id": "example-id",
"type": "report",
"author": [
{"given": "Jane", "family": "Roe"},
{"institution": "ACME Corporation"}
csl = {
'version': 1.1,
'references': [
{
"id": "example-id",
"type": "report",
"author": [
{"given": "Jane", "family": "Roe"},
{"institution": "ACME Corporation"}
]
}
]
}]
}
csl_data_validator.validate(csl)


Expand Down

0 comments on commit ac091cc

Please sign in to comment.