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

fix(ros): Copy better typing information from Notifications/Spreed app #49192

Merged

Conversation

nickvergessen
Copy link
Member

Fixes failing Talk and Notification psalm in a better way than nextcloud/notifications@5cf07bd

Checklist

@nickvergessen nickvergessen added bug 3. to review Waiting for reviews labels Nov 11, 2024
@nickvergessen nickvergessen added this to the Nextcloud 31 milestone Nov 11, 2024
@nickvergessen nickvergessen self-assigned this Nov 11, 2024
@nickvergessen nickvergessen requested review from a team, ArtificialOwl and icewind1991 and removed request for a team November 11, 2024 06:30
@@ -11,6 +11,36 @@
/**
* Class Validator
*
* @psalm-type RichObjectParameter = array{
Copy link
Member

@provokateurin provokateurin Nov 11, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could do this even better, by creating the exact types from

like this:

/**
 * @psalm-type RichObjectParameterAddressbook = array{
 *     id: string,
 *     type: string,
 *     name: string,
 * }
 *
 * @psalm-type RichObjectParameterAnnouncement = array{
 *     id: string,
 *     type: string,
 *     name: string,
 *     link?: string,
 * }
 *
 * @psalm-type RichObjectParameter = RichObjectParameterAddressbook|RichObjectParameterAnnouncement
 */

Of course this would be with all types, not just these ones.
Then every consumer knows exactly what they can use, because even with this annotation psalm will not yet prevent you from adding keys that are for a different object type.

We could have a script for this to ensure the psalm types match the definitions and then also make it available as a type for OpenAPI.
Maybe this is a bit overkill

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe this is a bit overkill

Glad you noticed it yourself :P

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well I have written this exact logic for a different use-case already, so it's not completely out of reach, just wanted to mention it would be possible to make it even stricter.

@nickvergessen nickvergessen merged commit a3be6ce into master Nov 11, 2024
179 of 186 checks passed
@nickvergessen nickvergessen deleted the bugfix/noid/copy-better-typing-from-notifications-app branch November 11, 2024 14:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3. to review Waiting for reviews bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants