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
Changes from 1 commit
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
Next Next commit
input: Convert root into object, require version
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
bdarcus committed Jun 2, 2022
commit 75a879d26532603249cbc8a89ebe608b9975ea74
38 changes: 31 additions & 7 deletions schemas/input/csl-data.json
Original file line number Diff line number Diff line change
@@ -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": {
@@ -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"
32 changes: 21 additions & 11 deletions tests/schemas/input/test_json.py
Original file line number Diff line number Diff line change
@@ -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)


@@ -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)