Skip to content

Commit 790e496

Browse files
committed
fixup! refactor(OpenAPI): Use proper type inheritance for chat messages
1 parent 158c7bb commit 790e496

File tree

10 files changed

+263
-245
lines changed

10 files changed

+263
-245
lines changed

lib/Model/ProxyCacheMessage.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@
5959
* @method void setMetaData(?string $metaData)
6060
* @method string|null getMetaData()
6161
*
62-
* @psalm-import-type TalkChatBaseMessage from ResponseDefinitions
62+
* @psalm-import-type TalkRoomProxyMessage from ResponseDefinitions
6363
*/
6464
class ProxyCacheMessage extends Entity implements \JsonSerializable {
6565
public const METADATA_REPLY_TO_ACTOR_TYPE = 'replyToActorType';
@@ -108,7 +108,7 @@ public function getParsedMetaData(): array {
108108
}
109109

110110
/**
111-
* @return TalkChatBaseMessage
111+
* @return TalkRoomProxyMessage
112112
*/
113113
public function jsonSerialize(): array {
114114
$expirationTimestamp = 0;

lib/ResponseDefinitions.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@
9393
* conversation?: string,
9494
* }
9595
*
96-
* @psalm-type TalkChatBaseMessage = array{
96+
* @psalm-type TalkBaseMessage = array{
9797
* actorDisplayName: string,
9898
* actorId: string,
9999
* actorType: string,
@@ -104,7 +104,7 @@
104104
* systemMessage: string,
105105
* }
106106
*
107-
* @psalm-type TalkChatMessage = TalkChatBaseMessage&array{
107+
* @psalm-type TalkChatMessage = TalkBaseMessage&array{
108108
* deleted?: true,
109109
* id: int,
110110
* isReplyable: bool,
@@ -120,7 +120,9 @@
120120
* silent?: bool,
121121
* }
122122
*
123-
* @psalm-type TalkRoomLastMessage = TalkChatMessage|TalkChatBaseMessage
123+
* @psalm-type TalkRoomProxyMessage = TalkBaseMessage
124+
*
125+
* @psalm-type TalkRoomLastMessage = TalkChatMessage|TalkRoomProxyMessage
124126
*
125127
* @psalm-type TalkChatMessageWithParent = TalkChatMessage&array{parent?: TalkChatMessage}
126128
*

openapi-backend-sipbridge.json

Lines changed: 48 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,49 @@
2020
}
2121
},
2222
"schemas": {
23+
"BaseMessage": {
24+
"type": "object",
25+
"required": [
26+
"actorDisplayName",
27+
"actorId",
28+
"actorType",
29+
"expirationTimestamp",
30+
"message",
31+
"messageParameters",
32+
"messageType",
33+
"systemMessage"
34+
],
35+
"properties": {
36+
"actorDisplayName": {
37+
"type": "string"
38+
},
39+
"actorId": {
40+
"type": "string"
41+
},
42+
"actorType": {
43+
"type": "string"
44+
},
45+
"expirationTimestamp": {
46+
"type": "integer",
47+
"format": "int64"
48+
},
49+
"message": {
50+
"type": "string"
51+
},
52+
"messageParameters": {
53+
"type": "object",
54+
"additionalProperties": {
55+
"$ref": "#/components/schemas/RichObjectParameter"
56+
}
57+
},
58+
"messageType": {
59+
"type": "string"
60+
},
61+
"systemMessage": {
62+
"type": "string"
63+
}
64+
}
65+
},
2366
"Capabilities": {
2467
"type": "object",
2568
"required": [
@@ -208,53 +251,10 @@
208251
}
209252
}
210253
},
211-
"ChatBaseMessage": {
212-
"type": "object",
213-
"required": [
214-
"actorDisplayName",
215-
"actorId",
216-
"actorType",
217-
"expirationTimestamp",
218-
"message",
219-
"messageParameters",
220-
"messageType",
221-
"systemMessage"
222-
],
223-
"properties": {
224-
"actorDisplayName": {
225-
"type": "string"
226-
},
227-
"actorId": {
228-
"type": "string"
229-
},
230-
"actorType": {
231-
"type": "string"
232-
},
233-
"expirationTimestamp": {
234-
"type": "integer",
235-
"format": "int64"
236-
},
237-
"message": {
238-
"type": "string"
239-
},
240-
"messageParameters": {
241-
"type": "object",
242-
"additionalProperties": {
243-
"$ref": "#/components/schemas/RichObjectParameter"
244-
}
245-
},
246-
"messageType": {
247-
"type": "string"
248-
},
249-
"systemMessage": {
250-
"type": "string"
251-
}
252-
}
253-
},
254254
"ChatMessage": {
255255
"allOf": [
256256
{
257-
"$ref": "#/components/schemas/ChatBaseMessage"
257+
"$ref": "#/components/schemas/BaseMessage"
258258
},
259259
{
260260
"type": "object",
@@ -726,9 +726,12 @@
726726
"$ref": "#/components/schemas/ChatMessage"
727727
},
728728
{
729-
"$ref": "#/components/schemas/ChatBaseMessage"
729+
"$ref": "#/components/schemas/RoomProxyMessage"
730730
}
731731
]
732+
},
733+
"RoomProxyMessage": {
734+
"$ref": "#/components/schemas/BaseMessage"
732735
}
733736
}
734737
},

openapi-federation.json

Lines changed: 48 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,49 @@
2020
}
2121
},
2222
"schemas": {
23+
"BaseMessage": {
24+
"type": "object",
25+
"required": [
26+
"actorDisplayName",
27+
"actorId",
28+
"actorType",
29+
"expirationTimestamp",
30+
"message",
31+
"messageParameters",
32+
"messageType",
33+
"systemMessage"
34+
],
35+
"properties": {
36+
"actorDisplayName": {
37+
"type": "string"
38+
},
39+
"actorId": {
40+
"type": "string"
41+
},
42+
"actorType": {
43+
"type": "string"
44+
},
45+
"expirationTimestamp": {
46+
"type": "integer",
47+
"format": "int64"
48+
},
49+
"message": {
50+
"type": "string"
51+
},
52+
"messageParameters": {
53+
"type": "object",
54+
"additionalProperties": {
55+
"$ref": "#/components/schemas/RichObjectParameter"
56+
}
57+
},
58+
"messageType": {
59+
"type": "string"
60+
},
61+
"systemMessage": {
62+
"type": "string"
63+
}
64+
}
65+
},
2366
"Capabilities": {
2467
"type": "object",
2568
"required": [
@@ -208,53 +251,10 @@
208251
}
209252
}
210253
},
211-
"ChatBaseMessage": {
212-
"type": "object",
213-
"required": [
214-
"actorDisplayName",
215-
"actorId",
216-
"actorType",
217-
"expirationTimestamp",
218-
"message",
219-
"messageParameters",
220-
"messageType",
221-
"systemMessage"
222-
],
223-
"properties": {
224-
"actorDisplayName": {
225-
"type": "string"
226-
},
227-
"actorId": {
228-
"type": "string"
229-
},
230-
"actorType": {
231-
"type": "string"
232-
},
233-
"expirationTimestamp": {
234-
"type": "integer",
235-
"format": "int64"
236-
},
237-
"message": {
238-
"type": "string"
239-
},
240-
"messageParameters": {
241-
"type": "object",
242-
"additionalProperties": {
243-
"$ref": "#/components/schemas/RichObjectParameter"
244-
}
245-
},
246-
"messageType": {
247-
"type": "string"
248-
},
249-
"systemMessage": {
250-
"type": "string"
251-
}
252-
}
253-
},
254254
"ChatMessage": {
255255
"allOf": [
256256
{
257-
"$ref": "#/components/schemas/ChatBaseMessage"
257+
"$ref": "#/components/schemas/BaseMessage"
258258
},
259259
{
260260
"type": "object",
@@ -780,9 +780,12 @@
780780
"$ref": "#/components/schemas/ChatMessage"
781781
},
782782
{
783-
"$ref": "#/components/schemas/ChatBaseMessage"
783+
"$ref": "#/components/schemas/RoomProxyMessage"
784784
}
785785
]
786+
},
787+
"RoomProxyMessage": {
788+
"$ref": "#/components/schemas/BaseMessage"
786789
}
787790
}
788791
},

0 commit comments

Comments
 (0)