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
RevLine 
[479]1{
[487]2  "$schema": "http://json-schema.org/draft-04/schema#",
[479]3  "title": "QED Object Schema",
[487]4  "version": "2",
[480]5  "type": "object",
6  "oneOf": [
[487]7    { "$ref": "#/definitions/schemaInfo" },
8    { "$ref": "#/definitions/docs/any" }
[480]9  ],
[487]10  "definitions": {
11    "schemaInfo": {
[479]12      "type": "object",
13      "properties": {
[499]14          "_id": { "type": "string", "pattern": "^schemaInfo$" },
[487]15          "_rev": { "type": "string" },
16          "version": { "type": "string" }
[479]17      },
[487]18      "required": ["_id","version"],
[479]19      "additionalProperties": false
20    },
[487]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        ]
[479]30      },
[487]31      "Question": {
32        "type": "object",
33        "properties": {
[499]34          "type": { "type": "string", "pattern": "^Question$" },
[487]35          "_id": { "type": "string" },
36          "_rev": { "type": "string" },
37          "categories": { "type": "array", "items": { "type": "string" } },
[492]38          "code": { "type": "string", "minLength": 1 },
[487]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
[479]47      },
[487]48      "Survey": {
49        "type": "object",
50        "properties": {
[499]51          "type": { "type": "string", "pattern": "^Survey$" },
[487]52          "_id": { "type": "string" },
53          "_rev": { "type": "string" },
[492]54          "description": { "type": "string" },
[487]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
[479]61      },
[487]62      "SurveyRun": {
[479]63        "type": "object",
64        "properties": {
[499]65          "type": { "type": "string", "pattern": "^SurveyRun$" },
[487]66          "_id": { "type": "string" },
67          "_rev": { "type": "string" },
68          "description": { "type": "string" },
69          "endDate": { "type": "string", "format": "datetime" },
[492]70          "liveName": { "type": "string" },
[487]71          "mode": { "type": "string", "enum": [ "open", "closed" ] },
[492]72          "respondentCanDeleteOwnResponse": { "type": "boolean" },
73          "secret": { "type": "string", "minLength": 1 },
[487]74          "startDate": { "type": "string", "format": "datetime" },
75          "survey": { "$ref": "#/definitions/docs/Survey" },
76          "title": { "type": "string" }
[479]77        },
[487]78        "required": ["type","description","mode","secret","survey","title"],
[479]79        "additionalProperties": false
[487]80      },
81      "Response": {
[479]82        "type": "object",
83        "properties": {
[499]84          "type": { "type": "string", "pattern": "^Response$" },
[487]85          "_id": { "type": "string" },
86          "_rev": { "type": "string" },
87          "answers": { "type": "object" },
[492]88          "email": { "type": "string", "format": "email" },
[487]89          "publicationDate": { "type": "string", "format": "datetime" },
[492]90          "secret": { "type": "string", "minLength": 1 },
[487]91          "surveyRunId": { "type": "string" }
[479]92        },
[487]93        "required": ["type","answers","secret","surveyRunId"],
[479]94        "additionalProperties": false
[487]95      }
[479]96    },
[487]97    "content":{
98      "any": {
[479]99        "type": "object",
[487]100        "oneOf": [
[493]101          { "$ref": "#/definitions/content/Header" },
[487]102          { "$ref": "#/definitions/content/Text" },
[493]103          { "$ref": "#/definitions/content/Divider" },
[487]104          { "$ref": "#/definitions/content/StringInput" },
[493]105          { "$ref": "#/definitions/content/TextInput" },
106          { "$ref": "#/definitions/content/NumberInput" },
107          { "$ref": "#/definitions/content/ScaleInput" },
108          { "$ref": "#/definitions/content/MultipleChoiceInput" }
[487]109        ]
110      },
[493]111      "Header": {
112        "type": "object",
113        "properties": {
[499]114          "type": { "type": "string", "pattern": "^Header$" },
[493]115          "text": { "type": "string" }
116        },
117        "required": ["type","text"],
118        "additionalProperties": false
119      },
[487]120      "Text": {
121        "type": "object",
[479]122        "properties": {
[499]123          "type": { "type": "string", "pattern": "^Text$" },
[487]124          "text": { "type": "string" }
[479]125        },
[487]126        "required": ["type","text"],
[479]127        "additionalProperties": false
[487]128      },
[493]129      "Divider": {
130        "type": "object",
131        "properties": {
[499]132          "type": { "type": "string", "pattern": "^Divider$" }
[493]133        },
134        "additionalProperties": false
135      },
[487]136      "StringInput": {
137        "type": "object",
138        "properties": {
[499]139          "type": { "type": "string", "pattern": "^StringInput$" },
[487]140          "text": { "type": "string" }
141        },
142        "required":["type","text"],
143        "additionalProperties": false
144      },
[493]145      "TextInput": {
146        "type": "object",
147        "properties": {
[499]148          "type": { "type": "string", "pattern": "^TextInput$" },
[493]149          "maxLength": { "type": "integer" },
150          "text": { "type": "string" }
151        },
152        "required":["type","text"],
153        "additionalProperties": false
154      },
155      "NumberInput": {
156        "type": "object",
157        "properties": {
[499]158          "type": { "type": "string", "pattern": "^NumberInput$" },
[493]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      },
[487]167      "ScaleInput": {
168        "type": "object",
169        "properties": {
[499]170          "type": { "type": "string", "pattern": "^ScaleInput$" },
[487]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
[493]189      },
190      "MultipleChoiceInput": {
191        "type": "object",
192        "properties": {
[499]193          "type": { "type": "string", "pattern": "^MultipleChoiceInput$" },
[493]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
[487]206      }
[479]207    }
208  }
209}
Note: See TracBrowser for help on using the repository browser.