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

How do I generate a dart client for custom nextcloud app? #2202

Closed
samolego opened this issue Jun 25, 2024 · 9 comments
Closed

How do I generate a dart client for custom nextcloud app? #2202

samolego opened this issue Jun 25, 2024 · 9 comments

Comments

@samolego
Copy link

Are there any guides on this? I'd like to generate a dart client from an existing nextcloud app - is that possible?

@provokateurin
Copy link
Member

Hi, this is only possible if you have an OpenAPI specification for it. Which app are you trying to use?

@samolego
Copy link
Author

Ah, ok. This one: https://memories.gallery/

@provokateurin
Copy link
Member

It doesn't look like it has one available, but you could generated one using https://github.com/nextcloud/openapi-extractor. It requires some work in the app though, as you need to add annotations for every endpoint.

Alternatively you could write an OpenAPI specification by hand, but we will not add it to the official package due to quality and maintainability concerns.

What is your use-case for a memories API client?

@samolego
Copy link
Author

samolego commented Jun 25, 2024

I'd like to try create a native flutter app, as the default memories one is a bit slow on mobile devices.

Thanks for the info :)

@provokateurin
Copy link
Member

We also have plans to implement a Photos app that can also work with Memories as a backend (#355), so you might want to consider using our framework for building your app.
For a prototype it would be fine to use a hand-written specification, see the discussion in #944 for reference.

@samolego
Copy link
Author

Ok, thanks!

@samolego
Copy link
Author

Sorry to bother again, I've generated a openapi.yaml from observing the traffic.
Do I have to use dynamite package now?

@provokateurin
Copy link
Member

provokateurin commented Jun 25, 2024

Yes! You should drop the file into packages/nextcloud/lib/src/api and name it memories.openapi.yaml. Then you can run the generate script using ./tool/generate-nextcloud.sh (from the root of the project). Afterwards you should have 3 new dart files.

What tool did you use to generated the specification? I wasn't aware something like that exists.

@samolego
Copy link
Author

Well, I navigated around the app, used firefox's save traffic to har file, then used https://github.com/jonluca/har-to-openapi to convert har to openapi.yml.

Not sure if it's correct, first time doing 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