Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ConversationsRepliesGetResponse200 should provide typing for messages other than mixed[] #136

Open
mpyw opened this issue Jan 18, 2022 · 5 comments

Comments

@mpyw
Copy link
Contributor

mpyw commented Jan 18, 2022

/**
* @return mixed[]|null
*/
public function getMessages(): ?array
{
return $this->messages;
}
/**
* @param mixed[]|null $messages
*/
public function setMessages(?array $messages): self
{
$this->messages = $messages;
return $this;
}

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

@mpyw
Copy link
Contributor Author

mpyw commented Jan 18, 2022

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
Copy link
Contributor Author

mpyw commented Jan 24, 2022

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

@mpyw mpyw changed the title ConversationsRepliesGetResponse200 is incorrectly typed ConversationsRepliesGetResponse200 should provide typing for messages, not mixed[] Jan 24, 2022
@mpyw mpyw changed the title ConversationsRepliesGetResponse200 should provide typing for messages, not mixed[] ConversationsRepliesGetResponse200 should provide typing for messages other than mixed[] Jan 24, 2022
@mpyw
Copy link
Contributor Author

mpyw commented Jan 24, 2022

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
Copy link
Contributor Author

mpyw commented Jan 28, 2022

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 😢

@lyrixx
Copy link
Member

lyrixx commented Apr 19, 2023

Hello,

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants