From d6d74c4cbef04e194826cf3565b21bf5959a7d31 Mon Sep 17 00:00:00 2001 From: Travis Ralston Date: Wed, 29 May 2019 15:23:45 -0600 Subject: [PATCH] Switch to using $ instead of # for sub-types # is reserved by the swagger validator as a way to include partial content from a JSON object (eg: "#/path" would include {"test": true} from the object {"path":{"test":true}}). Instead of trying to convince the validator that it is wrong, we'll just use a different character. Note that our rendering tools do not care about #-style references to objects. It's still somewhat worth changing the character though. --- api/application-service/transactions.yaml | 2 +- api/client-server/event_context.yaml | 6 +++--- api/client-server/message_pagination.yaml | 4 ++-- api/client-server/notifications.yaml | 2 +- api/client-server/old_sync.yaml | 8 ++++---- api/client-server/peeking_events.yaml | 2 +- api/client-server/room_initial_sync.yaml | 4 ++-- api/client-server/rooms.yaml | 2 +- api/client-server/search.yaml | 2 +- api/client-server/sync.yaml | 2 +- event-schemas/check_examples.py | 4 ++-- ....encrypted#megolm => m.room.encrypted$megolm} | 0 ...m.room.encrypted#olm => m.room.encrypted$olm} | 0 ...oom_state => m.room.member$invite_room_state} | 0 ...y_invite => m.room.member$third_party_invite} | 0 ...om.message#m.audio => m.room.message$m.audio} | 2 +- ...om.message#m.emote => m.room.message$m.emote} | 0 ...room.message#m.file => m.room.message$m.file} | 0 ...om.message#m.image => m.room.message$m.image} | 0 ...sage#m.location => m.room.message$m.location} | 0 ....message#m.notice => m.room.message$m.notice} | 0 ...ver_notice => m.room.message$m.server_notice} | 0 ...room.message#m.text => m.room.message$m.text} | 0 ...om.message#m.video => m.room.message$m.video} | 0 ...request => m.room_key_request$cancel_request} | 0 ...equest#request => m.room_key_request$request} | 0 ...om.message#m.audio => m.room.message$m.audio} | 0 ...om.message#m.emote => m.room.message$m.emote} | 0 ...room.message#m.file => m.room.message$m.file} | 0 ...om.message#m.image => m.room.message$m.image} | 0 ...sage#m.location => m.room.message$m.location} | 0 ....message#m.notice => m.room.message$m.notice} | 0 ...ver_notice => m.room.message$m.server_notice} | 0 ...room.message#m.text => m.room.message$m.text} | 0 ...om.message#m.video => m.room.message$m.video} | 0 scripts/templating/matrix_templates/sections.py | 16 ++++++++-------- scripts/templating/matrix_templates/units.py | 2 +- 37 files changed, 29 insertions(+), 29 deletions(-) rename event-schemas/examples/{m.room.encrypted#megolm => m.room.encrypted$megolm} (100%) rename event-schemas/examples/{m.room.encrypted#olm => m.room.encrypted$olm} (100%) rename event-schemas/examples/{m.room.member#invite_room_state => m.room.member$invite_room_state} (100%) rename event-schemas/examples/{m.room.member#third_party_invite => m.room.member$third_party_invite} (100%) rename event-schemas/examples/{m.room.message#m.audio => m.room.message$m.audio} (99%) rename event-schemas/examples/{m.room.message#m.emote => m.room.message$m.emote} (100%) rename event-schemas/examples/{m.room.message#m.file => m.room.message$m.file} (100%) rename event-schemas/examples/{m.room.message#m.image => m.room.message$m.image} (100%) rename event-schemas/examples/{m.room.message#m.location => m.room.message$m.location} (100%) rename event-schemas/examples/{m.room.message#m.notice => m.room.message$m.notice} (100%) rename event-schemas/examples/{m.room.message#m.server_notice => m.room.message$m.server_notice} (100%) rename event-schemas/examples/{m.room.message#m.text => m.room.message$m.text} (100%) rename event-schemas/examples/{m.room.message#m.video => m.room.message$m.video} (100%) rename event-schemas/examples/{m.room_key_request#cancel_request => m.room_key_request$cancel_request} (100%) rename event-schemas/examples/{m.room_key_request#request => m.room_key_request$request} (100%) rename event-schemas/schema/{m.room.message#m.audio => m.room.message$m.audio} (100%) rename event-schemas/schema/{m.room.message#m.emote => m.room.message$m.emote} (100%) rename event-schemas/schema/{m.room.message#m.file => m.room.message$m.file} (100%) rename event-schemas/schema/{m.room.message#m.image => m.room.message$m.image} (100%) rename event-schemas/schema/{m.room.message#m.location => m.room.message$m.location} (100%) rename event-schemas/schema/{m.room.message#m.notice => m.room.message$m.notice} (100%) rename event-schemas/schema/{m.room.message#m.server_notice => m.room.message$m.server_notice} (100%) rename event-schemas/schema/{m.room.message#m.text => m.room.message$m.text} (100%) rename event-schemas/schema/{m.room.message#m.video => m.room.message$m.video} (100%) diff --git a/api/application-service/transactions.yaml b/api/application-service/transactions.yaml index 981811969..09f152765 100644 --- a/api/application-service/transactions.yaml +++ b/api/application-service/transactions.yaml @@ -56,7 +56,7 @@ paths: example: { "events": [ {"$ref": "../../event-schemas/examples/m.room.member"}, - {"$ref": "../../event-schemas/examples/m.room.message#m.text"} + {"$ref": "../../event-schemas/examples/m.room.message$m.text"} ] } description: Transaction information diff --git a/api/client-server/event_context.yaml b/api/client-server/event_context.yaml index 549902a09..e20180284 100644 --- a/api/client-server/event_context.yaml +++ b/api/client-server/event_context.yaml @@ -105,18 +105,18 @@ paths: "events_after": [ { "room_id": "!636q39766251:example.com", - "$ref": "definitions/event-schemas/examples/m.room.message#m.text" + "$ref": "definitions/event-schemas/examples/m.room.message$m.text" } ], "event": { "event_id": "$f3h4d129462ha:example.com", "room_id": "!636q39766251:example.com", - "$ref": "definitions/event-schemas/examples/m.room.message#m.image" + "$ref": "definitions/event-schemas/examples/m.room.message$m.image" }, "events_before": [ { "room_id": "!636q39766251:example.com", - "$ref": "definitions/event-schemas/examples/m.room.message#m.file" + "$ref": "definitions/event-schemas/examples/m.room.message$m.file" } ], "start": "t27-54_2_0_2", diff --git a/api/client-server/message_pagination.yaml b/api/client-server/message_pagination.yaml index f29f1f23d..c9f9d0ae3 100644 --- a/api/client-server/message_pagination.yaml +++ b/api/client-server/message_pagination.yaml @@ -115,7 +115,7 @@ paths: "chunk": [ { "room_id": "!636q39766251:example.com", - "$ref": "definitions/event-schemas/examples/m.room.message#m.text" + "$ref": "definitions/event-schemas/examples/m.room.message$m.text" }, { "room_id": "!636q39766251:example.com", @@ -123,7 +123,7 @@ paths: }, { "room_id": "!636q39766251:example.com", - "$ref": "definitions/event-schemas/examples/m.room.message#m.video" + "$ref": "definitions/event-schemas/examples/m.room.message$m.video" } ] } diff --git a/api/client-server/notifications.yaml b/api/client-server/notifications.yaml index 6d9366be1..87341d418 100644 --- a/api/client-server/notifications.yaml +++ b/api/client-server/notifications.yaml @@ -75,7 +75,7 @@ paths: "room_id": "!abcdefg:example.com", "ts": 1475508881945, "event": { - "$ref": "definitions/event-schemas/examples/m.room.message#m.text" + "$ref": "definitions/event-schemas/examples/m.room.message$m.text" } } ] diff --git a/api/client-server/old_sync.yaml b/api/client-server/old_sync.yaml index c9b7586be..a79c3b322 100644 --- a/api/client-server/old_sync.yaml +++ b/api/client-server/old_sync.yaml @@ -64,7 +64,7 @@ paths: "start": "s3456_9_0", "end": "s3457_9_0", "chunk": [ - {"$ref": "definitions/event-schemas/examples/m.room.message#m.text"} + {"$ref": "definitions/event-schemas/examples/m.room.message$m.text"} ] } schema: @@ -148,11 +148,11 @@ paths: "chunk": [ { "room_id": "!TmaZBKYIFrIPVGoUYp:localhost", - "$ref": "definitions/event-schemas/examples/m.room.message#m.text" + "$ref": "definitions/event-schemas/examples/m.room.message$m.text" }, { "room_id": "!TmaZBKYIFrIPVGoUYp:localhost", - "$ref": "definitions/event-schemas/examples/m.room.message#m.video" + "$ref": "definitions/event-schemas/examples/m.room.message$m.video" } ], "end": "s3456_9_0", @@ -326,7 +326,7 @@ paths: 200: description: The full event. examples: - application/json: {"$ref": "definitions/event-schemas/examples/m.room.message#m.text"} + application/json: {"$ref": "definitions/event-schemas/examples/m.room.message$m.text"} schema: allOf: - "$ref": "definitions/event-schemas/schema/core-event-schema/event.yaml" diff --git a/api/client-server/peeking_events.yaml b/api/client-server/peeking_events.yaml index e3dc57774..feac36f4b 100644 --- a/api/client-server/peeking_events.yaml +++ b/api/client-server/peeking_events.yaml @@ -76,7 +76,7 @@ paths: "chunk": [ { "room_id": "!somewhere:over.the.rainbow", - "$ref": "definitions/event-schemas/examples/m.room.message#m.text" + "$ref": "definitions/event-schemas/examples/m.room.message$m.text" } ] } diff --git a/api/client-server/room_initial_sync.yaml b/api/client-server/room_initial_sync.yaml index 2a354fc0a..72e56ba9f 100644 --- a/api/client-server/room_initial_sync.yaml +++ b/api/client-server/room_initial_sync.yaml @@ -44,11 +44,11 @@ paths: "chunk": [ { "room_id": "!636q39766251:example.com", - "$ref": "definitions/event-schemas/examples/m.room.message#m.text" + "$ref": "definitions/event-schemas/examples/m.room.message$m.text" }, { "room_id": "!636q39766251:example.com", - "$ref": "definitions/event-schemas/examples/m.room.message#m.file" + "$ref": "definitions/event-schemas/examples/m.room.message$m.file" } ], "end": "s3456_9_0", diff --git a/api/client-server/rooms.yaml b/api/client-server/rooms.yaml index 554564360..377783c68 100644 --- a/api/client-server/rooms.yaml +++ b/api/client-server/rooms.yaml @@ -55,7 +55,7 @@ paths: examples: application/json: { "room_id": "!636q39766251:matrix.org", - "$ref": "definitions/event-schemas/examples/m.room.message#m.text" + "$ref": "definitions/event-schemas/examples/m.room.message$m.text" } schema: allOf: diff --git a/api/client-server/search.yaml b/api/client-server/search.yaml index 9d5d20747..4fe72d5bf 100644 --- a/api/client-server/search.yaml +++ b/api/client-server/search.yaml @@ -349,7 +349,7 @@ paths: "result": { "room_id": "!qPewotXpIctQySfjSy:localhost", "event_id": "$144429830826TWwbB:localhost", - "$ref": "definitions/event-schemas/examples/m.room.message#m.text" + "$ref": "definitions/event-schemas/examples/m.room.message$m.text" } } ] diff --git a/api/client-server/sync.yaml b/api/client-server/sync.yaml index ad5a6075c..02fddb84b 100644 --- a/api/client-server/sync.yaml +++ b/api/client-server/sync.yaml @@ -342,7 +342,7 @@ paths: }, { "room_id": "!726s6s6q:example.com", - "$ref": "definitions/event-schemas/examples/m.room.message#m.text" + "$ref": "definitions/event-schemas/examples/m.room.message$m.text" } ], "limited": true, diff --git a/event-schemas/check_examples.py b/event-schemas/check_examples.py index 3e536ec3b..2baa3ef02 100755 --- a/event-schemas/check_examples.py +++ b/event-schemas/check_examples.py @@ -112,8 +112,8 @@ def check_example_dir(exampledir, schemadir): continue examplepath = os.path.join(root, filename) schemapath = examplepath.replace(exampledir, schemadir) - if schemapath.find("#") >= 0: - schemapath = schemapath[:schemapath.find("#")] + if schemapath.find("$") >= 0: + schemapath = schemapath[:schemapath.find("$")] try: check_example_file(examplepath, schemapath) except Exception as e: diff --git a/event-schemas/examples/m.room.encrypted#megolm b/event-schemas/examples/m.room.encrypted$megolm similarity index 100% rename from event-schemas/examples/m.room.encrypted#megolm rename to event-schemas/examples/m.room.encrypted$megolm diff --git a/event-schemas/examples/m.room.encrypted#olm b/event-schemas/examples/m.room.encrypted$olm similarity index 100% rename from event-schemas/examples/m.room.encrypted#olm rename to event-schemas/examples/m.room.encrypted$olm diff --git a/event-schemas/examples/m.room.member#invite_room_state b/event-schemas/examples/m.room.member$invite_room_state similarity index 100% rename from event-schemas/examples/m.room.member#invite_room_state rename to event-schemas/examples/m.room.member$invite_room_state diff --git a/event-schemas/examples/m.room.member#third_party_invite b/event-schemas/examples/m.room.member$third_party_invite similarity index 100% rename from event-schemas/examples/m.room.member#third_party_invite rename to event-schemas/examples/m.room.member$third_party_invite diff --git a/event-schemas/examples/m.room.message#m.audio b/event-schemas/examples/m.room.message$m.audio similarity index 99% rename from event-schemas/examples/m.room.message#m.audio rename to event-schemas/examples/m.room.message$m.audio index 2f743d49e..58e874e0c 100644 --- a/event-schemas/examples/m.room.message#m.audio +++ b/event-schemas/examples/m.room.message$m.audio @@ -11,4 +11,4 @@ }, "msgtype": "m.audio" } -} +} diff --git a/event-schemas/examples/m.room.message#m.emote b/event-schemas/examples/m.room.message$m.emote similarity index 100% rename from event-schemas/examples/m.room.message#m.emote rename to event-schemas/examples/m.room.message$m.emote diff --git a/event-schemas/examples/m.room.message#m.file b/event-schemas/examples/m.room.message$m.file similarity index 100% rename from event-schemas/examples/m.room.message#m.file rename to event-schemas/examples/m.room.message$m.file diff --git a/event-schemas/examples/m.room.message#m.image b/event-schemas/examples/m.room.message$m.image similarity index 100% rename from event-schemas/examples/m.room.message#m.image rename to event-schemas/examples/m.room.message$m.image diff --git a/event-schemas/examples/m.room.message#m.location b/event-schemas/examples/m.room.message$m.location similarity index 100% rename from event-schemas/examples/m.room.message#m.location rename to event-schemas/examples/m.room.message$m.location diff --git a/event-schemas/examples/m.room.message#m.notice b/event-schemas/examples/m.room.message$m.notice similarity index 100% rename from event-schemas/examples/m.room.message#m.notice rename to event-schemas/examples/m.room.message$m.notice diff --git a/event-schemas/examples/m.room.message#m.server_notice b/event-schemas/examples/m.room.message$m.server_notice similarity index 100% rename from event-schemas/examples/m.room.message#m.server_notice rename to event-schemas/examples/m.room.message$m.server_notice diff --git a/event-schemas/examples/m.room.message#m.text b/event-schemas/examples/m.room.message$m.text similarity index 100% rename from event-schemas/examples/m.room.message#m.text rename to event-schemas/examples/m.room.message$m.text diff --git a/event-schemas/examples/m.room.message#m.video b/event-schemas/examples/m.room.message$m.video similarity index 100% rename from event-schemas/examples/m.room.message#m.video rename to event-schemas/examples/m.room.message$m.video diff --git a/event-schemas/examples/m.room_key_request#cancel_request b/event-schemas/examples/m.room_key_request$cancel_request similarity index 100% rename from event-schemas/examples/m.room_key_request#cancel_request rename to event-schemas/examples/m.room_key_request$cancel_request diff --git a/event-schemas/examples/m.room_key_request#request b/event-schemas/examples/m.room_key_request$request similarity index 100% rename from event-schemas/examples/m.room_key_request#request rename to event-schemas/examples/m.room_key_request$request diff --git a/event-schemas/schema/m.room.message#m.audio b/event-schemas/schema/m.room.message$m.audio similarity index 100% rename from event-schemas/schema/m.room.message#m.audio rename to event-schemas/schema/m.room.message$m.audio diff --git a/event-schemas/schema/m.room.message#m.emote b/event-schemas/schema/m.room.message$m.emote similarity index 100% rename from event-schemas/schema/m.room.message#m.emote rename to event-schemas/schema/m.room.message$m.emote diff --git a/event-schemas/schema/m.room.message#m.file b/event-schemas/schema/m.room.message$m.file similarity index 100% rename from event-schemas/schema/m.room.message#m.file rename to event-schemas/schema/m.room.message$m.file diff --git a/event-schemas/schema/m.room.message#m.image b/event-schemas/schema/m.room.message$m.image similarity index 100% rename from event-schemas/schema/m.room.message#m.image rename to event-schemas/schema/m.room.message$m.image diff --git a/event-schemas/schema/m.room.message#m.location b/event-schemas/schema/m.room.message$m.location similarity index 100% rename from event-schemas/schema/m.room.message#m.location rename to event-schemas/schema/m.room.message$m.location diff --git a/event-schemas/schema/m.room.message#m.notice b/event-schemas/schema/m.room.message$m.notice similarity index 100% rename from event-schemas/schema/m.room.message#m.notice rename to event-schemas/schema/m.room.message$m.notice diff --git a/event-schemas/schema/m.room.message#m.server_notice b/event-schemas/schema/m.room.message$m.server_notice similarity index 100% rename from event-schemas/schema/m.room.message#m.server_notice rename to event-schemas/schema/m.room.message$m.server_notice diff --git a/event-schemas/schema/m.room.message#m.text b/event-schemas/schema/m.room.message$m.text similarity index 100% rename from event-schemas/schema/m.room.message#m.text rename to event-schemas/schema/m.room.message$m.text diff --git a/event-schemas/schema/m.room.message#m.video b/event-schemas/schema/m.room.message$m.video similarity index 100% rename from event-schemas/schema/m.room.message#m.video rename to event-schemas/schema/m.room.message$m.video diff --git a/scripts/templating/matrix_templates/sections.py b/scripts/templating/matrix_templates/sections.py index 92afa5ffc..c88959ed7 100644 --- a/scripts/templating/matrix_templates/sections.py +++ b/scripts/templating/matrix_templates/sections.py @@ -115,7 +115,7 @@ class MatrixSections(Sections): schemas = self.units.get("event_schemas") renders = {} for event_type in schemas: - underscored_event_type = event_type.replace(".", "_").replace("#", "_") + underscored_event_type = event_type.replace(".", "_").replace("$", "_") renders[underscored_event_type + "_event"] = self._render_events( lambda x: x == event_type, sorted ) @@ -125,7 +125,7 @@ class MatrixSections(Sections): def filterFn(eventType): return ( eventType.startswith("m.room") and - not eventType.startswith("m.room.message#m.") + not eventType.startswith("m.room.message$m.") ) return self._render_events(filterFn, sorted) @@ -138,22 +138,22 @@ class MatrixSections(Sections): ]["subtitle"] sections = [] msgtype_order = [ - "m.room.message#m.text", "m.room.message#m.emote", - "m.room.message#m.notice", "m.room.message#m.image", - "m.room.message#m.file" + "m.room.message$m.text", "m.room.message$m.emote", + "m.room.message$m.notice", "m.room.message$m.image", + "m.room.message$m.file" ] excluded_types = [ # We exclude server notices from here because we handle them in a # dedicated module. We do not want to confuse developers this early # in the spec. - "m.room.message#m.server_notice", + "m.room.message$m.server_notice", ] other_msgtypes = [ - k for k in schemas.keys() if k.startswith("m.room.message#") and + k for k in schemas.keys() if k.startswith("m.room.message$") and k not in msgtype_order and k not in excluded_types ] for event_name in (msgtype_order + other_msgtypes): - if not event_name.startswith("m.room.message#m."): + if not event_name.startswith("m.room.message$m."): continue sections.append(template.render( example=examples[event_name][0], diff --git a/scripts/templating/matrix_templates/units.py b/scripts/templating/matrix_templates/units.py index d4745e4d6..ddb65efe2 100644 --- a/scripts/templating/matrix_templates/units.py +++ b/scripts/templating/matrix_templates/units.py @@ -795,7 +795,7 @@ class MatrixUnits(Units): if not filename.startswith("m."): continue - event_name = filename.split("#")[0] + event_name = filename.split("$")[0] filepath = os.path.join(path, filename) logger.info("Reading event example: %s" % filepath) try: