Hi Team I want to generate PACT Json files directl...
# general
p
Hi Team I want to generate PACT Json files directly from Swagger Json files using Java. Do we have any existing java based solution for this ?
y
Its not really a done thing, because an OpenAPI definition describes how a service should work, and provides examples of how it may be interacted with and what responses it may provide but doesn’t correlate to your actual consumers usage, which is what the pact file captures as part of the consumer contract test What use case are you trying to fulfil?
☝️ 1
m
Just on mobile, but search docs.pact.io for swagger. There's a discussion there
b
In all honesty, I think this is a big, big, BIG no-go. You want your consumer contracts to express how your customers consume your service and what they expect. Not how the service actually responds. The discrepancy between those two is exactly what contract testing attempts to bring to the surface. Generating consumer contracts from provider specifications completely erases that. There might be a case for generating provider-side acceptance tests from specs (and even that is questionable in my opinion), but I really, really would advise against doing this in contract testing.
☝️ 2
m
Nailed it Bas!