slack-php-api icon indicating copy to clipboard operation
slack-php-api copied to clipboard

ConversationsRepliesGetResponse200 should provide typing for `messages` other than `mixed[]`

Open mpyw opened this issue 4 years ago • 6 comments

https://github.com/jolicode/slack-php-api/blob/836217b880fedb47b34a4bcb2eccaa2502b92e57/generated/Model/ConversationsRepliesGetResponse200.php#L47-L63

~It should not be mixed[] but ObjsMessage[].~ It should be assigned the type other than mixed[].

mpyw avatar Jan 18 '22 05:01 mpyw

The official typing uses anonymous objects, so it doesn't seem to be treated as ObjsMessage. However, composing a items[0] and items[1] whose properties are completely nullable ~perfectly~ partially matches for ObjsMessage, so it's OK to go with it. This is a much better solution than mixed.

"messages": {
    "items": {
        "items": [
            {
                "additionalProperties": false,
                "properties": {
                    "last_read": {
                        "$ref": "#/definitions/defs_ts"
                    },
                    "latest_reply": {
                        "$ref": "#/definitions/defs_ts"
                    },
                    "reply_count": {
                        "type": "integer"
                    },
                    "reply_users": {
                        "items": {
                            "$ref": "#/definitions/defs_user_id"
                        },
                        "type": "array",
                        "uniqueItems": true
                    },
                    "reply_users_count": {
                        "type": "integer"
                    },
                    "source_team": {
                        "$ref": "#/definitions/defs_team"
                    },
                    "subscribed": {
                        "type": "boolean"
                    },
                    "team": {
                        "$ref": "#/definitions/defs_team"
                    },
                    "text": {
                        "type": "string"
                    },
                    "thread_ts": {
                        "$ref": "#/definitions/defs_ts"
                    },
                    "ts": {
                        "$ref": "#/definitions/defs_ts"
                    },
                    "type": {
                        "type": "string"
                    },
                    "unread_count": {
                        "type": "integer"
                    },
                    "user": {
                        "$ref": "#/definitions/defs_user_id"
                    },
                    "user_profile": {
                        "$ref": "#/definitions/objs_user_profile_short"
                    },
                    "user_team": {
                        "$ref": "#/definitions/defs_team"
                    }
                },
                "required": [
                    "type",
                    "user",
                    "text",
                    "thread_ts",
                    "reply_count",
                    "subscribed",
                    "ts"
                ],
                "type": "object"
            },
            {
                "additionalProperties": false,
                "properties": {
                    "is_starred": {
                        "type": "boolean"
                    },
                    "parent_user_id": {
                        "$ref": "#/definitions/defs_user_id"
                    },
                    "source_team": {
                        "$ref": "#/definitions/defs_team"
                    },
                    "team": {
                        "$ref": "#/definitions/defs_team"
                    },
                    "text": {
                        "type": "string"
                    },
                    "thread_ts": {
                        "$ref": "#/definitions/defs_ts"
                    },
                    "ts": {
                        "$ref": "#/definitions/defs_ts"
                    },
                    "type": {
                        "type": "string"
                    },
                    "user": {
                        "$ref": "#/definitions/defs_user_id"
                    },
                    "user_profile": {
                        "$ref": "#/definitions/objs_user_profile_short"
                    },
                    "user_team": {
                        "$ref": "#/definitions/defs_team"
                    }
                },
                "required": [
                    "type",
                    "user",
                    "text",
                    "thread_ts",
                    "parent_user_id",
                    "ts"
                ],
                "type": "object"
            }
        ]
    },
    "type": "array"
}
"objs_message": {
    "additionalProperties": false,
    "properties": {
        "attachments": {
            "items": {
                "additionalProperties": false,
                "properties": {
                    "fallback": {
                        "type": "string"
                    },
                    "id": {
                        "type": "integer"
                    },
                    "image_bytes": {
                        "type": "integer"
                    },
                    "image_height": {
                        "type": "integer"
                    },
                    "image_url": {
                        "type": "string"
                    },
                    "image_width": {
                        "type": "integer"
                    }
                },
                "required": [
                    "id"
                ],
                "type": "object"
            },
            "minItems": 1,
            "type": "array",
            "uniqueItems": true
        },
        "blocks": {
            "$ref": "#/definitions/blocks"
        },
        "bot_id": {
            "items": [
                {
                    "$ref": "#/definitions/defs_bot_id"
                },
                {
                    "title": "Nil bot_id set when display_as_bot is false",
                    "type": "null"
                }
            ]
        },
        "bot_profile": {
            "$ref": "#/definitions/objs_bot_profile"
        },
        "client_msg_id": {
            "type": "string"
        },
        "comment": {
            "$ref": "#/definitions/objs_comment"
        },
        "display_as_bot": {
            "type": "boolean"
        },
        "file": {
            "$ref": "#/definitions/objs_file"
        },
        "files": {
            "items": {
                "$ref": "#/definitions/objs_file"
            },
            "minItems": 1,
            "type": "array",
            "uniqueItems": true
        },
        "icons": {
            "additionalProperties": false,
            "properties": {
                "emoji": {
                    "type": "string"
                },
                "image_64": {
                    "format": "uri",
                    "type": "string"
                }
            },
            "type": "object"
        },
        "inviter": {
            "$ref": "#/definitions/defs_user_id"
        },
        "is_delayed_message": {
            "type": "boolean"
        },
        "is_intro": {
            "type": "boolean"
        },
        "is_starred": {
            "type": "boolean"
        },
        "last_read": {
            "$ref": "#/definitions/defs_ts"
        },
        "latest_reply": {
            "$ref": "#/definitions/defs_ts"
        },
        "name": {
            "type": "string"
        },
        "old_name": {
            "type": "string"
        },
        "parent_user_id": {
            "$ref": "#/definitions/defs_user_id"
        },
        "permalink": {
            "format": "uri",
            "type": "string"
        },
        "pinned_to": {
            "items": {
                "$ref": "#/definitions/defs_channel"
            },
            "type": "array"
        },
        "purpose": {
            "type": "string"
        },
        "reactions": {
            "items": {
                "$ref": "#/definitions/objs_reaction"
            },
            "type": "array"
        },
        "reply_count": {
            "type": "integer"
        },
        "reply_users": {
            "items": {
                "$ref": "#/definitions/defs_user_id"
            },
            "minItems": 1,
            "type": "array",
            "uniqueItems": true
        },
        "reply_users_count": {
            "type": "integer"
        },
        "source_team": {
            "$ref": "#/definitions/defs_workspace_id"
        },
        "subscribed": {
            "type": "boolean"
        },
        "subtype": {
            "type": "string"
        },
        "team": {
            "$ref": "#/definitions/defs_workspace_id"
        },
        "text": {
            "type": "string"
        },
        "thread_ts": {
            "$ref": "#/definitions/defs_ts"
        },
        "topic": {
            "type": "string"
        },
        "ts": {
            "$ref": "#/definitions/defs_ts"
        },
        "type": {
            "type": "string"
        },
        "unread_count": {
            "type": "integer"
        },
        "upload": {
            "type": "boolean"
        },
        "user": {
            "$ref": "#/definitions/defs_user_id"
        },
        "user_profile": {
            "$ref": "#/definitions/objs_user_profile_short"
        },
        "user_team": {
            "$ref": "#/definitions/defs_workspace_id"
        },
        "username": {
            "type": "string"
        }
    },
    "required": [
        "text",
        "type",
        "ts"
    ],
    "title": "Message object",
    "type": "object"
}

mpyw avatar Jan 18 '22 08:01 mpyw

Or more accurately, we need to provide another typed implementation for them.

mpyw avatar Jan 24 '22 02:01 mpyw

Diff

Individual

--- objs_message.txt	2022-01-24 11:53:04.000000000 +0900
+++ objs_message_reply_thread.txt	2022-01-24 11:59:33.000000000 +0900
-attachments
-blocks
-bot_id
-bot_profile
-client_msg_id
-comment
-display_as_bot
-file
-files
-icons
-inviter
-is_delayed_message
-is_intro
-is_starred
 last_read
 latest_reply
-name
-old_name
-parent_user_id
-permalink
-pinned_to
-purpose
-reactions
 reply_count
 reply_users
 reply_users_count
 source_team
 subscribed
-subtype
 team
 text
 thread_ts
-topic
 ts
 type
 unread_count
-upload
 user
 user_profile
-username
--- objs_message.txt	2022-01-24 11:53:04.000000000 +0900
+++ objs_message_reply_child.txt	2022-01-24 11:59:53.000000000 +0900
-attachments
-blocks
-bot_id
-bot_profile
-client_msg_id
-comment
-display_as_bot
-file
-files
-icons
-inviter
-is_delayed_message
-is_intro
 is_starred
-last_read
-latest_reply
-name
-old_name
 parent_user_id
-permalink
-pinned_to
-purpose
-reactions
-reply_count
-reply_users
-reply_users_count
 source_team
-subscribed
-subtype
 team
 text
 thread_ts
-topic
 ts
 type
-unread_count
-upload
 user
 user_profile
-user_team
-username

Merged

--- objs_message.txt	2022-01-24 11:53:04.000000000 +0900
+++ objs_message_reply_merged.txt	2022-01-24 11:53:28.000000000 +0900
-attachments
-blocks
-bot_id
-bot_profile
-client_msg_id
-comment
-display_as_bot
-file
-files
-icons
-inviter
-is_delayed_message
-is_intro
 is_starred
 last_read
 latest_reply
-name
-old_name
 parent_user_id
-permalink
-pinned_to
-purpose
-reactions
 reply_count
 reply_users
 reply_users_count
 source_team
 subscribed
-subtype
 team
 text
 thread_ts
-topic
 ts
 type
 unread_count
-upload
 user
 user_profile
 user_team
-username

mpyw avatar Jan 24 '22 02:01 mpyw

Oops, the actual API response structure looks like it includes more (perhaps not all) components of ObjsMessage. It seems to me that there is another major error on slack-api-specs 😢

mpyw avatar Jan 28 '22 02:01 mpyw

Hello,

Did you manage to fix your issue? If not, does the latest version fix it?

lyrixx avatar Apr 19 '23 11:04 lyrixx