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