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

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