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

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

Changes for validation

  • Split command line wrappers from processing logic.
  • Created a JSON Schema for the database
  • Allow off-line validation of database documents.
File size: 4.0 KB
Line 
1{
2  "title": "QED Object Schema",
3  "$ref": "#/docTypes/any",
4  "docTypes": {
5    "any": {
6      "type": "object",
7      "oneOf": [
8        { "$ref": "#/docTypes/Question" },
9        { "$ref": "#/docTypes/Survey" },
10        { "$ref": "#/docTypes/SurveyRun" },
11        { "$ref": "#/docTypes/Response" }
12      ]
13    },
14    "Question": {
15      "properties": {
16        "type": { "type": "string", "pattern": "Question" },
17        "_id": { "type": "string", "optional": true },
18        "_rev": { "type": "string", "optional": true },
19        "categories": { "type": "array", "items": { "type": "string" } },
20        "code": { "type": "string" },
21        "content": { "type": "array", "items": { "$ref": "#/contentTypes/any" } },
22        "description": { "type": "string", "optional": true },
23        "publicationDate": { "type": "string", "pattern": "", "optional": true },
24        "title": { "type": "string" },
25        "topic": { "type": "string", "optional": true }
26      },
27      "additionalProperties": false
28    },
29    "Survey": {
30      "type": "object",
31      "properties": {
32        "type": { "type": "string", "pattern": "Survey" },
33        "_id": { "type": "string", "optional": true },
34        "_rev": { "type": "string", "optional": true },
35        "publicationDate": { "type": "string", "pattern": "", "optional": true },
36        "questions": { "type": "array", "items": { "$ref": "#/docTypes/Question" } },
37        "title": { "type": "string" }
38      },
39      "additionalProperties": false
40    },
41    "SurveyRun": {
42      "type": "object",
43      "properties": {
44        "type": { "type": "string", "pattern": "SurveyRun" },
45        "_id": { "type": "string", "optional": true },
46        "_rev": { "type": "string", "optional": true },
47        "description": { "type": "string" },
48        "endDate": { "type": "string", "pattern": "" },
49        "mode": { "type": "string", "enum": [ "open", "closed" ] },
50        "startDate": { "type": "string", "pattern": "" },
51        "survey": { "$ref": "#/docTypes/Survey" },
52        "title": { "type": "string" }
53      },
54      "additionalProperties": false
55    },
56    "Response": {
57      "type": "object",
58      "properties": {
59        "type": { "type": "string", "pattern": "Response" },
60        "_id": { "type": "string", "optional": true },
61        "_rev": { "type": "string", "optional": true },
62        "answers": { "type": "object" },
63        "publicationDate": { "type": "string", "pattern": "", "optional": true },
64        "surveyRunId": { "type": "string" }
65      },
66      "additionalProperties": false
67    }
68  },
69  "contentTypes": {
70    "any": {
71      "type": "object",
72      "oneOf": [
73        { "$ref": "#/contentTypes/Text" },
74        { "$ref": "#/contentTypes/StringInput" },
75        { "$ref": "#/contentTypes/ScaleInput" }
76      ]
77    },
78    "Text": {
79        "type": "object",
80        "properties": {
81            "type": { "type": "string", "pattern": "Text" },
82            "text": { "type": "string" }
83        },
84        "additionalProperties": false
85    },
86    "StringInput": {
87        "type": "object",
88        "properties": {
89            "type": { "type": "string", "pattern": "StringInput" },
90            "text": { "type": "string" }
91        },
92        "additionalProperties": false
93    },
94    "ScaleInput": {
95        "type": "object",
96        "properties": {
97            "type": { "type": "string", "pattern": "ScaleInput" },
98            "minLabel": { "type": "string", "optional": true },
99            "min": { "type": "integer" },
100            "max": { "type": "integer" },
101            "maxLabel": { "type": "string", "optional": true },
102            "naLabel": { "type": "string", "optional": true },
103            "items": { "type": "array", "items": {
104                "type": "object",
105                "properties": {
106                    "text": { "type": "string" },
107                    "minLabel": { "type": "string", "optional": true },
108                    "maxLabel": { "type": "string", "optional": true }
109                },
110                "additionalProperties": false
111            } }
112        },
113        "additionalProperties": false
114    }
115  }
116}
Note: See TracBrowser for help on using the repository browser.