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

Last change on this file since 509 was 509, checked in by hendrikvanantwerpen, 11 years ago

Reject non-simple answers and fix promise callback.

File size: 8.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      },
20      "required": ["_id","version"],
21      "additionalProperties": false
22    },
23    "docs": {
24      "any": {
25        "type": "object",
26        "oneOf":[
27          { "$ref": "#/definitions/docs/Question" },
28          { "$ref": "#/definitions/docs/Survey" },
29          { "$ref": "#/definitions/docs/SurveyRun" },
30          { "$ref": "#/definitions/docs/Response" }
31        ]
32      },
33      "Question": {
34        "type": "object",
35        "properties": {
36          "type": { "type": "string", "pattern": "^Question$" },
37          "_id": { "$ref": "#/definitions/nonEmptyString" },
38          "_rev": { "$ref": "#/definitions/nonEmptyString" },
39          "categories": { "type": "array", "items": { "$ref": "#/definitions/nonEmptyString" } },
40          "code": { "$ref": "#/definitions/codeString" },
41          "content": { "type": "array", "items": { "$ref": "#/definitions/content/any" } },
42          "description": { "$ref": "#/definitions/nonEmptyString" },
43          "publicationDate": { "type": "string", "format": "datetime" },
44          "title": { "$ref": "#/definitions/nonEmptyString" },
45          "topic": { "$ref": "#/definitions/nonEmptyString" }
46        },
47        "required": ["type","categories","code","content","title"],
48        "additionalProperties": false
49      },
50      "Survey": {
51        "type": "object",
52        "properties": {
53          "type": { "type": "string", "pattern": "^Survey$" },
54          "_id": { "$ref": "#/definitions/nonEmptyString" },
55          "_rev": { "$ref": "#/definitions/nonEmptyString" },
56          "description": { "$ref": "#/definitions/nonEmptyString" },
57          "publicationDate": { "type": "string", "format": "datetime" },
58          "questions": { "type": "array", "items": { "$ref": "#/definitions/docs/Question" } },
59          "title": { "$ref": "#/definitions/nonEmptyString" }
60        },
61        "required": ["type","questions","title"],
62        "additionalProperties": false
63      },
64      "SurveyRun": {
65        "type": "object",
66        "properties": {
67          "type": { "type": "string", "pattern": "^SurveyRun$" },
68          "_id": { "$ref": "#/definitions/nonEmptyString" },
69          "_rev": { "$ref": "#/definitions/nonEmptyString" },
70          "description": { "$ref": "#/definitions/nonEmptyString" },
71          "endDate": { "type": "string", "format": "datetime" },
72          "liveName": { "$ref": "#/definitions/nonEmptyString" },
73          "mode": { "type": "string", "enum": [ "open", "closed" ] },
74          "respondentCanDeleteOwnResponse": { "type": "boolean" },
75          "secret": { "$ref": "#/definitions/nonEmptyString" },
76          "startDate": { "type": "string", "format": "datetime" },
77          "survey": { "$ref": "#/definitions/docs/Survey" },
78          "title": { "$ref": "#/definitions/nonEmptyString" }
79        },
80        "required": ["type","mode","secret","survey","title"],
81        "additionalProperties": false
82      },
83      "Response": {
84        "type": "object",
85        "properties": {
86          "type": { "type": "string", "pattern": "^Response$" },
87          "_id": { "$ref": "#/definitions/nonEmptyString" },
88          "_rev": { "$ref": "#/definitions/nonEmptyString" },
89          "answers": {
90              "type": "object",
91              "patternProperties": {
92                  "^[A-Za-z0-9]+$": { "type": ["string","number"] }
93              },
94              "additionalProperties": false
95          },
96          "email": { "type": "string", "format": "email" },
97          "publicationDate": { "type": "string", "format": "datetime" },
98          "secret": { "$ref": "#/definitions/nonEmptyString" },
99          "surveyRunId": { "$ref": "#/definitions/nonEmptyString" }
100        },
101        "required": ["type","answers","secret","surveyRunId"],
102        "additionalProperties": false
103      }
104    },
105    "content": {
106      "any": {
107        "type": "object",
108        "oneOf": [
109          { "$ref": "#/definitions/content/Header" },
110          { "$ref": "#/definitions/content/Text" },
111          { "$ref": "#/definitions/content/Divider" },
112          { "$ref": "#/definitions/content/StringInput" },
113          { "$ref": "#/definitions/content/TextInput" },
114          { "$ref": "#/definitions/content/NumberInput" },
115          { "$ref": "#/definitions/content/ScaleInput" },
116          { "$ref": "#/definitions/content/MultipleChoiceInput" }
117        ]
118      },
119      "Header": {
120        "type": "object",
121        "properties": {
122          "type": { "type": "string", "pattern": "^Header$" },
123          "text": { "$ref": "#/definitions/nonEmptyString" }
124        },
125        "required": ["type","text"],
126        "additionalProperties": false
127      },
128      "Text": {
129        "type": "object",
130        "properties": {
131          "type": { "type": "string", "pattern": "^Text$" },
132          "text": { "$ref": "#/definitions/nonEmptyString" }
133        },
134        "required": ["type","text"],
135        "additionalProperties": false
136      },
137      "Divider": {
138        "type": "object",
139        "properties": {
140          "type": { "type": "string", "pattern": "^Divider$" }
141        },
142        "additionalProperties": false
143      },
144      "StringInput": {
145        "type": "object",
146        "properties": {
147          "type": { "type": "string", "pattern": "^StringInput$" },
148          "subcode": { "$ref": "#/definitions/codeString" },
149          "text": { "$ref": "#/definitions/nonEmptyString" }
150        },
151        "required":["type","subcode"],
152        "additionalProperties": false
153      },
154      "TextInput": {
155        "type": "object",
156        "properties": {
157          "type": { "type": "string", "pattern": "^TextInput$" },
158          "maxLength": { "type": "integer" },
159          "subcode": { "$ref": "#/definitions/codeString" },
160          "text": { "$ref": "#/definitions/nonEmptyString" }
161        },
162        "required":["type","subcode"],
163        "additionalProperties": false
164      },
165      "NumberInput": {
166        "type": "object",
167        "properties": {
168          "type": { "type": "string", "pattern": "^NumberInput$" },
169          "min": { "type": "integer" },
170          "max": { "type": "integer" },
171          "places": { "type": "integer" },
172          "subcode": { "$ref": "#/definitions/codeString" },
173          "text": { "$ref": "#/definitions/nonEmptyString" }
174        },
175        "required":["type","subcode"],
176        "additionalProperties": false
177      },
178      "ScaleInput": {
179        "type": "object",
180        "properties": {
181          "type": { "type": "string", "pattern": "^ScaleInput$" },
182          "minLabel": { "$ref": "#/definitions/nonEmptyString" },
183          "min": { "type": "integer" },
184          "max": { "type": "integer" },
185          "maxLabel": { "$ref": "#/definitions/nonEmptyString" },
186          "naLabel": { "$ref": "#/definitions/nonEmptyString" },
187          "items": { "type": "array", "items": {
188            "type": "object",
189            "properties": {
190              "minLabel": { "$ref": "#/definitions/nonEmptyString" },
191              "maxLabel": { "$ref": "#/definitions/nonEmptyString" },
192              "subcode": { "$ref": "#/definitions/codeString" },
193              "text": { "$ref": "#/definitions/nonEmptyString" }
194            },
195            "required":["subcode","text"],
196            "additionalProperties": false
197          } }
198        },
199        "required":["type","min","max","items"],
200        "additionalProperties": false
201      },
202      "MultipleChoiceInput": {
203        "type": "object",
204        "properties": {
205          "type": { "type": "string", "pattern": "^MultipleChoiceInput$" },
206          "allowMultiple": { "type": "boolean" },
207          "items": { "type": "array", "items": {
208              "type": "object",
209              "properties": {
210                  "subcode": { "$ref": "#/definitions/codeString" },
211                  "text": { "$ref": "#/definitions/nonEmptyString" }
212              },
213              "required": ["subcode","text"],
214              "additionalProperties": false
215          } },
216          "otherItem": {
217              "type": "object",
218              "properties": {
219                  "subcode": { "$ref": "#/definitions/codeString" },
220                  "text": { "$ref": "#/definitions/nonEmptyString" }
221              },
222              "required": ["subcode","text"],
223              "additionalProperties": false
224          }
225        },
226        "required":["type","items"],
227        "additionalProperties": false
228      }
229    }
230  }
231}
Note: See TracBrowser for help on using the repository browser.