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

feat: Add OpenAPI #3324

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft

feat: Add OpenAPI #3324

wants to merge 1 commit into from

Conversation

provokateurin
Copy link
Member

Closes #3208
This is a breaking change to the API, but since it was not usable before due to CSRF restrictions it doesn't matter.
While working on this I also had to cleanup a lot of the internal typings which resulted in this relatively large change for adding OpenAPI.
If this is too big please let me know and I will try to split it up.

@provokateurin provokateurin added enhancement 3. to review Items that need to be reviewed labels Oct 7, 2024
@provokateurin provokateurin added this to the Nextcloud 31 milestone Oct 7, 2024
@provokateurin provokateurin marked this pull request as draft October 7, 2024 10:02

Non-admins can access the `GET` requests to retrieve info about group folders they have access to.
Admins can add `applicable=1` as a parameter to the group folder list request to get the same filtered results of only folders they have direct access to.
See the [OpenAPI specification](openapi.json) to learn about all available API endpoints.
Copy link
Contributor

Choose a reason for hiding this comment

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

Hum any chance at linking to a readable form of the doc?

Copy link
Member Author

Choose a reason for hiding this comment

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

Not sure how that would work since we do not have an existing documentation page for Groupfolders.

Copy link
Contributor

Choose a reason for hiding this comment

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

Can you generate a .md files from the openapi doc? Then we could link to that?

Copy link
Contributor

Choose a reason for hiding this comment

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

I was thinking of a magic link like https://petstore.swagger.io/?url=https://raw.githubusercontent.com/nextcloud/groupfolders/ac3b696dbb820a5ae34039be1300c1309e58d4e1/openapi.json
tables application does that.
Using this instance is not ideal as it’s supposed to be a demo and it may even be contrary to their ToS, I did not check. But maybe there is a similar tool we can use, or we can host our own?

Copy link
Member Author

Choose a reason for hiding this comment

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

I think we have to go with something like that, there are no good markdown generators it seems.

lib/Command/ListCommand.php Show resolved Hide resolved
}, array_keys($folder['groups']), array_values($folder['groups']));
$folder['groups'] = implode("\n", $groupStrings);
} else {
$folder['groups'] = [];
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
$folder['groups'] = [];
$folder['groups'] = '';


use OC\Files\Cache\CacheEntry;

class Folder {
Copy link
Contributor

Choose a reason for hiding this comment

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

Avoid using the same name as core classes, it’s confusing when the class is imported with a use statement.

Copy link
Member Author

Choose a reason for hiding this comment

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

But Groupfolder is also not a good name. Would InternalFolder be better as it is only used as an internal type between different methods?

Copy link
Contributor

Choose a reason for hiding this comment

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

As said below this should be in Db and be an entity with a mapper ideally.
I do think Groupfolder is closer to what it is than Folder.
Could be FolderDefinition or FolderSettings if that makes sense?

$folderMap[$id] = [
$applicables = $applicableMap[$id] ?? [];
if (empty($applicables)) {
$applicables = new stdClass();
Copy link
Contributor

Choose a reason for hiding this comment

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

This is a controller specific thing that ends up in the manager, is there no way to avoid that?


namespace OCA\GroupFolders\Folder;

class FolderMapping {
Copy link
Contributor

Choose a reason for hiding this comment

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

These classes should actually be entities with mappers, no?

Copy link
Member Author

Choose a reason for hiding this comment

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

I guess so. I only made this change from array to class last minute, so I didn't give it much thought.

Signed-off-by: provokateurin <kate@provokateurin.de>
@provokateurin
Copy link
Member Author

I will try to extract some of the changes into separate PRs to get them merged first and then come back to this PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3. to review Items that need to be reviewed enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Replace broken REST API documentation with OpenAPI
3 participants