This is an interesting and somewhat subtle point 😅
We don't currently have a programmatic adapter to convert Zod schemas to Pact matchers, though it’s certainly feasible. I’ve seen similar adapters built for libraries like TypeBox; however, there is a risk in doing so that's worth highlighting:
You can quickly devolve from contract testing to schema testing.
The core value of Pact is that it is consumer-driven: the consumers should only define the specific fields they actually "consume" to provide the provider with maximum flexibility. If you blindly reuse the full Zod schema, you inadvertently turn our contract tests into Schema Tests.
Say for example your schema contains 20 fields, but your consumer only uses 2 of them. If you blindly use the full schema, your provider will think that all 20 fields are required.
This can be an issue for example if you are looking to deprecate a field. If the consumer defines their needs precisely, the Provider can see that no one is using the old field and safely remove it. If the consumer blindly uses the Zod schema (which includes the deprecated field), the can-i-deploy check will fail, blocking the Provider from cleaning up their API even if the consumer doesn't actually need that data.
So ultimately, while we are tempted to keep everything DRY, the duplication here can be good, and act as a buffer to ensure that the Consumer is only asserting what they strictly require.
A possible use-case here could be if the consumer is maintaining their own Zod schema that is strictly what they need (as opposed to, for example, a shared package containing the fully schema). In that case, you might benefit from a Zod-to-Pact adapter 🙂