From 6147562d14a0efb7fe14b64c1cf8637a0c86bf8f Mon Sep 17 00:00:00 2001 From: Mark Haines Date: Thu, 17 Sep 2015 10:09:37 +0100 Subject: [PATCH 1/6] Split the "core" definition files into separate files. To make it easier to use the schema files with tools that don't support deep links. --- event-schemas/schema/v1/core | 88 ------------------- event-schemas/schema/v1/core/event.json | 24 +++++ .../v1/core/msgtype_infos/image_info.json | 23 +++++ event-schemas/schema/v1/core/room_event.json | 16 ++++ event-schemas/schema/v1/core/state_event.json | 20 +++++ event-schemas/schema/v1/m.call.answer | 2 +- event-schemas/schema/v1/m.call.candidates | 2 +- event-schemas/schema/v1/m.call.hangup | 2 +- event-schemas/schema/v1/m.call.invite | 2 +- event-schemas/schema/v1/m.room.aliases | 2 +- .../schema/v1/m.room.canonical_alias | 2 +- event-schemas/schema/v1/m.room.create | 2 +- .../schema/v1/m.room.history_visibility | 2 +- event-schemas/schema/v1/m.room.join_rules | 2 +- event-schemas/schema/v1/m.room.member | 2 +- event-schemas/schema/v1/m.room.message | 2 +- .../schema/v1/m.room.message#m.audio | 2 +- .../schema/v1/m.room.message#m.emote | 2 +- event-schemas/schema/v1/m.room.message#m.file | 4 +- .../schema/v1/m.room.message#m.image | 4 +- .../schema/v1/m.room.message#m.location | 4 +- .../schema/v1/m.room.message#m.notice | 2 +- event-schemas/schema/v1/m.room.message#m.text | 2 +- .../schema/v1/m.room.message#m.video | 4 +- .../schema/v1/m.room.message.feedback | 2 +- event-schemas/schema/v1/m.room.name | 2 +- event-schemas/schema/v1/m.room.power_levels | 2 +- event-schemas/schema/v1/m.room.redaction | 2 +- event-schemas/schema/v1/m.room.topic | 2 +- 29 files changed, 111 insertions(+), 116 deletions(-) delete mode 100644 event-schemas/schema/v1/core create mode 100644 event-schemas/schema/v1/core/event.json create mode 100644 event-schemas/schema/v1/core/msgtype_infos/image_info.json create mode 100644 event-schemas/schema/v1/core/room_event.json create mode 100644 event-schemas/schema/v1/core/state_event.json diff --git a/event-schemas/schema/v1/core b/event-schemas/schema/v1/core deleted file mode 100644 index ed374a69..00000000 --- a/event-schemas/schema/v1/core +++ /dev/null @@ -1,88 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-04/schema#", - "definitions": { - "event": { - "title": "Event", - "description": "The basic set of fields all events must have.", - "type": "object", - "properties": { - "event_id": { - "type": "string", - "description": "The globally unique event identifier." - }, - "user_id": { - "type": "string", - "description": "Contains the fully-qualified ID of the user who *sent* this event." - }, - "content": { - "type": "object", - "description": "The fields in this object will vary depending on the type of event. When interacting with the REST API, this is the HTTP body." - }, - "type": { - "type": "string", - "description": "The type of event. This SHOULD be namespaced similar to Java package naming conventions e.g. 'com.example.subdomain.event.type'" - } - }, - "required": ["event_id", "user_id", "content", "type"] - }, - "room_event": { - "type": "object", - "title": "Room Event", - "description": "In addition to the Event fields, Room Events MUST have the following additional field.", - "allOf":[{ - "$ref": "#/definitions/event" - }], - "properties": { - "room_id": { - "type": "string", - "description": "The ID of the room associated with this event." - } - }, - "required": ["room_id"] - }, - "state_event": { - "type": "object", - "title": "State Event", - "description": "In addition to the Room Event fields, State Events have the following additional fields.", - "allOf":[{ - "$ref": "#/definitions/room_event" - }], - "properties": { - "state_key": { - "type": "string", - "description": "A unique key which defines the overwriting semantics for this piece of room state. This value is often a zero-length string. The presence of this key makes this event a State Event." - }, - "prev_content": { - "type": "object", - "description": "Optional. The previous ``content`` for this event. If there is no previous content, this key will be missing." - } - }, - "required": ["state_key"] - }, - "msgtype_infos": { - "image_info": { - "type": "object", - "title": "ImageInfo", - "description": "Metadata about an image.", - "properties": { - "size": { - "type": "integer", - "description": "Size of the image in bytes." - }, - "w": { - "type": "integer", - "description": "The width of the image in pixels." - }, - "h": { - "type": "integer", - "description": "The height of the image in pixels." - }, - "mimetype": { - "type": "string", - "description": "The mimetype of the image, e.g. ``image/jpeg``." - } - } - } - } - } -} diff --git a/event-schemas/schema/v1/core/event.json b/event-schemas/schema/v1/core/event.json new file mode 100644 index 00000000..b4824079 --- /dev/null +++ b/event-schemas/schema/v1/core/event.json @@ -0,0 +1,24 @@ +{ + "$schema": "http://json-schema.org/draft-04/schema#", + "type": "object", + "title": "Event", + "description": "The basic set of fields all events must have.", + "properties": { + "event_id": { + "type": "string", + "description": "The globally unique event identifier." + }, + "user_id": { + "type": "string", + "description": "Contains the fully-qualified ID of the user who *sent* this event." + }, + "content": { + "type": "object", + "description": "The fields in this object will vary depending on the type of event. When interacting with the REST API, this is the HTTP body." + }, + "type": { + "type": "string", + "description": "The type of event. This SHOULD be namespaced similar to Java package naming conventions e.g. 'com.example.subdomain.event.type'" + } + } +} diff --git a/event-schemas/schema/v1/core/msgtype_infos/image_info.json b/event-schemas/schema/v1/core/msgtype_infos/image_info.json new file mode 100644 index 00000000..ee75745e --- /dev/null +++ b/event-schemas/schema/v1/core/msgtype_infos/image_info.json @@ -0,0 +1,23 @@ +{ + "$schema": "http://json-schema.org/draft-04/schema#", + "title": "ImageInfo", + "description": "Metadata about an image.", + "properties": { + "size": { + "type": "integer", + "description": "Size of the image in bytes." + }, + "w": { + "type": "integer", + "description": "The width of the image in pixels." + }, + "h": { + "type": "integer", + "description": "The height of the image in pixels." + }, + "mimetype": { + "type": "string", + "description": "The mimetype of the image, e.g. ``image/jpeg``." + } + } +} diff --git a/event-schemas/schema/v1/core/room_event.json b/event-schemas/schema/v1/core/room_event.json new file mode 100644 index 00000000..717cdaae --- /dev/null +++ b/event-schemas/schema/v1/core/room_event.json @@ -0,0 +1,16 @@ +{ + "$schema": "http://json-schema.org/draft-04/schema#", + "type": "object", + "title": "Room Event", + "description": "In addition to the Event fields, Room Events MUST have the following additional field.", + "allOf":[{ + "$ref": "core/event.json" + }], + "properties": { + "room_id": { + "type": "string", + "description": "The ID of the room associated with this event." + } + }, + "required": ["room_id"] +} diff --git a/event-schemas/schema/v1/core/state_event.json b/event-schemas/schema/v1/core/state_event.json new file mode 100644 index 00000000..a237f4d1 --- /dev/null +++ b/event-schemas/schema/v1/core/state_event.json @@ -0,0 +1,20 @@ +{ + "$schema": "http://json-schema.org/draft-04/schema#", + "type": "object", + "title": "State Event", + "description": "In addition to the Room Event fields, State Events have the following additional fields.", + "allOf":[{ + "$ref": "core/room_event.json" + }], + "properties": { + "state_key": { + "type": "string", + "description": "A unique key which defines the overwriting semantics for this piece of room state. This value is often a zero-length string. The presence of this key makes this event a State Event." + }, + "prev_content": { + "type": "object", + "description": "Optional. The previous ``content`` for this event. If there is no previous content, this key will be missing." + } + }, + "required": ["state_key"] +} diff --git a/event-schemas/schema/v1/m.call.answer b/event-schemas/schema/v1/m.call.answer index 598554f0..abdf4a9b 100644 --- a/event-schemas/schema/v1/m.call.answer +++ b/event-schemas/schema/v1/m.call.answer @@ -3,7 +3,7 @@ "type": "object", "description": "This event is sent by the callee when they wish to answer the call.", "allOf": [{ - "$ref": "core#/definitions/room_event" + "$ref": "core/room_event.json" }], "properties": { "content": { diff --git a/event-schemas/schema/v1/m.call.candidates b/event-schemas/schema/v1/m.call.candidates index 6475cf51..052ead0b 100644 --- a/event-schemas/schema/v1/m.call.candidates +++ b/event-schemas/schema/v1/m.call.candidates @@ -3,7 +3,7 @@ "type": "object", "description": "This event is sent by callers after sending an invite and by the callee after answering. Its purpose is to give the other party additional ICE candidates to try using to communicate.", "allOf": [{ - "$ref": "core#/definitions/room_event" + "$ref": "core/room_event.json" }], "properties": { "content": { diff --git a/event-schemas/schema/v1/m.call.hangup b/event-schemas/schema/v1/m.call.hangup index 3704ec75..383952d8 100644 --- a/event-schemas/schema/v1/m.call.hangup +++ b/event-schemas/schema/v1/m.call.hangup @@ -3,7 +3,7 @@ "type": "object", "description": "Sent by either party to signal their termination of the call. This can be sent either once the call has has been established or before to abort the call.", "allOf": [{ - "$ref": "core#/definitions/room_event" + "$ref": "core/room_event.json" }], "properties": { "content": { diff --git a/event-schemas/schema/v1/m.call.invite b/event-schemas/schema/v1/m.call.invite index 2be01466..a852ff43 100644 --- a/event-schemas/schema/v1/m.call.invite +++ b/event-schemas/schema/v1/m.call.invite @@ -3,7 +3,7 @@ "type": "object", "description": "This event is sent by the caller when they wish to establish a call.", "allOf": [{ - "$ref": "core#/definitions/room_event" + "$ref": "core/room_event.json" }], "properties": { "content": { diff --git a/event-schemas/schema/v1/m.room.aliases b/event-schemas/schema/v1/m.room.aliases index 6585f13d..79fd259b 100644 --- a/event-schemas/schema/v1/m.room.aliases +++ b/event-schemas/schema/v1/m.room.aliases @@ -4,7 +4,7 @@ "title": "Informs the room about what room aliases it has been given.", "description": "This event is sent by a homeserver directly to inform of changes to the list of aliases it knows about for that room. The ``state_key`` for this event is set to the homeserver which owns the room alias. The entire set of known aliases for the room is the union of all the ``m.room.aliases`` events, one for each homeserver. Clients **should** check the validity of any room alias given in this list before presenting it to the user as trusted fact. The lists given by this event should be considered simply as advice on which aliases might exist, for which the client can perform the lookup to confirm whether it receives the correct room ID.", "allOf": [{ - "$ref": "core#/definitions/state_event" + "$ref": "core/state_event.json" }], "properties": { "content": { diff --git a/event-schemas/schema/v1/m.room.canonical_alias b/event-schemas/schema/v1/m.room.canonical_alias index 9f044e58..17caa321 100644 --- a/event-schemas/schema/v1/m.room.canonical_alias +++ b/event-schemas/schema/v1/m.room.canonical_alias @@ -4,7 +4,7 @@ "title": "Informs the room as to which alias is the canonical one.", "description": "This event is used to inform the room about which alias should be considered the canonical one. This could be for display purposes or as suggestion to users which alias to use to advertise the room.", "allOf": [{ - "$ref": "core#/definitions/state_event" + "$ref": "core/state_event.json" }], "properties": { "content": { diff --git a/event-schemas/schema/v1/m.room.create b/event-schemas/schema/v1/m.room.create index 8f74e69b..ecc2ed63 100644 --- a/event-schemas/schema/v1/m.room.create +++ b/event-schemas/schema/v1/m.room.create @@ -4,7 +4,7 @@ "title": "The first event in the room.", "description": "This is the first event in a room and cannot be changed. It acts as the root of all other events.", "allOf": [{ - "$ref": "core#/definitions/state_event" + "$ref": "core/state_event.json" }], "properties": { "content": { diff --git a/event-schemas/schema/v1/m.room.history_visibility b/event-schemas/schema/v1/m.room.history_visibility index 07bd39ff..48b0a5c4 100644 --- a/event-schemas/schema/v1/m.room.history_visibility +++ b/event-schemas/schema/v1/m.room.history_visibility @@ -4,7 +4,7 @@ "title": "Controls visibility of history.", "description": "This event controls whether a member of a room can see the events that happened in a room from before they joined.", "allOf": [{ - "$ref": "core#/definitions/state_event" + "$ref": "core/state_event.json" }], "properties": { "content": { diff --git a/event-schemas/schema/v1/m.room.join_rules b/event-schemas/schema/v1/m.room.join_rules index 2ba20b89..567247eb 100644 --- a/event-schemas/schema/v1/m.room.join_rules +++ b/event-schemas/schema/v1/m.room.join_rules @@ -4,7 +4,7 @@ "title": "Describes how users are allowed to join the room.", "description": "A room may be ``public`` meaning anyone can join the room without any prior action. Alternatively, it can be ``invite`` meaning that a user who wishes to join the room must first receive an invite to the room from someone already inside of the room. Currently, ``knock`` and ``private`` are reserved keywords which are not implemented.", "allOf": [{ - "$ref": "core#/definitions/state_event" + "$ref": "core/state_event.json" }], "properties": { "content": { diff --git a/event-schemas/schema/v1/m.room.member b/event-schemas/schema/v1/m.room.member index ab616176..67e10d51 100644 --- a/event-schemas/schema/v1/m.room.member +++ b/event-schemas/schema/v1/m.room.member @@ -4,7 +4,7 @@ "title": "The current membership state of a user in the room.", "description": "Adjusts the membership state for a user in a room. It is preferable to use the membership APIs (``/rooms//invite`` etc) when performing membership actions rather than adjusting the state directly as there are a restricted set of valid transformations. For example, user A cannot force user B to join a room, and trying to force this state change directly will fail.", "allOf": [{ - "$ref": "core#/definitions/state_event" + "$ref": "core/state_event.json" }], "properties": { "content": { diff --git a/event-schemas/schema/v1/m.room.message b/event-schemas/schema/v1/m.room.message index a849f07f..61b6256f 100644 --- a/event-schemas/schema/v1/m.room.message +++ b/event-schemas/schema/v1/m.room.message @@ -4,7 +4,7 @@ "title": "Message", "description": "This event is used when sending messages in a room. Messages are not limited to be text. The ``msgtype`` key outlines the type of message, e.g. text, audio, image, video, etc. The ``body`` key is text and MUST be used with every kind of ``msgtype`` as a fallback mechanism for when a client cannot render a message.", "allOf": [{ - "$ref": "core#/definitions/room_event" + "$ref": "core/room_event.json" }], "properties": { "content": { diff --git a/event-schemas/schema/v1/m.room.message#m.audio b/event-schemas/schema/v1/m.room.message#m.audio index 9910cb0c..b236e5b0 100644 --- a/event-schemas/schema/v1/m.room.message#m.audio +++ b/event-schemas/schema/v1/m.room.message#m.audio @@ -4,7 +4,7 @@ "title": "AudioMessage", "description": "This message represents a single audio clip.", "allOf": [{ - "$ref": "core#/definitions/room_event" + "$ref": "core/room_event.json" }], "properties": { "content": { diff --git a/event-schemas/schema/v1/m.room.message#m.emote b/event-schemas/schema/v1/m.room.message#m.emote index 886abafc..9f17180c 100644 --- a/event-schemas/schema/v1/m.room.message#m.emote +++ b/event-schemas/schema/v1/m.room.message#m.emote @@ -4,7 +4,7 @@ "title": "EmoteMessage", "description": "This message is similar to ``m.text`` except that the sender is 'performing' the action contained in the ``body`` key, similar to ``/me`` in IRC. This message should be prefixed by the name of the sender. This message could also be represented in a different colour to distinguish it from regular ``m.text`` messages.", "allOf": [{ - "$ref": "core#/definitions/room_event" + "$ref": "core/room_event.json" }], "properties": { "content": { diff --git a/event-schemas/schema/v1/m.room.message#m.file b/event-schemas/schema/v1/m.room.message#m.file index cf6d6552..d8c63b33 100644 --- a/event-schemas/schema/v1/m.room.message#m.file +++ b/event-schemas/schema/v1/m.room.message#m.file @@ -4,7 +4,7 @@ "title": "FileMessage", "description": "This message represents a generic file.", "allOf": [{ - "$ref": "core#/definitions/room_event" + "$ref": "core/room_event.json" }], "properties": { "content": { @@ -50,7 +50,7 @@ "title": "ImageInfo", "description": "Metadata about the image referred to in ``thumbnail_url``.", "allOf": [{ - "$ref": "core#/definitions/msgtype_infos/image_info" + "$ref": "core/msgtype_infos/image_info.json" }] } }, diff --git a/event-schemas/schema/v1/m.room.message#m.image b/event-schemas/schema/v1/m.room.message#m.image index 8c010b0d..ca22654f 100644 --- a/event-schemas/schema/v1/m.room.message#m.image +++ b/event-schemas/schema/v1/m.room.message#m.image @@ -4,7 +4,7 @@ "title": "ImageMessage", "description": "This message represents a single image and an optional thumbnail.", "allOf": [{ - "$ref": "core#/definitions/room_event" + "$ref": "core/room_event.json" }], "properties": { "content": { @@ -31,7 +31,7 @@ "title": "ImageInfo", "description": "Metadata about the image referred to in ``thumbnail_url``.", "allOf": [{ - "$ref": "core#/definitions/msgtype_infos/image_info" + "$ref": "core/msgtype_infos/image_info.json" }] }, "info": { diff --git a/event-schemas/schema/v1/m.room.message#m.location b/event-schemas/schema/v1/m.room.message#m.location index cd15f31e..919c3325 100644 --- a/event-schemas/schema/v1/m.room.message#m.location +++ b/event-schemas/schema/v1/m.room.message#m.location @@ -4,7 +4,7 @@ "title": "LocationMessage", "description": "This message represents a real-world location.", "allOf": [{ - "$ref": "core#/definitions/room_event" + "$ref": "core/room_event.json" }], "properties": { "content": { @@ -30,7 +30,7 @@ "type": "object", "title": "ImageInfo", "allOf": [{ - "$ref": "core#/definitions/msgtype_infos/image_info" + "$ref": "core/msgtype_infos/image_info.json" }] } }, diff --git a/event-schemas/schema/v1/m.room.message#m.notice b/event-schemas/schema/v1/m.room.message#m.notice index 0f8044f5..e6ce6f89 100644 --- a/event-schemas/schema/v1/m.room.message#m.notice +++ b/event-schemas/schema/v1/m.room.message#m.notice @@ -4,7 +4,7 @@ "title": "NoticeMessage", "description": "A m.notice message should be considered similar to a plain m.text message except that clients should visually distinguish it in some way. It is intended to be used by automated clients, such as bots, bridges, and other entities, rather than humans. Additionally, such automated agents which watch a room for messages and respond to them ought to ignore m.notice messages. This helps to prevent infinite-loop situations where two automated clients continuously exchange messages, as each responds to the other.", "allOf": [{ - "$ref": "core#/definitions/room_event" + "$ref": "core/room_event.json" }], "properties": { "content": { diff --git a/event-schemas/schema/v1/m.room.message#m.text b/event-schemas/schema/v1/m.room.message#m.text index 054d4a96..ceadbcd0 100644 --- a/event-schemas/schema/v1/m.room.message#m.text +++ b/event-schemas/schema/v1/m.room.message#m.text @@ -4,7 +4,7 @@ "title": "TextMessage", "description": "This message is the most basic message and is used to represent text.", "allOf": [{ - "$ref": "core#/definitions/room_event" + "$ref": "core/room_event.json" }], "properties": { "content": { diff --git a/event-schemas/schema/v1/m.room.message#m.video b/event-schemas/schema/v1/m.room.message#m.video index 22266506..667832ff 100644 --- a/event-schemas/schema/v1/m.room.message#m.video +++ b/event-schemas/schema/v1/m.room.message#m.video @@ -4,7 +4,7 @@ "title": "VideoMessage", "description": "This message represents a single video clip.", "allOf": [{ - "$ref": "core#/definitions/room_event" + "$ref": "core/room_event.json" }], "properties": { "content": { @@ -55,7 +55,7 @@ "type": "object", "title": "ImageInfo", "allOf": [{ - "$ref": "core#/definitions/msgtype_infos/image_info" + "$ref": "core/msgtype_infos/image_info.json" }] } } diff --git a/event-schemas/schema/v1/m.room.message.feedback b/event-schemas/schema/v1/m.room.message.feedback index 4cfd44d1..b662e9e6 100644 --- a/event-schemas/schema/v1/m.room.message.feedback +++ b/event-schemas/schema/v1/m.room.message.feedback @@ -4,7 +4,7 @@ "title": "MessageFeedback", "description": "Feedback events are events sent to acknowledge a message in some way. There are two supported acknowledgements: ``delivered`` (sent when the event has been received) and ``read`` (sent when the event has been observed by the end-user). The ``target_event_id`` should reference the ``m.room.message`` event being acknowledged. N.B. not implemented in Synapse, and superceded in v2 CS API by the ``relates_to`` event field.", "allOf": [{ - "$ref": "core#/definitions/room_event" + "$ref": "core/room_event.json" }], "properties": { "content": { diff --git a/event-schemas/schema/v1/m.room.name b/event-schemas/schema/v1/m.room.name index 5077774c..5565147c 100644 --- a/event-schemas/schema/v1/m.room.name +++ b/event-schemas/schema/v1/m.room.name @@ -4,7 +4,7 @@ "description": "A room has an opaque room ID which is not human-friendly to read. A room alias is human-friendly, but not all rooms have room aliases. The room name is a human-friendly string designed to be displayed to the end-user. The room name is not unique, as multiple rooms can have the same room name set. The room name can also be set when creating a room using ``/createRoom`` with the ``name`` key.", "type": "object", "allOf": [{ - "$ref": "core#/definitions/state_event" + "$ref": "core/state_event.json" }], "properties": { "content": { diff --git a/event-schemas/schema/v1/m.room.power_levels b/event-schemas/schema/v1/m.room.power_levels index 9e0cb81a..95850fcb 100644 --- a/event-schemas/schema/v1/m.room.power_levels +++ b/event-schemas/schema/v1/m.room.power_levels @@ -4,7 +4,7 @@ "title": "Defines the power levels (privileges) of users in the room.", "description": "This event specifies the minimum level a user must have in order to perform a certain action. It also specifies the levels of each user in the room. If a ``user_id`` is in the ``users`` list, then that ``user_id`` has the associated power level. Otherwise they have the default level ``users_default``. If ``users_default`` is not supplied, it is assumed to be 0. The level required to send a certain event is governed by ``events``, ``state_default`` and ``events_default``. If an event type is specified in ``events``, then the user must have at least the level specified in order to send that event. If the event type is not supplied, it defaults to ``events_default`` for Message Events and ``state_default`` for State Events.", "allOf": [{ - "$ref": "core#/definitions/state_event" + "$ref": "core/state_event.json" }], "properties": { "content": { diff --git a/event-schemas/schema/v1/m.room.redaction b/event-schemas/schema/v1/m.room.redaction index 2896c0da..b095b17d 100644 --- a/event-schemas/schema/v1/m.room.redaction +++ b/event-schemas/schema/v1/m.room.redaction @@ -4,7 +4,7 @@ "title": "Redaction", "description": "Events can be redacted by either room or server admins. Redacting an event means that all keys not required by the protocol are stripped off, allowing admins to remove offensive or illegal content that may have been attached to any event. This cannot be undone, allowing server owners to physically delete the offending data. There is also a concept of a moderator hiding a message event, which can be undone, but cannot be applied to state events. The event that has been redacted is specified in the ``redacts`` event level key.", "allOf": [{ - "$ref": "core#/definitions/room_event" + "$ref": "core/room_event.json" }], "properties": { "content": { diff --git a/event-schemas/schema/v1/m.room.topic b/event-schemas/schema/v1/m.room.topic index 266df8fa..32319c38 100644 --- a/event-schemas/schema/v1/m.room.topic +++ b/event-schemas/schema/v1/m.room.topic @@ -4,7 +4,7 @@ "title": "Topic", "description": "A topic is a short message detailing what is currently being discussed in the room. It can also be used as a way to display extra information about the room, which may not be suitable for the room name. The room topic can also be set when creating a room using ``/createRoom`` with the ``topic`` key.", "allOf": [{ - "$ref": "core#/definitions/state_event" + "$ref": "core/state_event.json" }], "properties": { "content": { From 2cf8da6b20dabe3d97ac9c97a6d356b4aa2c4d5d Mon Sep 17 00:00:00 2001 From: Mark Haines Date: Thu, 17 Sep 2015 10:28:57 +0100 Subject: [PATCH 2/6] Update the gendoc script to load the core event schema from separate files. --- templating/matrix_templates/units.py | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/templating/matrix_templates/units.py b/templating/matrix_templates/units.py index 0c072df3..6bb9b7d7 100644 --- a/templating/matrix_templates/units.py +++ b/templating/matrix_templates/units.py @@ -283,17 +283,25 @@ class MatrixUnits(Units): def load_common_event_fields(self): path = "../event-schemas/schema/v1/core" event_types = {} - with open(path, "r") as f: - core_json = json.loads(f.read()) - for event_type in core_json["definitions"]: + + for (root, dirs, files) in os.walk(path): + for filename in files: + if not filename.endswith(".json"): + continue + + event_type = filename[:-5] # strip the ".json" + with open(os.path.join(root, filename)) as f: + event_info = json.loads(f.read()) + if "event" not in event_type: continue # filter ImageInfo and co - event_info = core_json["definitions"][event_type] + table = { "title": event_info["title"], "desc": event_info["description"], "rows": [] } + for prop in sorted(event_info["properties"]): row = { "key": prop, @@ -301,6 +309,7 @@ class MatrixUnits(Units): "desc": event_info["properties"][prop].get("description","") } table["rows"].append(row) + event_types[event_type] = table return event_types From c49338006aa1fe8da43185ea77afa7510673c99d Mon Sep 17 00:00:00 2001 From: Mark Haines Date: Thu, 17 Sep 2015 13:09:35 +0100 Subject: [PATCH 3/6] replace definitions/*event.yaml with symlinks to /event-schemas/ --- api/client-server/v1/core | 1 + api/client-server/v1/definitions/event.yaml | 7 ---- .../v1/definitions/room_event.yaml | 9 ----- .../v1/definitions/state_event.yaml | 11 ------ api/client-server/v1/events | 1 + api/client-server/v1/presence.yaml | 2 +- api/client-server/v1/sync.yaml | 10 ++--- .../schema/v1/core/.room_event.json.swp | Bin 0 -> 12288 bytes event-schemas/schema/v1/core/event.json | 9 ----- event-schemas/schema/v1/core/room_event.json | 11 +++++- event-schemas/schema/v1/core/state_event.json | 35 +++++++++--------- 11 files changed, 34 insertions(+), 62 deletions(-) create mode 120000 api/client-server/v1/core delete mode 100644 api/client-server/v1/definitions/event.yaml delete mode 100644 api/client-server/v1/definitions/room_event.yaml delete mode 100644 api/client-server/v1/definitions/state_event.yaml create mode 120000 api/client-server/v1/events create mode 100644 event-schemas/schema/v1/core/.room_event.json.swp diff --git a/api/client-server/v1/core b/api/client-server/v1/core new file mode 120000 index 00000000..9fc0cd87 --- /dev/null +++ b/api/client-server/v1/core @@ -0,0 +1 @@ +events/core \ No newline at end of file diff --git a/api/client-server/v1/definitions/event.yaml b/api/client-server/v1/definitions/event.yaml deleted file mode 100644 index cfb1b924..00000000 --- a/api/client-server/v1/definitions/event.yaml +++ /dev/null @@ -1,7 +0,0 @@ -type: object -description: A Matrix Event -properties: - event_id: - type: string - description: An event ID. -required: ["event_id"] \ No newline at end of file diff --git a/api/client-server/v1/definitions/room_event.yaml b/api/client-server/v1/definitions/room_event.yaml deleted file mode 100644 index 5a9e3a09..00000000 --- a/api/client-server/v1/definitions/room_event.yaml +++ /dev/null @@ -1,9 +0,0 @@ -type: object -description: A Matrix Room Event -properties: - event_id: - type: string - description: An event ID. - room_id: - type: string -required: ["event_id", "room_id"] \ No newline at end of file diff --git a/api/client-server/v1/definitions/state_event.yaml b/api/client-server/v1/definitions/state_event.yaml deleted file mode 100644 index f8e6f4d4..00000000 --- a/api/client-server/v1/definitions/state_event.yaml +++ /dev/null @@ -1,11 +0,0 @@ -type: object -description: A Matrix State Event -properties: - event_id: - type: string - description: An event ID. - room_id: - type: string - state_key: - type: string -required: ["event_id", "room_id", "state_key"] \ No newline at end of file diff --git a/api/client-server/v1/events b/api/client-server/v1/events new file mode 120000 index 00000000..7a0d0326 --- /dev/null +++ b/api/client-server/v1/events @@ -0,0 +1 @@ +../../../event-schemas/schema/v1 \ No newline at end of file diff --git a/api/client-server/v1/presence.yaml b/api/client-server/v1/presence.yaml index 6f8311e4..472a2d7f 100644 --- a/api/client-server/v1/presence.yaml +++ b/api/client-server/v1/presence.yaml @@ -205,4 +205,4 @@ paths: type: object title: PresenceEvent allOf: - - "$ref": "definitions/event.yaml" + - "$ref": "events/core/event.json" diff --git a/api/client-server/v1/sync.yaml b/api/client-server/v1/sync.yaml index 777e27db..b9525491 100644 --- a/api/client-server/v1/sync.yaml +++ b/api/client-server/v1/sync.yaml @@ -82,7 +82,7 @@ paths: type: object title: RoomEvent allOf: - - "$ref": "definitions/room_event.yaml" + - "$ref": "events/core/room_event.json" 400: description: "Bad pagination ``from`` parameter." "/initialSync": @@ -253,7 +253,7 @@ paths: type: object title: Event allOf: - - "$ref": "definitions/event.yaml" + - "$ref": "events/core/event.json" rooms: type: array items: @@ -294,7 +294,7 @@ paths: type: object title: RoomEvent allOf: - - "$ref": "definitions/room_event.yaml" + - "$ref": "events/core/room_event.json" required: ["start", "end", "chunk"] state: type: array @@ -307,7 +307,7 @@ paths: title: StateEvent type: object allOf: - - "$ref": "definitions/state_event.yaml" + - "$ref": "events/core/state_event.json" visibility: type: string enum: ["private", "public"] @@ -350,6 +350,6 @@ paths: } schema: allOf: - - "$ref": "definitions/event.yaml" + - "$ref": "events/core/event.json" 404: description: The event was not found or you do not have permission to read this event. diff --git a/event-schemas/schema/v1/core/.room_event.json.swp b/event-schemas/schema/v1/core/.room_event.json.swp new file mode 100644 index 0000000000000000000000000000000000000000..fce0fd5f873a95140af3b68ffd4843fa3cb522c4 GIT binary patch literal 12288 zcmeI2&2G~`5XZN0E}$a8g~PA~AyrM>@S#fOz=01bhpG}ZNT{l+jlGUHI9_LWolsQ~ z2i^b>7oH&!2e|PPyatcZ17g;85~+t!j-XlTpS3;XotfX9tW0<7WqTL4oA(*6D~#>E zKkeL}-nlq!F*Xq9bwBZj@w0}AV)HD4I3tM zAZ$?W!Kf94+Q`6YJvb^ontiLYbA==)B0vP@1XkI-yR9vMyUuUI)wRytLKj4U2oM1x zKm>>Y5g-CYfC&8m1YEwt-eQ>->Qb-Q`^uTUzNL)_5CI}U1c(3;AOb{y2oM1xKm>>Y z5%>oQh={QptBid_`TzfC-~YcZGxihp0~MoQp&p_hpw>}qsMAY~eML=CpHc5n&rpw0 zP1H5icRcqS>I>=<%E$SDqD2IV01+SpM1Tko0U|&IhyW2F0*p-<05@`2C?g}j0|&eu zeO3`aM9X9of94x{M$(2xY}YF-AwlihJH{gD=DwX+_t0(1Z75hk+(C(AS0#{_z*?h4ESicAd) zSw#R9VN9QqY5pNtnbEnUEz0x6Kv=6oB^(w$#AotCb?>3^z+*bwrFI4)ij;2}I9+z+sULm^gpx*f6Q275%10JVE2OUxp5!ov`26(Di%( literal 0 HcmV?d00001 diff --git a/event-schemas/schema/v1/core/event.json b/event-schemas/schema/v1/core/event.json index b4824079..e73aec80 100644 --- a/event-schemas/schema/v1/core/event.json +++ b/event-schemas/schema/v1/core/event.json @@ -1,17 +1,8 @@ { - "$schema": "http://json-schema.org/draft-04/schema#", "type": "object", "title": "Event", "description": "The basic set of fields all events must have.", "properties": { - "event_id": { - "type": "string", - "description": "The globally unique event identifier." - }, - "user_id": { - "type": "string", - "description": "Contains the fully-qualified ID of the user who *sent* this event." - }, "content": { "type": "object", "description": "The fields in this object will vary depending on the type of event. When interacting with the REST API, this is the HTTP body." diff --git a/event-schemas/schema/v1/core/room_event.json b/event-schemas/schema/v1/core/room_event.json index 717cdaae..a64ba2ea 100644 --- a/event-schemas/schema/v1/core/room_event.json +++ b/event-schemas/schema/v1/core/room_event.json @@ -1,5 +1,4 @@ { - "$schema": "http://json-schema.org/draft-04/schema#", "type": "object", "title": "Room Event", "description": "In addition to the Event fields, Room Events MUST have the following additional field.", @@ -10,7 +9,15 @@ "room_id": { "type": "string", "description": "The ID of the room associated with this event." - } + }, + "event_id": { + "type": "string", + "description": "The globally unique event identifier." + }, + "user_id": { + "type": "string", + "description": "Contains the fully-qualified ID of the user who *sent* this event." + }, }, "required": ["room_id"] } diff --git a/event-schemas/schema/v1/core/state_event.json b/event-schemas/schema/v1/core/state_event.json index a237f4d1..60de9413 100644 --- a/event-schemas/schema/v1/core/state_event.json +++ b/event-schemas/schema/v1/core/state_event.json @@ -1,20 +1,19 @@ { - "$schema": "http://json-schema.org/draft-04/schema#", - "type": "object", - "title": "State Event", - "description": "In addition to the Room Event fields, State Events have the following additional fields.", - "allOf":[{ - "$ref": "core/room_event.json" - }], - "properties": { - "state_key": { - "type": "string", - "description": "A unique key which defines the overwriting semantics for this piece of room state. This value is often a zero-length string. The presence of this key makes this event a State Event." - }, - "prev_content": { - "type": "object", - "description": "Optional. The previous ``content`` for this event. If there is no previous content, this key will be missing." - } - }, - "required": ["state_key"] + "type": "object", + "title": "State Event", + "description": "In addition to the Room Event fields, State Events have the following additional fields.", + "allOf":[{ + "$ref": "core/room_event.json" + }], + "properties": { + "state_key": { + "type": "string", + "description": "A unique key which defines the overwriting semantics for this piece of room state. This value is often a zero-length string. The presence of this key makes this event a State Event." + }, + "prev_content": { + "type": "object", + "description": "Optional. The previous ``content`` for this event. If there is no previous content, this key will be missing." + } + }, + "required": ["state_key"] } From 380f186273b4b7e045c76b0078b091063347aef6 Mon Sep 17 00:00:00 2001 From: Mark Haines Date: Thu, 17 Sep 2015 14:42:43 +0100 Subject: [PATCH 4/6] Log which file a json parse error occurred in --- templating/matrix_templates/units.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/templating/matrix_templates/units.py b/templating/matrix_templates/units.py index 6bb9b7d7..4b8127ae 100644 --- a/templating/matrix_templates/units.py +++ b/templating/matrix_templates/units.py @@ -290,8 +290,14 @@ class MatrixUnits(Units): continue event_type = filename[:-5] # strip the ".json" - with open(os.path.join(root, filename)) as f: - event_info = json.loads(f.read()) + filepath = os.path.join(root, filename) + with open(filepath) as f: + try: + event_info = json.load(f) + except Exception as e: + raise ValueError( + "Error reading file %r" % (filepath,), e + ) if "event" not in event_type: continue # filter ImageInfo and co From d0b018c46ecee5ee01d11a3c244d5e4fd3e30bef Mon Sep 17 00:00:00 2001 From: Mark Haines Date: Thu, 17 Sep 2015 14:43:09 +0100 Subject: [PATCH 5/6] Fix syntax error in JSON --- .../schema/v1/core/.room_event.json.swp | Bin 12288 -> 12288 bytes event-schemas/schema/v1/core/room_event.json | 2 +- 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/event-schemas/schema/v1/core/.room_event.json.swp b/event-schemas/schema/v1/core/.room_event.json.swp index fce0fd5f873a95140af3b68ffd4843fa3cb522c4..8140e9ceb080ae0bf455a04a57e8d6966854a472 100644 GIT binary patch delta 73 zcmZojXh@JsG6?hZRWR2xVE_UF28JgGe}$^8RcAgcyHV!=h& delta 77 zcmZojXh@JsG6?hZRWR2xVE_UF1_u90zd}{lsxz-O+$i-*o>hjIfnmyIPK9XRtw7cW bAf5&i*<7fg!aI4IuIgkLJ&DbiboH135Umu8 diff --git a/event-schemas/schema/v1/core/room_event.json b/event-schemas/schema/v1/core/room_event.json index a64ba2ea..7ac66b30 100644 --- a/event-schemas/schema/v1/core/room_event.json +++ b/event-schemas/schema/v1/core/room_event.json @@ -17,7 +17,7 @@ "user_id": { "type": "string", "description": "Contains the fully-qualified ID of the user who *sent* this event." - }, + } }, "required": ["room_id"] } From fd3401fc7a78b3ccbfd9825f01272225d7858407 Mon Sep 17 00:00:00 2001 From: Mark Haines Date: Thu, 17 Sep 2015 14:44:17 +0100 Subject: [PATCH 6/6] Remove accidentally committed swp file --- .../schema/v1/core/.room_event.json.swp | Bin 12288 -> 0 bytes 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 event-schemas/schema/v1/core/.room_event.json.swp diff --git a/event-schemas/schema/v1/core/.room_event.json.swp b/event-schemas/schema/v1/core/.room_event.json.swp deleted file mode 100644 index 8140e9ceb080ae0bf455a04a57e8d6966854a472..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 12288 zcmeI2&1w`u5XU=uj!FbQ1YmwMh!EpZsfPdb%v4QR)vr#=R%iWLYYXl)Z!ugK z82kR^sD175`q{6`jP-?i(aXHyHxd z5g-CYfCvx)B0vO)01^2A3An)mdxd45sY|_F?+eHF`jIvwKm>>Y5g-CYfCvx)B0vO) z01+SpMBpDJAQHxw7a4nt^8f!&fB*kH&)5&tH&lvxj=GDwjaor1p^nZm_7Qc6dXIXI zdW5=%YN9ToKI6HcP#;k5P(IEZ6fGh^1c(3;AOb{y2oM1xKm>>Y5nyaGVF297VX2Hv z_$KV|F#D_$zKfR08eVV`s_jTcfDlE86LR#keeq&gQT%}4T(0Twm z4VKbM1LI7?s>PY>ReYx`RMXXbda~OeNPncoS?!|BtGL{Mxre!I!a;DX^Z7lKZA_q> z>yE%2pe)p|lvM;!3C8ppndTpYg^W%eZC;)S2Etk$E8(#4F^--8MU7M5RgHXL^gtS? zq^+x-?A9=@8ku@TVM2XAobIdQSodQz?s!bcyVNQ`B#H7(1E)hr9{S;TKqz@)*WigS yAiT1$)qc7SnHb67m+Cy%V{FLm1d&&tHA9QIQ!WpEo1ak|>VE1@PsR@49k5>;A@-yI