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

A method to use a checksum to make sure schema reference hasn't changed #13

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
Open
20 changes: 20 additions & 0 deletions badgeExtensions-schema/badgeClass.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"name": "Sample Extended Badge",
"description": "For doing awesome things in fairly standard ways.",
"image": "https://example.org/extended-badge-longcat.png",
"criteria": "https://example.org/extended-badge.html",
"tags": ["badgeClassExtensions"],
"issuer": "https://example.org/organization.json",
"extensions": [
{
"schema": {
"reference": "http://this-domain.org/schema-age-target-v0.5.json",
"checksum": "sha1$596d1c1c7ab83eed4f62f445fe2489086c6e3d36"
},
"content": {
"age": "5-18",
"grade": "K-12"
}
}
]
}
16 changes: 16 additions & 0 deletions badgeExtensions-schema/schema-age-target-v0.5.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"$schema": "http://json-schema.org/draft-04/schema#",
"title" : "Badge Age Target",
"description": "A suggested age or US grade range targeted by the described badge or learning experience. Use one or both options.",
"type": "object",
"properties": {
"age": {
"description": "The targeted age range for a badge or learning experience (e.g. '6-10')",
"type": "string"
},
"grade": {
"description": "The targeted US grade range for a badge or learning experience (e.g. 'K-3')",
"type": "string"
}
}
}
91 changes: 91 additions & 0 deletions badgeExtensions-schema/schema-badgeClass.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
{
"$schema": "http://json-schema.org/draft-04/schema#",
"title" : "Open Badge BadgeClass Definition v1.1",
"description": "A schematic defining how an issuer defines an open badge to issue to its users",
"type": "object",
"properties": {
"name": {
"description": "A name or title of the particular badge defined in the present badge class, which could then be issued to many recipients.",
"type": "string"
},
"description": {
"description": "A short description of the achievement represented by the present badge.",
"type": "string"
},
"image": {
"description": "The URL of the image that represents the present achievement. It will be baked into a complete badge for each recipient.",
"type": "string",
"format": "uri"
},
"criteria": {
"description": "The URL of a human-readable page describing the criteria for earning the achievement. If the badge represents an educational achievement, consider marking up this up with LRMI.",
"type": "string",
"format": "uri"
},
"issuer": {
"description": "URL of an object describing the organization that issued the badge. Endpoint should be JSON following the IssuerOrganization schema",
"type": "string",
"format": "uri"
},
"tags": {
"description": "An array of text: List of tags that describe the type of achievement.",
"type": "array",
"items": {
"type": "string"
}
},
"alignment": {
"description": "List of objects describing which educational standards this badge aligns to, if any. An array of AlignmentObjects.",
"type": "array",
"items": {
"type": "object",
"properties": {
"name": {
"description": "Name of the alignment.",
"type": "string"
},
"url": {
"description": "URL linking to the official description of the standard.",
"type": "string",
"format": "uri"
},
"description": {
"description": "Short description of the standard.",
"type": "string"
}
},
"required": ["name","url"],
"additionalProperties": false
}
},
"extensions": {
"description": "An array of objects each linking to and fulfilling a schema for additional badge class information",
"type": "array",
"items": {
"type": "object",
"properties": {
"schema": {
"type": "object",
"properties": {
"reference": {
"description": "URL to the JSON-schema file defining the structure of this extension",
"type": "string",
"format": "uri"
},
"checksum": {
"description": "SHA-1 hash of the linked schema file so issuers may avoid downloading it repeatedly. use format: alg$hash",
"type": "string",

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You might also want to include "pattern": "^\w+\$\w+$" (or similar) here.

"pattern": "^\\w+\\$\\w+$"
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I couldn't find many examples of this, but it looks like backslashes in JSON need to be escaped, and schema validators are equipped to handle it like this. Tested, success on http://json-schema-validator.herokuapp.com/index.jsp

}
},
"required": ["reference"]
},
"content": {
"type": "object"
}
},
"required": ["schema", "content"]
}
}
}
}