|
| 1 | +{ |
| 2 | + "comments": |
| 3 | + [ " This is a JSON Schema for 'canonical-data.json' files. " |
| 4 | + , " " |
| 5 | + , " It enforces just a general structure for all exercises, " |
| 6 | + , " without specifying how the test data should be organized " |
| 7 | + , " for each type of test. We do this to keep generality and " |
| 8 | + , " allow support for tests the do not fit well in the " |
| 9 | + , " 'function (input) == output' structure, like property " |
| 10 | + , " tests. " |
| 11 | + , " " |
| 12 | + , " The only thing enforced regarding how test data should be " |
| 13 | + , " structured is the error encoding, because it was agreed " |
| 14 | + , " and it doesn't restrict flexibility in a significant way. " |
| 15 | + , " " |
| 16 | + , " Standardized property names may help when automatically " |
| 17 | + , " deriving JSON parsers in some languages, so we followed " |
| 18 | + , " a few conventions from the 'Google JSON Style Guide'. " |
| 19 | + , " " |
| 20 | + , " Additionally, this schema strictly enforces letters, in " |
| 21 | + , " lowerCamelCase, for naming the 'property' being tested. We " |
| 22 | + , " expect this regularity will allow an easier automatic " |
| 23 | + , " generation of function's names in test generators, " |
| 24 | + , " slightly reducing the amount of manually generated code. " |
| 25 | + ], |
| 26 | + |
| 27 | + "$schema": "http://json-schema.org/draft-04/schema#", |
| 28 | + |
| 29 | + "self": { "vendor" : "io.exercism" |
| 30 | + , "name" : "canonical-data" |
| 31 | + , "format" : "jsonschema" |
| 32 | + , "version": "1-0-0" |
| 33 | + }, |
| 34 | + |
| 35 | + "$ref": "#/definitions/canonicalData", |
| 36 | + |
| 37 | + "definitions":{ |
| 38 | + |
| 39 | + "canonicalData": |
| 40 | + { "description": "This is the top-level file structure" |
| 41 | + , "type" : "object" |
| 42 | + , "required" : ["exercise" , "version", "cases"] |
| 43 | + , "properties" : |
| 44 | + { "exercise" : { "$ref": "#/definitions/exercise" } |
| 45 | + , "version" : { "$ref": "#/definitions/version" } |
| 46 | + , "comments" : { "$ref": "#/definitions/comments" } |
| 47 | + , "cases" : { "$ref": "#/definitions/testGroup" } |
| 48 | + } |
| 49 | + , "additionalProperties": false |
| 50 | + }, |
| 51 | + |
| 52 | + "exercise": |
| 53 | + { "description": "Exercise's slug (kebab-case)" |
| 54 | + , "type" : "string" |
| 55 | + , "pattern" : "^[a-z]+(-[a-z]+)*$" |
| 56 | + }, |
| 57 | + |
| 58 | + "version" : |
| 59 | + { "description" : "Semantic versioning: MAJOR.MINOR.PATCH" |
| 60 | + , "type" : "string" |
| 61 | + , "pattern" : "^(0|[1-9][0-9]*)(\\.(0|[1-9][0-9]*)){2}$" |
| 62 | + }, |
| 63 | + |
| 64 | + "comments": |
| 65 | + { "description": "An array of strings to fake multi-line comments" |
| 66 | + , "type" : "array" |
| 67 | + , "items" : { "type": "string" } |
| 68 | + , "minItems" : 1 |
| 69 | + }, |
| 70 | + |
| 71 | + "testGroup": |
| 72 | + { "description": "An array of labeled test items" |
| 73 | + , "type" : "array" |
| 74 | + , "items" : { "$ref": "#/definitions/labeledTestItem" } |
| 75 | + , "minItems" : 1 |
| 76 | + }, |
| 77 | + |
| 78 | + "labeledTestItem": |
| 79 | + { "description": "A single test or group of tests with a description" |
| 80 | + , "oneOf": [ { "$ref": "#/definitions/labeledTest" } |
| 81 | + , { "$ref": "#/definitions/labeledTestGroup" } |
| 82 | + ] |
| 83 | + }, |
| 84 | + |
| 85 | + "labeledTest": |
| 86 | + { "description": "A single test with a description" |
| 87 | + , "type" : "object" |
| 88 | + , "required" : ["description", "property"] |
| 89 | + , "properties" : |
| 90 | + { "description": { "$ref": "#/definitions/description" } |
| 91 | + , "comments" : { "$ref": "#/definitions/comments" } |
| 92 | + , "property" : { "$ref": "#/definitions/property" } |
| 93 | + , "expected" : { "$ref": "#/definitions/expected" } |
| 94 | + } |
| 95 | + }, |
| 96 | + |
| 97 | + "labeledTestGroup": |
| 98 | + { "description": "A group of tests with a description" |
| 99 | + , "type" : "object" |
| 100 | + , "required" : ["description", "cases"] |
| 101 | + , "properties" : |
| 102 | + { "description": { "$ref": "#/definitions/description" } |
| 103 | + , "comments" : { "$ref": "#/definitions/comments" } |
| 104 | + , "cases" : { "$ref": "#/definitions/testGroup" } |
| 105 | + } |
| 106 | + , "additionalProperties": false |
| 107 | + }, |
| 108 | + |
| 109 | + "description": |
| 110 | + { "description": "A short, clear, one-line description" |
| 111 | + , "type" : "string" |
| 112 | + }, |
| 113 | + |
| 114 | + "property": |
| 115 | + { "description": "A letters-only, lowerCamelCase property name" |
| 116 | + , "type" : "string" |
| 117 | + , "pattern" : "^[a-z]+([A-Z][a-z]+)*[A-Z]?$" |
| 118 | + }, |
| 119 | + |
| 120 | + "expected": |
| 121 | + { "description": "The expected return value of a test case" |
| 122 | + , "properties": |
| 123 | + { "error": { "$ref": "#/definitions/error" } |
| 124 | + } |
| 125 | + , "dependencies": |
| 126 | + { "error": { "maxProperties": 1 } |
| 127 | + } |
| 128 | + }, |
| 129 | + |
| 130 | + "error": |
| 131 | + { "description": "A message describing an error condition" |
| 132 | + , "type" : "string" |
| 133 | + } |
| 134 | + |
| 135 | + } |
| 136 | + |
| 137 | +} |
0 commit comments