jolicode / slack-php-api

:hash: PHP Slack Client based on the official OpenAPI specification
https://jolicode.github.io/slack-php-api/
MIT License
222 stars 56 forks source link

Update the Slack Specification and rewrite all the patches #45

Closed damienalexandre closed 4 years ago

damienalexandre commented 5 years ago
pyrech commented 5 years ago

Looks like Slack changed some object definition and used items to describe possible variant for some object. In particular, the objs_user changed to differentiate normal users and enterprise users and is now rendered as two classes ObjsUserItem0 and ObjsUserItem1 instead of the previous ObjsUser. The denormilizer even returns stdClass instead of these classes.

We should probably apply a patch to transform back the user model in one class. Should we also fix other models that are now described with the items notation?

damienalexandre commented 5 years ago

You were right, the Slack specification introduced some polymorphic objects that cannot be handled gracefully in the generated client.

I added two patches to merge those objects.

Could you please test again?

jamesgraham commented 5 years ago

@damienalexandre does this fix #7 ?

damienalexandre commented 5 years ago

As far as I can guess, yes... maybe? But it should be ok on master too... did you try again recently?

Look at this part:

https://github.com/jolicode/slack-php-api/blob/fc7986874136f51b3e20b459ccd1b37d9dc9b378/generated/Endpoint/UsersList.php#L67-L81

If the status is not 200, the UsersListGetResponsedefault object is used, and the error string is here:

https://github.com/jolicode/slack-php-api/blob/fc7986874136f51b3e20b459ccd1b37d9dc9b378/generated/Model/UsersListGetResponsedefault.php#L13-L22

pyrech commented 4 years ago

The PR now works great on https://github.com/jolicode/secret-santa. Great jobs :clap: