reljicb
reljicb

Reputation: 91

Java: Consumer-Driven Contracts for non-RESTful APIs

I would like to implement consumer-driven contracts in my Spring Boot micro-services.

However, not all services are RESTful. Some of them use proprietary communication protocols. Some of them do not have Java API implemented by me. For all these service, I have written a "java client" library, which I include in the consumers as a dependency, and that way I aid integration.

Could you please tell me if there exists an extension to Spring Cloud Contract, or an alternative Java implementation of Consumer-Driven Contracts which have stub and tests generation for POJO classes or Spring Boot services out of the contract, the same way this is done for the RESTful APIs?

Upvotes: 0

Views: 276

Answers (1)

Marcin Grzejszczak
Marcin Grzejszczak

Reputation: 11149

What you can do is call the API via a proxy and generate stubs of it. You can check out an example of such a flow here https://github.com/marcingrzejszczak/the-legacy-app/tree/master/stubs_with_proxy/

With such an approach, your communication with the service you don't own will be recorded and can be later reused as a stub.

Upvotes: 1

Related Questions