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.
This commit is contained in:
parent
c25afa663e
commit
d6d74c4cbe
37 changed files with 29 additions and 29 deletions
|
@ -56,7 +56,7 @@ paths:
|
||||||
example: {
|
example: {
|
||||||
"events": [
|
"events": [
|
||||||
{"$ref": "../../event-schemas/examples/m.room.member"},
|
{"$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
|
description: Transaction information
|
||||||
|
|
|
@ -105,18 +105,18 @@ paths:
|
||||||
"events_after": [
|
"events_after": [
|
||||||
{
|
{
|
||||||
"room_id": "!636q39766251:example.com",
|
"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": {
|
||||||
"event_id": "$f3h4d129462ha:example.com",
|
"event_id": "$f3h4d129462ha:example.com",
|
||||||
"room_id": "!636q39766251: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": [
|
"events_before": [
|
||||||
{
|
{
|
||||||
"room_id": "!636q39766251:example.com",
|
"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",
|
"start": "t27-54_2_0_2",
|
||||||
|
|
|
@ -115,7 +115,7 @@ paths:
|
||||||
"chunk": [
|
"chunk": [
|
||||||
{
|
{
|
||||||
"room_id": "!636q39766251:example.com",
|
"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",
|
"room_id": "!636q39766251:example.com",
|
||||||
|
@ -123,7 +123,7 @@ paths:
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"room_id": "!636q39766251:example.com",
|
"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"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
|
@ -75,7 +75,7 @@ paths:
|
||||||
"room_id": "!abcdefg:example.com",
|
"room_id": "!abcdefg:example.com",
|
||||||
"ts": 1475508881945,
|
"ts": 1475508881945,
|
||||||
"event": {
|
"event": {
|
||||||
"$ref": "definitions/event-schemas/examples/m.room.message#m.text"
|
"$ref": "definitions/event-schemas/examples/m.room.message$m.text"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
|
@ -64,7 +64,7 @@ paths:
|
||||||
"start": "s3456_9_0",
|
"start": "s3456_9_0",
|
||||||
"end": "s3457_9_0",
|
"end": "s3457_9_0",
|
||||||
"chunk": [
|
"chunk": [
|
||||||
{"$ref": "definitions/event-schemas/examples/m.room.message#m.text"}
|
{"$ref": "definitions/event-schemas/examples/m.room.message$m.text"}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
schema:
|
schema:
|
||||||
|
@ -148,11 +148,11 @@ paths:
|
||||||
"chunk": [
|
"chunk": [
|
||||||
{
|
{
|
||||||
"room_id": "!TmaZBKYIFrIPVGoUYp:localhost",
|
"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",
|
"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",
|
"end": "s3456_9_0",
|
||||||
|
@ -326,7 +326,7 @@ paths:
|
||||||
200:
|
200:
|
||||||
description: The full event.
|
description: The full event.
|
||||||
examples:
|
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:
|
schema:
|
||||||
allOf:
|
allOf:
|
||||||
- "$ref": "definitions/event-schemas/schema/core-event-schema/event.yaml"
|
- "$ref": "definitions/event-schemas/schema/core-event-schema/event.yaml"
|
||||||
|
|
|
@ -76,7 +76,7 @@ paths:
|
||||||
"chunk": [
|
"chunk": [
|
||||||
{
|
{
|
||||||
"room_id": "!somewhere:over.the.rainbow",
|
"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"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,11 +44,11 @@ paths:
|
||||||
"chunk": [
|
"chunk": [
|
||||||
{
|
{
|
||||||
"room_id": "!636q39766251:example.com",
|
"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",
|
"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",
|
"end": "s3456_9_0",
|
||||||
|
|
|
@ -55,7 +55,7 @@ paths:
|
||||||
examples:
|
examples:
|
||||||
application/json: {
|
application/json: {
|
||||||
"room_id": "!636q39766251:matrix.org",
|
"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:
|
schema:
|
||||||
allOf:
|
allOf:
|
||||||
|
|
|
@ -349,7 +349,7 @@ paths:
|
||||||
"result": {
|
"result": {
|
||||||
"room_id": "!qPewotXpIctQySfjSy:localhost",
|
"room_id": "!qPewotXpIctQySfjSy:localhost",
|
||||||
"event_id": "$144429830826TWwbB: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"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
|
@ -342,7 +342,7 @@ paths:
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"room_id": "!726s6s6q:example.com",
|
"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,
|
"limited": true,
|
||||||
|
|
|
@ -112,8 +112,8 @@ def check_example_dir(exampledir, schemadir):
|
||||||
continue
|
continue
|
||||||
examplepath = os.path.join(root, filename)
|
examplepath = os.path.join(root, filename)
|
||||||
schemapath = examplepath.replace(exampledir, schemadir)
|
schemapath = examplepath.replace(exampledir, schemadir)
|
||||||
if schemapath.find("#") >= 0:
|
if schemapath.find("$") >= 0:
|
||||||
schemapath = schemapath[:schemapath.find("#")]
|
schemapath = schemapath[:schemapath.find("$")]
|
||||||
try:
|
try:
|
||||||
check_example_file(examplepath, schemapath)
|
check_example_file(examplepath, schemapath)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
|
|
@ -115,7 +115,7 @@ class MatrixSections(Sections):
|
||||||
schemas = self.units.get("event_schemas")
|
schemas = self.units.get("event_schemas")
|
||||||
renders = {}
|
renders = {}
|
||||||
for event_type in schemas:
|
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(
|
renders[underscored_event_type + "_event"] = self._render_events(
|
||||||
lambda x: x == event_type, sorted
|
lambda x: x == event_type, sorted
|
||||||
)
|
)
|
||||||
|
@ -125,7 +125,7 @@ class MatrixSections(Sections):
|
||||||
def filterFn(eventType):
|
def filterFn(eventType):
|
||||||
return (
|
return (
|
||||||
eventType.startswith("m.room") and
|
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)
|
return self._render_events(filterFn, sorted)
|
||||||
|
|
||||||
|
@ -138,22 +138,22 @@ class MatrixSections(Sections):
|
||||||
]["subtitle"]
|
]["subtitle"]
|
||||||
sections = []
|
sections = []
|
||||||
msgtype_order = [
|
msgtype_order = [
|
||||||
"m.room.message#m.text", "m.room.message#m.emote",
|
"m.room.message$m.text", "m.room.message$m.emote",
|
||||||
"m.room.message#m.notice", "m.room.message#m.image",
|
"m.room.message$m.notice", "m.room.message$m.image",
|
||||||
"m.room.message#m.file"
|
"m.room.message$m.file"
|
||||||
]
|
]
|
||||||
excluded_types = [
|
excluded_types = [
|
||||||
# We exclude server notices from here because we handle them in a
|
# We exclude server notices from here because we handle them in a
|
||||||
# dedicated module. We do not want to confuse developers this early
|
# dedicated module. We do not want to confuse developers this early
|
||||||
# in the spec.
|
# in the spec.
|
||||||
"m.room.message#m.server_notice",
|
"m.room.message$m.server_notice",
|
||||||
]
|
]
|
||||||
other_msgtypes = [
|
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
|
k not in msgtype_order and k not in excluded_types
|
||||||
]
|
]
|
||||||
for event_name in (msgtype_order + other_msgtypes):
|
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
|
continue
|
||||||
sections.append(template.render(
|
sections.append(template.render(
|
||||||
example=examples[event_name][0],
|
example=examples[event_name][0],
|
||||||
|
|
|
@ -795,7 +795,7 @@ class MatrixUnits(Units):
|
||||||
if not filename.startswith("m."):
|
if not filename.startswith("m."):
|
||||||
continue
|
continue
|
||||||
|
|
||||||
event_name = filename.split("#")[0]
|
event_name = filename.split("$")[0]
|
||||||
filepath = os.path.join(path, filename)
|
filepath = os.path.join(path, filename)
|
||||||
logger.info("Reading event example: %s" % filepath)
|
logger.info("Reading event example: %s" % filepath)
|
||||||
try:
|
try:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue