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

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