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

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