Federated Repositories
In a federated setup, contracts/specifications are distributed across multiple contract-only repositories instead of one central contract repository.
These repositories still contain contracts/specifications only. The difference is that they are split across multiple repositories, for example by domain, department, or business unit.
Federated Repositories Example
In this example, we will use:
Contract Repositories
payments-contractsstores payment-domain contracts/specificationsorders-contractsstores order-domain contracts/specifications
Service Repositories
payment-serviceprovides its contract frompayments-contractsorder-serviceprovides its own contract fromorders-contracts, and in this example it consumes the sharedpayment-servicecontract frompayments-contracts
payments-contracts
The payments-contracts repository stores the shared contracts/specifications for the payments domain.
For this example, the relevant contract/specification is:
contracts/services/payment-service/http/openapi.yaml
orders-contracts
The orders-contracts repository stores the shared contracts/specifications for the orders domain.
For this example, the relevant contract/specification is:
contracts/services/order-service/http/openapi.yaml
payment-service
payment-service is the provider in this example.
Its specmatic.yaml points to the payments-contracts repository for its own contract/specification:
systemUnderTest:
service:
$ref: "#/components/services/paymentService"
components:
sources:
paymentsContracts:
git:
url: https://github.com/example/payments-contracts
services:
paymentService:
definitions:
- definition:
source:
$ref: "#/components/sources/paymentsContracts"
specs:
- spec:
path: "contracts/services/payment-service/http/openapi.yaml"
order-service
order-service is also a provider, but in this example we are looking at it as a consumer of the shared payment-service contract from payments-contracts.
Its specmatic.yaml points to:
orders-contractsfor its ownorder-servicecontract/specificationpayments-contractsfor the sharedpayment-servicecontract/specification
systemUnderTest:
service:
$ref: "#/components/services/orderService"
dependencies:
services:
- service:
$ref: "#/components/services/paymentService"
components:
sources:
ordersContracts:
git:
url: https://github.com/example/orders-contracts
paymentsContracts:
git:
url: https://github.com/example/payments-contracts
services:
orderService:
definitions:
- definition:
source:
$ref: "#/components/sources/ordersContracts"
specs:
- spec:
path: "contracts/services/order-service/http/openapi.yaml"
paymentService:
definitions:
- definition:
source:
$ref: "#/components/sources/paymentsContracts"
specs:
- spec:
path: "contracts/services/payment-service/http/openapi.yaml"
To learn more about specmatic.yaml, see Specmatic configuration.
Repository flow
The repository flow in the federated model is similar to Central Contract Repository.
The main differences are:
- run the central contract repo report flow separately for each federated contract repository
- service repositories may point to one or more federated contract repositories, depending on how contracts/specifications are split
CI Workflows
PR Process
Pull requests on each federated contract repository should run the usual pre-merge checks for contracts/specifications before they are merged.
To learn more about the shared PR process for contract repositories, see PR Process.
Posting reports to Insights
Publish reports to Insights only from workflows that run on push or merge to main.
Federated contract repository workflow
The federated contract repository workflow is the same as in Central Contract Repository.
In the federated model, run that workflow for each federated contract repository.
Service repository workflow
The service repository workflow in the federated model is the same as in Central Contract Repository.
How this will look in Insights
Insights processes federated contract repositories in the same way as a Central Contract Repository, but instead of one shared central contract repository, it will show one Spec Repository block per federated contract repository.
In this example, you will see two Spec Repository blocks:
order-contractspayment-contracts
order-contracts Spec Repository block
The following snapshot shows the order-contracts repository in Insights:

In this view:
- the
Spec Repositoryblock comes from theorder-contractscentral contract repo report - the block lists the contracts/specifications stored in
order-contracts, such ascontracts/services/order-service/http/openapi.yaml order-serviceappears in the center because it provides theorder-servicecontract/specification fromorder-contracts- there are no consumers shown on the left-hand side for this contract/specification
payment-serviceappears on the right-hand side becauseorder-serviceconsumes that dependency
payment-contracts Spec Repository block
The following snapshot shows the payment-contracts repository in Insights:

In this view:
- the
Spec Repositoryblock comes from thepayment-contractscentral contract repo report - the block lists the contracts/specifications stored in
payment-contracts, such ascontracts/services/payment-service/http/openapi.yaml payment-serviceappears in the center because it provides thepayment-servicecontract/specification frompayment-contractsorder-serviceappears on the left-hand side because it consumes the sharedpayment-servicecontract/specification frompayment-contracts- there are no dependencies shown on the right-hand side for this contract/specification
Troubleshooting
Troubleshooting in the federated model is similar to Central Contract Repository.
The main differences are:
- make sure the relevant central contract repo report was generated from the correct federated contract repository and posted to Insights
- make sure the provider or consumer repository points to the correct spec path in the correct federated contract repository