-
-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
user_status: Add OpenAPI spec #36408
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Psalm found more than 10 potential problems in the proposed changes. Check the Files changed tab for more details.
* @return DataResponse<PrivateUserStatus> 200 Status successfully updated | ||
* @return DataResponse 204 User has no status to update | ||
* @return DataResponse 400 Invalid status to update |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Several @return
is not allowed it seems, see psalm errors.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah this is still a problem I have no solution for. I really need to have this working, but I don't know how. Only a single return annotation is kind of impossible or will get really ugly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would PHP attributes be a possible solution here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wdym? We probably found a solution for this problem, but I first need to test it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
https://www.php.net/manual/de/language.attributes.syntax.php it something we could use in Nextcloud 26+ as it requires PHP8+
Sample in #36363
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm I see, but it wouldn't help with static analysis, right? The idea seems pretty good though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you define am attribute and scan statically for that attribute, you can find these. You might be able to use reflections to let the PHP parser do the scanning even.
As PHP 7 is EOL, it should be good to go in general.
You could add a parameter to the attribute that contains an array. The keys would be the status codes and the value either a string of even a structure to describe the status.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, but this won't help psalm validate the code in the method, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe i got the problem wrong. Are you concerned about static code analysis using psalm or about the extraction of the API specification from the code?
For psalm a single return should be sufficient, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Both. Please let us discuss this in #36513
@@ -57,12 +60,12 @@ public function __construct(string $appName, | |||
/** | |||
* @NoAdminRequired | |||
* | |||
* @return DataResponse | |||
* @return DataResponse<PredefinedStatus[]> 200 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
DataResponse is not a template in the current code base. Remove the parameter or update the docblocks of DataRepsonse to make it a template.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#36355 can you review?
8c790bf
to
73f5c87
Compare
0253834
to
e514beb
Compare
cf4adbd
to
b3a7a60
Compare
Signed-off-by: jld3103 <[email protected]>
b3a7a60
to
79673bf
Compare
Summary
Adapts the code to make it friendly for https://github.com/nextcloud-gmbh/openapi-extractor and add the automatically generated spec.
TODO
Checklist