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