Preferred REST client

Hi all,
if I plan to develop a binding for a specific web server that exposes structured responses and translate it into a channels of a specific thing type is there any preferred REST client to use?
Or maybe some AbstractRESTBinding that may reuse existing functionality for the web calls and the JSON/XML response to Java object mapping?

I know that maybe I can use the HTTP binding and do a JSONPath transformation instead of developing additional binding but I wonder if developers who are using REST are using something already pre-defined in the core-code as a base for such use cases…


Do you have an openAPI descriptor? If so - generate code using java 11 http client and jackson. Java 11 is default for openHAB (no more support for 8) hence you can save a lot of extra dependencies since you use standard library + jackson which is included in default distro.

You can try to generate a jaxrs client stub from openAPI but I never really succeeded with deployment of it. An alternative way could be manual writing of client interface and construction of a client stub through ClientBuilder or something. Sadly there is not too much of “blueprints” for cloud integrations hence you have to dig and find your own way. Depending on the complexity of interface you have to integrate - try to avoid playing with http client directly. It will force you to produce absurd amounts of code which noone wants to maintain. :wink:

Recently I worked on a binding which I wanted to keep as compact as possible with all above points included. You can have a look on it here: org.connectorio.addons.binding.smartme (its a third party addon).
While its not something “approved” to come into official distro (see, there is no clear guideline for REST/http integrations, each binding does it in maybe standard, but usual an own way), I plan to port all my http bindings to rely on such way, so long term I will be able to throw away all http client libraries which take a lot of space. :wink:


1 Like