Skip to content

Commit d84b636

Browse files
authored
Add JSON schemas for structured data feature (#342)
* Add JSON schema for structured data event * Add further schemas * src/schema/statusResponse.json * src/schema/fhir.json * src/schema/clientCapabilities.json * src/schema/statusRequest.json
1 parent 8ae97f7 commit d84b636

6 files changed

Lines changed: 401 additions & 1 deletion

File tree

.github/actions/lint-jsonschema/action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ runs:
2828
if ! check-jsonschema --check-metaschema "$file"; then
2929
rc=1
3030
fi
31-
done < <(find "$SCHEMAS_ROOT" -name "*.json" -maxdepth 1)
31+
done < <(find "$SCHEMAS_ROOT" -name "*.json" -not -path '*/examples/*')
3232
3333
exit $rc
3434

src/schema/clientCapabilities.json

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
{
2+
"$schema": "https://json-schema.org/draft/2020-12/schema",
3+
"$id": "https://gematik.de/ti-m/clientCapabilities.json",
4+
"title": "Client capabilities",
5+
"description": "Schema of the `de.gematik.client_capability.*` objects for storing per-device capabilities in user profiles. See also [MSC4401](https://github.com/matrix-org/matrix-spec-proposals/pull/4401) for further context.",
6+
"type": "object",
7+
"properties": {
8+
"events": {
9+
"description": "A list of objects containing details about the events this device supports.",
10+
"type": "array",
11+
"items": {
12+
"type": "object",
13+
"properties": {
14+
"type": {
15+
"description": "The type of the event.",
16+
"type": "string",
17+
"examples": ["de.wald-krankenhaus.message"]
18+
},
19+
"content": {
20+
"description": "An optional list of objects describing additional requirements for properties inside the content of the event.",
21+
"type": "array",
22+
"items": {
23+
"type": "object",
24+
"properties": {
25+
"key": {
26+
"description": "The dot-separated path of the property (analogous to key in event_match push rule conditions).",
27+
"type": "string",
28+
"examples": ["content.msgtype"]
29+
},
30+
"value": {
31+
"description": "The exact value of the property",
32+
"type": "string",
33+
"examples": ["de.wald-krankenhaus.dicom"]
34+
}
35+
},
36+
"required": [
37+
"key",
38+
"value"
39+
]
40+
}
41+
}
42+
}
43+
}
44+
}
45+
}
46+
}

src/schema/fhir.json

Lines changed: 159 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,159 @@
1+
{
2+
"$schema": "https://json-schema.org/draft/2020-12/schema",
3+
"$id": "https://gematik.de/ti-m/fhir.json",
4+
"title": "FHIR event",
5+
"description": "Schema of the de.gematik.fhir event for exchanging FHIR resources. See also [MSC4302](https://github.com/matrix-org/matrix-spec-proposals/pull/4302) for further context.",
6+
"type": "object",
7+
"properties": {
8+
"type": {
9+
"description": "The event type.",
10+
"type": "string",
11+
"const": "de.gematik.fhir"
12+
},
13+
"content": {
14+
"description": "The event content.",
15+
"type": "object",
16+
"properties": {
17+
"de.gematik.fhir.structure_definition": {
18+
"description": "Information about the resource's `StructureDefinition`.",
19+
"type": "object",
20+
"properties": {
21+
"url": {
22+
"description": "The canonical URL of the most specific `StructureDefinition` describing the resource. This is equivalent to `StructureDefinition.url` in FHIR.",
23+
"type": "string"
24+
},
25+
"version": {
26+
"description": "The version of the `StructureDefinition`. This is equivalent to `StructureDefinition.version` in FHIR.",
27+
"type": "string"
28+
},
29+
"type": {
30+
"description": "The `StructureDefinition`'s base type. This is equivalent to `StructureDefinition.type` in FHIR.",
31+
"type": "string"
32+
},
33+
"fhir_version": {
34+
"description": "The version of the FHIR specification on which the `StructureDefinition` is based. This is equivalent to `StructureDefinition.fhirVersion` in FHIR.",
35+
"type": "string"
36+
}
37+
},
38+
"required": ["url", "version", "type", "fhir_version"]
39+
},
40+
"de.gematik.fhir.resource": {
41+
"description": "The serialised JSON of the resource if it fits within the 64 KiB event size limit. REQUIRED if `de.gematik.fhir.file` is missing.",
42+
"type": "object",
43+
"additionalProperties": true
44+
},
45+
"de.gematik.fhir.file": {
46+
"description": "A file containing the JSON or XML serialisation of the resource if it is too large to be inlined. REQUIRED if `de.gematik.fhir.resource` is missing.",
47+
"type": "object",
48+
"properties": {
49+
"url": {
50+
"description": "The `mxc://` URI for the file.",
51+
"type": "string",
52+
"pattern": "^mxc://.+"
53+
},
54+
"name": {
55+
"description": "Name of the file including extension (if applicable).",
56+
"type": "string"
57+
},
58+
"mimetype": {
59+
"description": "The file's mimetype. Optional but RECOMMENDED.",
60+
"enum": ["application/fhir+json", "application/fhir+xml"]
61+
},
62+
"size": {
63+
"description": "The file's size in bytes. Optional but RECOMMENDED.",
64+
"type": "integer",
65+
"minimum": 0
66+
},
67+
"key": {
68+
"description": "A JSON Web Key object as per the `EncryptedFile` type in `m.room.message`. REQUIRED if the file is encrypted.",
69+
"type": "object"
70+
},
71+
"iv": {
72+
"description": "The 128-bit initialization vector as per the `EncryptedFile` type in `m.room.message`. REQUIRED if the file is encrypted.",
73+
"type": "string"
74+
},
75+
"hashes": {
76+
"description": "A map from an algorithm name to a hash of the ciphertext, encoded as unpadded base64 as per the `EncryptedFile` type in `m.room.message`. REQUIRED if the file is encrypted.",
77+
"type": "object"
78+
},
79+
"v": {
80+
"description": "Version of the encrypted attachments protocol as per the `EncryptedFile` type in `m.room.message`. REQUIRED if the file is encrypted.",
81+
"type": "string"
82+
}
83+
84+
},
85+
"required": ["url", "name"]
86+
},
87+
"de.gematik.text": {
88+
"description": "An ordered array of textual representations of the resource in different mimetypes to be used as fallback by clients that don't understand the event otherwise. Senders MUST specify at least one representation and MUST always include a plaintext representation. Receivers SHOULD use the first representation in the array that they understand.",
89+
"type": "array",
90+
"items": {
91+
"type": "object",
92+
"properties": {
93+
"mimetype": {
94+
"description": "The mimetype. Defaults to `text/plain` if omitted.",
95+
"type": "string",
96+
"examples": ["text/html"]
97+
},
98+
"body": {
99+
"description": "The string content. Clients SHOULD validate and sanitize the content as they do for rich content associated with `msgtype` of `m.room.message`.",
100+
"type": "string"
101+
}
102+
},
103+
"required": ["body"]
104+
},
105+
"minItems": 1
106+
},
107+
"de.gematik.file": {
108+
"description": "A file representation of the resource to be used as fallback by clients that don't understand the event otherwise.",
109+
"type": "object",
110+
"properties": {
111+
"url": {
112+
"description": "The `mxc://` URI for the file.",
113+
"type": "string",
114+
"pattern": "^mxc://.+"
115+
},
116+
"name": {
117+
"description": "Name of the file including extension (if applicable).",
118+
"type": "string"
119+
},
120+
"mimetype": {
121+
"description": "The file's mimetype. Optional but RECOMMENDED.",
122+
"type": "string",
123+
"examples": ["application/pdf"]
124+
},
125+
"size": {
126+
"description": "The file's size in bytes. Optional but RECOMMENDED.",
127+
"type": "integer",
128+
"minimum": 0
129+
},
130+
"key": {
131+
"description": "A JSON Web Key object as per the `EncryptedFile` type in `m.room.message`. REQUIRED if the file is encrypted.",
132+
"type": "object"
133+
},
134+
"iv": {
135+
"description": "The 128-bit initialization vector as per the `EncryptedFile` type in `m.room.message`. REQUIRED if the file is encrypted.",
136+
"type": "string"
137+
},
138+
"hashes": {
139+
"description": "A map from an algorithm name to a hash of the ciphertext, encoded as unpadded base64 as per the `EncryptedFile` type in `m.room.message`. REQUIRED if the file is encrypted.",
140+
"type": "object"
141+
},
142+
"v": {
143+
"description": "Version of the encrypted attachments protocol as per the `EncryptedFile` type in `m.room.message`. REQUIRED if the file is encrypted.",
144+
"type": "string"
145+
}
146+
147+
},
148+
"required": ["url", "name"]
149+
}
150+
},
151+
"anyOf": [{
152+
"required": ["de.gematik.fhir.structure_definition", "de.gematik.text", "de.gematik.fhir.resource"]
153+
}, {
154+
"required": ["de.gematik.fhir.structure_definition", "de.gematik.text", "de.gematik.fhir.file"]
155+
}]
156+
}
157+
},
158+
"required": ["type", "content"]
159+
}

src/schema/statusRequest.json

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"$schema": "https://json-schema.org/draft/2020-12/schema",
3+
"$id": "https://gematik.de/ti-m/statusRequest.json",
4+
"title": "Processing status request",
5+
"description": "Schema of the `de.gematik.request.status` content block for requesting the processing status of an event. See also [MSC4300](https://github.com/matrix-org/matrix-spec-proposals/pull/4300) for further context.",
6+
"type": "object",
7+
"properties": {
8+
"from_device": {
9+
"description": "The sending device's device ID. Allows recipients to optionally submit their responses privately via to-device messages in the future.",
10+
"type": "string"
11+
},
12+
"to_device": {
13+
"description": "The receiving device's device ID. Should be set when the sender wants to address a specific recipient device only. If omitted, the devices of all room members are considered recipients.",
14+
"type": "string"
15+
},
16+
"lifetime": {
17+
"description": "The duration in milliseconds during which the sender will consider responses to this request. Prevents meaningless delayed responses when new or previously disconnected devices encounter requests on older events.",
18+
"type": "integer",
19+
"minimum": 0
20+
}
21+
},
22+
"required": ["from_device"]
23+
}

src/schema/statusResponse.json

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
{
2+
"$schema": "https://json-schema.org/draft/2020-12/schema",
3+
"$id": "https://gematik.de/ti-m/statusResponse.json",
4+
"title": "Processing status response",
5+
"description": "Schema of the de.gematik.response.status event for communicating the processing status of an event back to its sender. See also [MSC4300](https://github.com/matrix-org/matrix-spec-proposals/pull/4300) for further context.",
6+
"type": "object",
7+
"properties": {
8+
"type": {
9+
"description": "The event type.",
10+
"type": "string",
11+
"const": "de.gematik.response.status"
12+
},
13+
"content": {
14+
"type": "object",
15+
"description": "The event content.",
16+
"properties": {
17+
"de.gematik.response.status": {
18+
"type": "object",
19+
"properties": {
20+
"from_device": {
21+
"description": "The sending device's device ID. Helps clients identify the remote echo of their own responses.",
22+
"type": "string"
23+
},
24+
"status": {
25+
"description": "Whether the sending device has understood and successfully processed the event.",
26+
"enum": ["success", "error"]
27+
},
28+
"messages": {
29+
"description": "An optional array of messages to help recipients understand the status.",
30+
"type": "array",
31+
"items": {
32+
"type": "object",
33+
"properties": {
34+
"type": {
35+
"description": "The message category.",
36+
"enum": ["info", "warning", "error"]
37+
},
38+
"de.gematik.text": {
39+
"description": "An ordered array of textual representations of the message in different mimetypes. MUST always include a plaintext representation. Receivers SHOULD use the first representation in the array that they understand.",
40+
"type": "array",
41+
"items": {
42+
"type": "object",
43+
"properties": {
44+
"mimetype": {
45+
"description": "The mimetype. Defaults to `text/plain` if omitted.",
46+
"type": "string",
47+
"examples": ["text/html"]
48+
},
49+
"body": {
50+
"description": "The string content. Clients SHOULD validate and sanitize the content as they do for rich content associated with `msgtype` of `m.room.message`.",
51+
"type": "string"
52+
}
53+
},
54+
"required": ["body"]
55+
},
56+
"minItems": 1
57+
}
58+
},
59+
"required": ["type", "de.gematik.text"]
60+
}
61+
}
62+
},
63+
"required": ["from_device", "status"]
64+
},
65+
"m.relates_to": {
66+
"description": "The relationship of this event to its parent.",
67+
"type": "object",
68+
"properties": {
69+
"rel_type": {
70+
"description": "The namespaced relationship type.",
71+
"type": "string",
72+
"const": "m.reference"
73+
},
74+
"event_id": {
75+
"description": "The ID of the event that contained the de.gematik.request.status content block that this event replies to.",
76+
"type": "string"
77+
}
78+
},
79+
"required": ["rel_type", "event_id"]
80+
}
81+
},
82+
"required": ["de.gematik.response.status", "m.relates_to"]
83+
}
84+
},
85+
"required": ["type", "content"]
86+
}

0 commit comments

Comments
 (0)