source: Dev/trunk/src/server/config/couchdb-schema.json

Last change on this file was 531, checked in by hendrikvanantwerpen, 11 years ago
  • Return to using truly ISO formatted dates, including milliseconds.
  • Also set constraint on surveyrun dates when value is initially set.
  • Separate runs & results from surveys and questions.
  • Moved date & email format to schema itself.
File size: 10.0 KB
RevLine 
[479]1{
[487]2  "$schema": "http://json-schema.org/draft-04/schema#",
[479]3  "title": "QED Object Schema",
[508]4  "version": "4",
[480]5  "type": "object",
6  "oneOf": [
[487]7    { "$ref": "#/definitions/schemaInfo" },
8    { "$ref": "#/definitions/docs/any" }
[480]9  ],
[487]10  "definitions": {
[506]11    "nonEmptyString": { "type": "string", "minLength": 1 },
[531]12    "code": { "type": "string", "pattern": "^[A-Za-z0-9]+$" },
13    "subcode": { "type": "string", "pattern": "^[A-Za-z0-9]*$" },
14    "datetime": {"type": "string", "pattern": "^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}\\.[0-9]{3}Z$"},
15    "html5Email": {"type": "string", "pattern": "^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$"},
[487]16    "schemaInfo": {
[479]17      "type": "object",
18      "properties": {
[499]19          "_id": { "type": "string", "pattern": "^schemaInfo$" },
[506]20          "_rev": { "$ref": "#/definitions/nonEmptyString" },
[523]21          "version": { "$ref": "#/definitions/nonEmptyString" },
22          "viewsVersion": { "$ref": "#/definitions/nonEmptyString" }
[479]23      },
[487]24      "required": ["_id","version"],
[479]25      "additionalProperties": false
26    },
[487]27    "docs": {
28      "any": {
29        "type": "object",
30        "oneOf":[
31          { "$ref": "#/definitions/docs/Question" },
32          { "$ref": "#/definitions/docs/Survey" },
33          { "$ref": "#/definitions/docs/SurveyRun" },
34          { "$ref": "#/definitions/docs/Response" }
35        ]
[479]36      },
[487]37      "Question": {
38        "type": "object",
39        "properties": {
[499]40          "type": { "type": "string", "pattern": "^Question$" },
[506]41          "_id": { "$ref": "#/definitions/nonEmptyString" },
42          "_rev": { "$ref": "#/definitions/nonEmptyString" },
43          "categories": { "type": "array", "items": { "$ref": "#/definitions/nonEmptyString" } },
[531]44          "code": { "$ref": "#/definitions/code" },
[487]45          "content": { "type": "array", "items": { "$ref": "#/definitions/content/any" } },
[506]46          "description": { "$ref": "#/definitions/nonEmptyString" },
[531]47          "publicationDate": { "$ref": "#/definitions/datetime" },
[506]48          "title": { "$ref": "#/definitions/nonEmptyString" },
49          "topic": { "$ref": "#/definitions/nonEmptyString" }
[487]50        },
51        "required": ["type","categories","code","content","title"],
52        "additionalProperties": false
[479]53      },
[487]54      "Survey": {
55        "type": "object",
56        "properties": {
[499]57          "type": { "type": "string", "pattern": "^Survey$" },
[506]58          "_id": { "$ref": "#/definitions/nonEmptyString" },
59          "_rev": { "$ref": "#/definitions/nonEmptyString" },
60          "description": { "$ref": "#/definitions/nonEmptyString" },
[531]61          "publicationDate": { "$ref": "#/definitions/datetime" },
[487]62          "questions": { "type": "array", "items": { "$ref": "#/definitions/docs/Question" } },
[506]63          "title": { "$ref": "#/definitions/nonEmptyString" }
[487]64        },
65        "required": ["type","questions","title"],
66        "additionalProperties": false
[479]67      },
[487]68      "SurveyRun": {
[479]69        "type": "object",
70        "properties": {
[499]71          "type": { "type": "string", "pattern": "^SurveyRun$" },
[506]72          "_id": { "$ref": "#/definitions/nonEmptyString" },
73          "_rev": { "$ref": "#/definitions/nonEmptyString" },
74          "description": { "$ref": "#/definitions/nonEmptyString" },
[531]75          "endDate": { "$ref": "#/definitions/datetime" },
[487]76          "mode": { "type": "string", "enum": [ "open", "closed" ] },
[492]77          "respondentCanDeleteOwnResponse": { "type": "boolean" },
[506]78          "secret": { "$ref": "#/definitions/nonEmptyString" },
[531]79          "startDate": { "$ref": "#/definitions/datetime" },
[487]80          "survey": { "$ref": "#/definitions/docs/Survey" },
[506]81          "title": { "$ref": "#/definitions/nonEmptyString" }
[479]82        },
[506]83        "required": ["type","mode","secret","survey","title"],
[479]84        "additionalProperties": false
[487]85      },
86      "Response": {
[479]87        "type": "object",
88        "properties": {
[499]89          "type": { "type": "string", "pattern": "^Response$" },
[506]90          "_id": { "$ref": "#/definitions/nonEmptyString" },
91          "_rev": { "$ref": "#/definitions/nonEmptyString" },
[508]92          "answers": {
93              "type": "object",
94              "patternProperties": {
[509]95                  "^[A-Za-z0-9]+$": { "type": ["string","number"] }
[508]96              },
97              "additionalProperties": false
98          },
[531]99          "publicationDate": { "$ref": "#/definitions/datetime" },
[506]100          "secret": { "$ref": "#/definitions/nonEmptyString" },
101          "surveyRunId": { "$ref": "#/definitions/nonEmptyString" }
[479]102        },
[487]103        "required": ["type","answers","secret","surveyRunId"],
[479]104        "additionalProperties": false
[487]105      }
[479]106    },
[506]107    "content": {
[487]108      "any": {
[479]109        "type": "object",
[487]110        "oneOf": [
[493]111          { "$ref": "#/definitions/content/Header" },
[487]112          { "$ref": "#/definitions/content/Text" },
[493]113          { "$ref": "#/definitions/content/Divider" },
[487]114          { "$ref": "#/definitions/content/StringInput" },
[493]115          { "$ref": "#/definitions/content/TextInput" },
116          { "$ref": "#/definitions/content/NumberInput" },
117          { "$ref": "#/definitions/content/ScaleInput" },
[510]118          { "$ref": "#/definitions/content/SingleChoiceInput" },
[493]119          { "$ref": "#/definitions/content/MultipleChoiceInput" }
[487]120        ]
121      },
[493]122      "Header": {
123        "type": "object",
124        "properties": {
[499]125          "type": { "type": "string", "pattern": "^Header$" },
[506]126          "text": { "$ref": "#/definitions/nonEmptyString" }
[493]127        },
128        "required": ["type","text"],
129        "additionalProperties": false
130      },
[487]131      "Text": {
132        "type": "object",
[479]133        "properties": {
[499]134          "type": { "type": "string", "pattern": "^Text$" },
[506]135          "text": { "$ref": "#/definitions/nonEmptyString" }
[479]136        },
[487]137        "required": ["type","text"],
[479]138        "additionalProperties": false
[487]139      },
[493]140      "Divider": {
141        "type": "object",
142        "properties": {
[499]143          "type": { "type": "string", "pattern": "^Divider$" }
[493]144        },
145        "additionalProperties": false
146      },
[487]147      "StringInput": {
148        "type": "object",
149        "properties": {
[499]150          "type": { "type": "string", "pattern": "^StringInput$" },
[531]151          "subcode": { "$ref": "#/definitions/subcode" },
[506]152          "text": { "$ref": "#/definitions/nonEmptyString" }
[487]153        },
[506]154        "required":["type","subcode"],
[487]155        "additionalProperties": false
156      },
[493]157      "TextInput": {
158        "type": "object",
159        "properties": {
[499]160          "type": { "type": "string", "pattern": "^TextInput$" },
[493]161          "maxLength": { "type": "integer" },
[531]162          "subcode": { "$ref": "#/definitions/subcode" },
[506]163          "text": { "$ref": "#/definitions/nonEmptyString" }
[493]164        },
[506]165        "required":["type","subcode"],
[493]166        "additionalProperties": false
167      },
168      "NumberInput": {
169        "type": "object",
170        "properties": {
[499]171          "type": { "type": "string", "pattern": "^NumberInput$" },
[493]172          "min": { "type": "integer" },
173          "max": { "type": "integer" },
174          "places": { "type": "integer" },
[531]175          "subcode": { "$ref": "#/definitions/subcode" },
[506]176          "text": { "$ref": "#/definitions/nonEmptyString" }
[493]177        },
[506]178        "required":["type","subcode"],
[493]179        "additionalProperties": false
180      },
[487]181      "ScaleInput": {
182        "type": "object",
183        "properties": {
[499]184          "type": { "type": "string", "pattern": "^ScaleInput$" },
[506]185          "minLabel": { "$ref": "#/definitions/nonEmptyString" },
[487]186          "min": { "type": "integer" },
187          "max": { "type": "integer" },
[506]188          "maxLabel": { "$ref": "#/definitions/nonEmptyString" },
189          "naLabel": { "$ref": "#/definitions/nonEmptyString" },
[487]190          "items": { "type": "array", "items": {
191            "type": "object",
192            "properties": {
[506]193              "minLabel": { "$ref": "#/definitions/nonEmptyString" },
194              "maxLabel": { "$ref": "#/definitions/nonEmptyString" },
[531]195              "subcode": { "$ref": "#/definitions/subcode" },
[506]196              "text": { "$ref": "#/definitions/nonEmptyString" }
[487]197            },
[506]198            "required":["subcode","text"],
[487]199            "additionalProperties": false
200          } }
201        },
202        "required":["type","min","max","items"],
203        "additionalProperties": false
[493]204      },
[510]205      "SingleChoiceInput": {
206        "type": "object",
207        "properties": {
208          "type": { "type": "string", "pattern": "^SingleChoiceInput$" },
209          "items": { "type": "array", "items": {
210              "type": "object",
211              "properties": {
212                  "text": { "$ref": "#/definitions/nonEmptyString" },
213                  "value": { "$ref": "#/definitions/nonEmptyString" }
214              },
215              "required": ["text","value"],
216              "additionalProperties": false
217          } },
[511]218          "lastItemIsOpen": {
[510]219              "type": "object",
220              "properties": {
[531]221                  "subcode": { "$ref": "#/definitions/subcode" }
[510]222              },
[511]223              "required": ["subcode"],
[510]224              "additionalProperties": false
225          },
[531]226          "subcode": { "$ref": "#/definitions/subcode" }
[510]227        },
228        "required":["type","items","subcode"],
229        "additionalProperties": false
230      },
[493]231      "MultipleChoiceInput": {
232        "type": "object",
233        "properties": {
[499]234          "type": { "type": "string", "pattern": "^MultipleChoiceInput$" },
[493]235          "items": { "type": "array", "items": {
236              "type": "object",
237              "properties": {
[531]238                "subcode": { "$ref": "#/definitions/subcode" },
[511]239                "text": { "$ref": "#/definitions/nonEmptyString" }
[493]240              },
[506]241              "required": ["subcode","text"],
[493]242              "additionalProperties": false
[506]243          } },
[511]244          "lastItemIsOpen": {
[506]245              "type": "object",
246              "properties": {
[531]247                "subcode": { "$ref": "#/definitions/subcode" }
[506]248              },
[511]249              "required": ["subcode"],
[506]250              "additionalProperties": false
251          }
[493]252        },
253        "required":["type","items"],
254        "additionalProperties": false
[487]255      }
[479]256    }
257  }
258}
Note: See TracBrowser for help on using the repository browser.