lorawan-stack icon indicating copy to clipboard operation
lorawan-stack copied to clipboard

Code generation for calling API endpoints

Open johanstokking opened this issue 6 years ago • 9 comments

Summary: Currently, api methods for the http connector in the js-sdk are generated at runtime from a json schema that contains all api defintions.

What is already there? What do you see now? All api methods are generated at runtime when the main instance gets instantiated on the client. The api-defintions.json gets parsed and for each entry a method is created in the api module.

What is missing? What do you want to see? A set of generated es6 methods (during build) that will delegate all api calls to axios and can be published within the sdk, without the need to include redundant json files and generate the methods at runtime.

This shouldnt be too hard, since all methods have the same structure, only the arguments differ.

Worth noting, that the current implementation should stay until the draft sdk is finished, as well as the backend api, and can be tested.


Original issue: https://github.com/TheThingsIndustries/lorawan-stack/issues/1137 by @bafonins

johanstokking avatar Jan 29 '19 18:01 johanstokking

Please discuss relevance for Next Up

johanstokking avatar Mar 04 '19 14:03 johanstokking

I think we should look into resolving this in the near future.

kschiffer avatar Aug 13 '19 15:08 kschiffer

We dont need to change the current api of the stack in order to implement this. We can generate api methods for the js sdk using the swagger schema that is produced by grpc-gateway.

bafonins avatar Apr 06 '20 11:04 bafonins

Also, references https://github.com/TheThingsNetwork/lorawan-stack/issues/1982. no api changes required as well

bafonins avatar Apr 06 '20 11:04 bafonins

update on this. I have a working utility that can generate API functions from the swagger schema using babel. However, I would like to check if we can use grpc directly.

bafonins avatar Jul 04 '20 11:07 bafonins

I have tried that in the past. The best way (at the time) was https://github.com/improbable-eng/grpc-web

htdvisser avatar Jul 06 '20 07:07 htdvisser

See #2298 for an open issue with Swagger also

johanstokking avatar Jul 06 '20 15:07 johanstokking

FYI https://github.com/grpc/grpc-web is supported by https://github.com/TheThingsIndustries/docker-protobuf Not sure what's the difference from improbable-eng one and if it's related at all

rvolosatovs avatar Jul 10 '20 17:07 rvolosatovs

Moving to Next up since this doesnt cause any problems with the current setup and there are issues with higher priority to work on.

bafonins avatar Oct 13 '20 12:10 bafonins