-
Notifications
You must be signed in to change notification settings - Fork 302
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
Publish clean API protos #2297
Comments
It seems like a workaround would be to generate the go model from the swagger definition:
This however feels counter intuitive, unless the swagger definition is the primary definition and not the proto files. |
Thanks for the report. Indeed, the proto files in We have some ideas to generate clean protos which would go to a separate repository. Indeed, we have the Swagger which should act as a reference. So we technically publish the API definitions that way; I'll keep this issue open until we have clean protos. |
…ge/open-source
Still running into this same issue. Trying to add V3 webhook support to my systems, I'm struggling to find a definitive protocol specification of how the json I will receive should look. The definition should be https://github.com/TheThingsNetwork/lorawan-stack/blob/v3.13/api/messages.proto. I however haven't been successful in building these protos yet. Current issue is:
|
I believe I have this working in go. It needs a couple of workaround steps though. Inside go.mod add
We need to update the grpc-gateway version.
After these additions I can do something like this to parse json being POSTed to me with the webhook integration.
TODO: Maybe it is now trivial to switch to protobufs for the webhook integrations to save bandwidth? |
Use
Yes. And you can support either by checking the request's BTW, this issue is about publishing clean protos, that is, |
Thanks, that is all very useful recommendations. Indeed we are getting a bit off-topic here, and the end goal of this issue is indeed to have proto files I can compile to any language. I've tried doing that myself before (TheThingsArchive/api#43) but ran into some dependency hell. Back then I decided to rather use the swagger file to generate my models, which also didn't work correctly. Publishing clean protos (I guess without gogo) which can be easily compile will hopefully make it easier. I just stumbled upon https://github.com/TheThingsIndustries/docker-protobuf. Is this the same as https://github.com/TheThingsNetwork/api but for TTS v3? In that case, does this repo solve this issue? I guess not really. What I'd like to have is a way to make sure my API endpoint is always up to date with the protocol the webhook template sends to me. Using a Go module works for now, as I can update the vendors easily to the latest version. Protos that I include and compile each time will however be more generic. |
Yes it is, but we are phasing this out as part of moving away from gogo. We will need a reproducable way to compile protos, and a Docker image is very useful for that, but this particular image is very opinionated and contains lots of magic with proto options.
Indeed. They will be more generic, but that is also where we are moving with The Things Stack. In any case, we guarantee that the protos and the JSON stay compatible in all future versions of V3. So if it works now with loading TTS as a module (the hardest way), it will work with we moved away from gogo (easier already because more updated dependencies, less downgrades etc), and also when we publish clean protos that you can compile yourself, and even with the Swagger file that we will also have at some point. |
Removing my assignment and bumping back to triage for re-assignment (cc: @NicolasMrad). Maybe this should be merged into a new "SDK" umbrella issue? |
We are one big step closer to this with #5986 |
@jpmeijers we made some progress on this again: #6449. We're now publishing clean protos to Buf: https://buf.build/thethingsnetwork/lorawan-stack. This allows you to generate code using For Go, Node, Java and Swift, Buf also generates them on the fly, e.g. This issue can now be closed. We are also planning a SDKs: packages and modules that include generated protos as well as some helpers around allowed field masks per backend component, device creation on IS/NS/AS/JS with rollback, device claiming with rollback, etc. That is outside the scope of this issue. |
Summary
DEVELOPMENT.md describes how one can generate the API definitions for JavaScript. It however does not describe how to do this for other languages. Due to external dependencies in the proto files they can't simply be compiled by protoc to any language one wants.
It would be great if the proto files did not have any foreign dependencies so that one can simply compile them into the language you want.
On TTNv2 if you wanted golang type struct definitions you could simple copy them from the repo here: https://github.com/TheThingsNetwork/ttn/tree/develop/core/types
This is not the case with V3.
Why do we need this?
Allow building services where the webhooks can send data, being able to parse the messages correctly according to the central definition (proto file).
What is already there? What do you see now?
The proto files are there, and I see a command to run to give me api definitions for Javascript, not other languages.
What is missing? What do you want to see?
A generic way to compile the proto files into any supported language. I also want type definitions for go, but if the protos can compile I can compile it to go myself.
Environment
N/A
How do you propose to implement this?
Clean up the proto definitions in the api directory so that they do not depend on foreign dependencies, OR document how one can compile them for any supported language, not just JS.
Can you do this yourself and submit a Pull Request?
Been trying to figure this out, but because the tooling uses mage, and a lot of custom build scripts were written to compile the codebase and to export the JS definitions, this is rather complicated to understand.
The text was updated successfully, but these errors were encountered: