spring-cloud / spring-cloud-contract

Support for Consumer Driven Contracts in Spring
https://cloud.spring.io/spring-cloud-contract
Apache License 2.0
720 stars 439 forks source link

Spring Cloud Contract: common repository for all microservices #1777

Closed mpssantos closed 2 years ago

mpssantos commented 2 years ago

I am working on a microservice architecture system. I would like to setup a common repository with all the contracts of our microservices, using a consumer driven approach. I am taking this sample as an example:

https://github.com/spring-cloud/spring-cloud-contract/tree/main/samples/standalone/contracts

No problems setting up a test on the consumer side.

But while setting up the producer to get the contracts, I realized that the contracts-0.0.1-SNAPSHOT.jar contains all the contacts of all producers in the contracts project. This sample project sample is simple and only contains one producer: com.example:server.

What happens when more producers contracts are added like com.example:my-super-service? From what i understood, contracts-0.0.1-SNAPSHOT.jar will contain all the contracts for both serverand my-super-service applications.

Does it make sense all producers get all universe of contracts by the means of this jar? How can we restrict the installed contracts to be to the service in question? for instance com.example:my-super-service only to see its respective contracts? Or this repo was tough to be on a per producer basis?

What solution would you advise?

Thank you so much for your help

mpssantos commented 2 years ago

Apparently, if more than 1 producers are defined on the contracts project, in the producer, it resolves only the contracts of the directory matching its groupid:artifact id. Is this correct?

marcingrzejszczak commented 2 years ago

Yeah I mean it will have to find the contracts for a particular producer in order to generate tests for that producer. Would you expect this to work in a different way?

mpssantos commented 2 years ago

Yes, this is the expected behavior. I was having issues setting up the project, but after i setup properly the producer, i noticed that it only download the contracts from the the directory that match the structure of its group-id and artifact-id.

Thank you very much for your support, and congratulations for you awesome job with this project. Thanks a mil.