Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

input: Convert root into object, require version #420

Merged
merged 2 commits into from
Jun 3, 2022
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
41 changes: 32 additions & 9 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 @@ -79,8 +99,7 @@
"edtf-string": {
"title": "EDTF date string",
"description": "CSL input supports EDTF, levels 0 and 1.",
"type": "string",
"pattern": "^[0-9-%~X?./]{4,}$"
"type":"string"
},
"date-object-v2": {
"title": "Date Object (v2)",
Expand All @@ -90,7 +109,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