https://pact.io logo
#general
Title
# general
a

Allen

04/04/2022, 4:39 AM
Hi everyone, just a question is this possible to generate open api based on pact contract? If so, could someone share me a link to find how does it work?
m

Matt (pactflow.io / pact-js / pact-go)

04/04/2022, 4:40 AM
Hi Allen, I believe there might be converters somewhere
what are you trying to do?
a

Allen

04/04/2022, 4:43 AM
Yep. I try to use pact to generate open api and then generate types for client side such as TS? Does this make sense? Please let me know if this is too crazy idea
m

Matt (pactflow.io / pact-js / pact-go)

04/04/2022, 4:46 AM
No this doesn’t make sense at all to me, sorry 🙂
The workflow would be: 1. Client generates pact file (which requires a working API client) 2. Convert Pact to an OAS 3. Generate API Client from OAS you can see how this is nonsensical
a

Allen

04/04/2022, 4:49 AM
cos i know 3 is absolutely doable
but I try to avoid to manually create both OAS and pact testing file. I feel like somehow they’re kind of duplication. My understanding is that OAS is abstract and pact testing file is more like a concrete example of OAS.
m

Matt (pactflow.io / pact-js / pact-go)

04/04/2022, 4:51 AM
yes, but if you already have a pact file, then you already have a working client. So why do 2 and 3 if you already have one?
a

Allen

04/04/2022, 4:54 AM
Right. If you notice, API Client is manually typed as well without 2 and 3. But I hope I can get an auto-generated API Client.
m

Matt (pactflow.io / pact-js / pact-go)

04/04/2022, 4:56 AM
So it’s up to you if you want to have a typed API client generated from an OAS
1
you might like to read https://pactflow.io/blog/schemas-are-not-contracts/ for the downsides of this approach, from a contract testing perspective
a

Allen

04/04/2022, 4:57 AM
will do. Many thanks
👍 1
Hi @Matt (pactflow.io / pact-js / pact-go), By looking at this, what do you mean by
pack + open api
? just wondering where i can find more details?
👍 1
I guess this is the one - https://pactflow.io/blog/introducing-bi-directional-contract-testing/. If so, this looks like the similar idea from

https://www.youtube.com/watch?v=-6x6XBDf9sQ

m

Matt (pactflow.io / pact-js / pact-go)

04/04/2022, 7:17 AM
Yes, the core idea is identical. We wrap up that idea (and currently, even some of their tooling) into a unified workflow. so you can do it with Pact or future contract types (e.g. protobufs, graphql etc.)
1
a

Allen

04/05/2022, 1:47 PM
nice work
3 Views