Allow relative references to schema to work in python and node.

Rename "schema/v1/core" to "schema/v1/core-event-schema".
Add self-referential symlinks to schema/v1/core-event-schema

The python json schema libraries expect that relative references are
relative to the file they are in. The node json schema libraries
expect that relateive references are relative to the first file loaded.

To support both kinds we reference the core event schema using
"core-event-schema/event.json". We then symlink the core-event-schema
directory to both the location of the file refering to "event.json" so
that it will work in python and to the location of the top level file
so that it will work in node.
pull/977/head
Mark Haines 9 years ago
parent bb441427ac
commit 7f81501762

@ -0,0 +1 @@
v1-event-schema/core-event-schema

@ -205,4 +205,4 @@ paths:
type: object type: object
title: PresenceEvent title: PresenceEvent
allOf: allOf:
- "$ref": "events/core/event.json" - "$ref": "core-event-schema/event.json"

@ -82,7 +82,7 @@ paths:
type: object type: object
title: RoomEvent title: RoomEvent
allOf: allOf:
- "$ref": "events/core/room_event.json" - "$ref": "core-event-schema/room_event.json"
400: 400:
description: "Bad pagination ``from`` parameter." description: "Bad pagination ``from`` parameter."
"/initialSync": "/initialSync":
@ -253,7 +253,7 @@ paths:
type: object type: object
title: Event title: Event
allOf: allOf:
- "$ref": "events/core/event.json" - "$ref": "core-event-schema/event.json"
rooms: rooms:
type: array type: array
items: items:
@ -294,7 +294,7 @@ paths:
type: object type: object
title: RoomEvent title: RoomEvent
allOf: allOf:
- "$ref": "events/core/room_event.json" - "$ref": "core-event-schema/room_event.json"
required: ["start", "end", "chunk"] required: ["start", "end", "chunk"]
state: state:
type: array type: array
@ -307,7 +307,7 @@ paths:
title: StateEvent title: StateEvent
type: object type: object
allOf: allOf:
- "$ref": "events/core/state_event.json" - "$ref": "core-event-schema/state_event.json"
visibility: visibility:
type: string type: string
enum: ["private", "public"] enum: ["private", "public"]
@ -350,6 +350,6 @@ paths:
} }
schema: schema:
allOf: allOf:
- "$ref": "events/core/event.json" - "$ref": "core-event-schema/event.json"
404: 404:
description: The event was not found or you do not have permission to read this event. description: The event was not found or you do not have permission to read this event.

@ -3,7 +3,7 @@
"title": "Room Event", "title": "Room Event",
"description": "In addition to the Event fields, Room Events MUST have the following additional field.", "description": "In addition to the Event fields, Room Events MUST have the following additional field.",
"allOf":[{ "allOf":[{
"$ref": "core/event.json" "$ref": "core-event-schema/event.json"
}], }],
"properties": { "properties": {
"room_id": { "room_id": {

@ -3,7 +3,7 @@
"title": "State Event", "title": "State Event",
"description": "In addition to the Room Event fields, State Events have the following additional fields.", "description": "In addition to the Room Event fields, State Events have the following additional fields.",
"allOf":[{ "allOf":[{
"$ref": "core/room_event.json" "$ref": "core-event-schema/room_event.json"
}], }],
"properties": { "properties": {
"state_key": { "state_key": {

@ -3,7 +3,7 @@
"type": "object", "type": "object",
"description": "This event is sent by the callee when they wish to answer the call.", "description": "This event is sent by the callee when they wish to answer the call.",
"allOf": [{ "allOf": [{
"$ref": "core/room_event.json" "$ref": "core-event-schema/room_event.json"
}], }],
"properties": { "properties": {
"content": { "content": {

@ -3,7 +3,7 @@
"type": "object", "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.", "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": [{ "allOf": [{
"$ref": "core/room_event.json" "$ref": "core-event-schema/room_event.json"
}], }],
"properties": { "properties": {
"content": { "content": {

@ -3,7 +3,7 @@
"type": "object", "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.", "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": [{ "allOf": [{
"$ref": "core/room_event.json" "$ref": "core-event-schema/room_event.json"
}], }],
"properties": { "properties": {
"content": { "content": {

@ -3,7 +3,7 @@
"type": "object", "type": "object",
"description": "This event is sent by the caller when they wish to establish a call.", "description": "This event is sent by the caller when they wish to establish a call.",
"allOf": [{ "allOf": [{
"$ref": "core/room_event.json" "$ref": "core-event-schema/room_event.json"
}], }],
"properties": { "properties": {
"content": { "content": {

@ -4,7 +4,7 @@
"title": "Informs the room about what room aliases it has been given.", "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.", "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": [{ "allOf": [{
"$ref": "core/state_event.json" "$ref": "core-event-schema/state_event.json"
}], }],
"properties": { "properties": {
"content": { "content": {

@ -4,7 +4,7 @@
"title": "Informs the room as to which alias is the canonical one.", "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.", "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": [{ "allOf": [{
"$ref": "core/state_event.json" "$ref": "core-event-schema/state_event.json"
}], }],
"properties": { "properties": {
"content": { "content": {

@ -4,7 +4,7 @@
"title": "The first event in the room.", "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.", "description": "This is the first event in a room and cannot be changed. It acts as the root of all other events.",
"allOf": [{ "allOf": [{
"$ref": "core/state_event.json" "$ref": "core-event-schema/state_event.json"
}], }],
"properties": { "properties": {
"content": { "content": {

@ -4,7 +4,7 @@
"title": "Controls visibility of history.", "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.", "description": "This event controls whether a member of a room can see the events that happened in a room from before they joined.",
"allOf": [{ "allOf": [{
"$ref": "core/state_event.json" "$ref": "core-event-schema/state_event.json"
}], }],
"properties": { "properties": {
"content": { "content": {

@ -4,7 +4,7 @@
"title": "Describes how users are allowed to join the room.", "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.", "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": [{ "allOf": [{
"$ref": "core/state_event.json" "$ref": "core-event-schema/state_event.json"
}], }],
"properties": { "properties": {
"content": { "content": {

@ -4,7 +4,7 @@
"title": "The current membership state of a user in the room.", "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/<room id>/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.", "description": "Adjusts the membership state for a user in a room. It is preferable to use the membership APIs (``/rooms/<room id>/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": [{ "allOf": [{
"$ref": "core/state_event.json" "$ref": "core-event-schema/state_event.json"
}], }],
"properties": { "properties": {
"content": { "content": {

@ -4,7 +4,7 @@
"title": "Message", "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.", "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": [{ "allOf": [{
"$ref": "core/room_event.json" "$ref": "core-event-schema/room_event.json"
}], }],
"properties": { "properties": {
"content": { "content": {

@ -4,7 +4,7 @@
"title": "AudioMessage", "title": "AudioMessage",
"description": "This message represents a single audio clip.", "description": "This message represents a single audio clip.",
"allOf": [{ "allOf": [{
"$ref": "core/room_event.json" "$ref": "core-event-schema/room_event.json"
}], }],
"properties": { "properties": {
"content": { "content": {

@ -4,7 +4,7 @@
"title": "EmoteMessage", "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.", "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": [{ "allOf": [{
"$ref": "core/room_event.json" "$ref": "core-event-schema/room_event.json"
}], }],
"properties": { "properties": {
"content": { "content": {

@ -4,7 +4,7 @@
"title": "FileMessage", "title": "FileMessage",
"description": "This message represents a generic file.", "description": "This message represents a generic file.",
"allOf": [{ "allOf": [{
"$ref": "core/room_event.json" "$ref": "core-event-schema/room_event.json"
}], }],
"properties": { "properties": {
"content": { "content": {
@ -50,7 +50,7 @@
"title": "ImageInfo", "title": "ImageInfo",
"description": "Metadata about the image referred to in ``thumbnail_url``.", "description": "Metadata about the image referred to in ``thumbnail_url``.",
"allOf": [{ "allOf": [{
"$ref": "core/msgtype_infos/image_info.json" "$ref": "core-event-schema/msgtype_infos/image_info.json"
}] }]
} }
}, },

@ -4,7 +4,7 @@
"title": "ImageMessage", "title": "ImageMessage",
"description": "This message represents a single image and an optional thumbnail.", "description": "This message represents a single image and an optional thumbnail.",
"allOf": [{ "allOf": [{
"$ref": "core/room_event.json" "$ref": "core-event-schema/room_event.json"
}], }],
"properties": { "properties": {
"content": { "content": {
@ -31,7 +31,7 @@
"title": "ImageInfo", "title": "ImageInfo",
"description": "Metadata about the image referred to in ``thumbnail_url``.", "description": "Metadata about the image referred to in ``thumbnail_url``.",
"allOf": [{ "allOf": [{
"$ref": "core/msgtype_infos/image_info.json" "$ref": "core-event-schema/msgtype_infos/image_info.json"
}] }]
}, },
"info": { "info": {

@ -4,7 +4,7 @@
"title": "LocationMessage", "title": "LocationMessage",
"description": "This message represents a real-world location.", "description": "This message represents a real-world location.",
"allOf": [{ "allOf": [{
"$ref": "core/room_event.json" "$ref": "core-event-schema/room_event.json"
}], }],
"properties": { "properties": {
"content": { "content": {
@ -30,7 +30,7 @@
"type": "object", "type": "object",
"title": "ImageInfo", "title": "ImageInfo",
"allOf": [{ "allOf": [{
"$ref": "core/msgtype_infos/image_info.json" "$ref": "core-event-schema/msgtype_infos/image_info.json"
}] }]
} }
}, },

@ -4,7 +4,7 @@
"title": "NoticeMessage", "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.", "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": [{ "allOf": [{
"$ref": "core/room_event.json" "$ref": "core-event-schema/room_event.json"
}], }],
"properties": { "properties": {
"content": { "content": {

@ -4,7 +4,7 @@
"title": "TextMessage", "title": "TextMessage",
"description": "This message is the most basic message and is used to represent text.", "description": "This message is the most basic message and is used to represent text.",
"allOf": [{ "allOf": [{
"$ref": "core/room_event.json" "$ref": "core-event-schema/room_event.json"
}], }],
"properties": { "properties": {
"content": { "content": {

@ -4,7 +4,7 @@
"title": "VideoMessage", "title": "VideoMessage",
"description": "This message represents a single video clip.", "description": "This message represents a single video clip.",
"allOf": [{ "allOf": [{
"$ref": "core/room_event.json" "$ref": "core-event-schema/room_event.json"
}], }],
"properties": { "properties": {
"content": { "content": {
@ -55,7 +55,7 @@
"type": "object", "type": "object",
"title": "ImageInfo", "title": "ImageInfo",
"allOf": [{ "allOf": [{
"$ref": "core/msgtype_infos/image_info.json" "$ref": "core-event-schema/msgtype_infos/image_info.json"
}] }]
} }
} }

@ -4,7 +4,7 @@
"title": "MessageFeedback", "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.", "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": [{ "allOf": [{
"$ref": "core/room_event.json" "$ref": "core-event-schema/room_event.json"
}], }],
"properties": { "properties": {
"content": { "content": {

@ -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.", "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", "type": "object",
"allOf": [{ "allOf": [{
"$ref": "core/state_event.json" "$ref": "core-event-schema/state_event.json"
}], }],
"properties": { "properties": {
"content": { "content": {

@ -4,7 +4,7 @@
"title": "Defines the power levels (privileges) of users in the room.", "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.", "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": [{ "allOf": [{
"$ref": "core/state_event.json" "$ref": "core-event-schema/state_event.json"
}], }],
"properties": { "properties": {
"content": { "content": {

@ -4,7 +4,7 @@
"title": "Redaction", "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.", "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": [{ "allOf": [{
"$ref": "core/room_event.json" "$ref": "core-event-schema/room_event.json"
}], }],
"properties": { "properties": {
"content": { "content": {

@ -4,7 +4,7 @@
"title": "Topic", "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.", "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": [{ "allOf": [{
"$ref": "core/state_event.json" "$ref": "core-event-schema/state_event.json"
}], }],
"properties": { "properties": {
"content": { "content": {

@ -281,7 +281,7 @@ class MatrixUnits(Units):
return apis return apis
def load_common_event_fields(self): def load_common_event_fields(self):
path = "../event-schemas/schema/v1/core" path = "../event-schemas/schema/v1/core-event-schema"
event_types = {} event_types = {}
for (root, dirs, files) in os.walk(path): for (root, dirs, files) in os.walk(path):

Loading…
Cancel
Save