Replies: 2 comments
-
|
To further simplify the DSL, we could consider making the explicit default values (= "...") optional. Instead, a Wirespec-to-Pact generator could automatically create example values using a seeded reverse regex generator (rgxgen). This approach removes the burden of manually defining and maintaining examples, while guaranteeing the example always matches its own validation rule. Using a consistent seed ensures deterministic output, which is crucial for stable contract tests across consumer and provider builds. The Flock community's kotlin-rgxgen is a great proof-of-concept for this capability. It would make the Wirespec definitions even more concise and robust. |
Beta Was this translation helpful? Give feedback.
-
|
Thanks for raising this and fleshing it out. I'll aim to come back next week with some further thoughts, but wanted to "ack" this for now. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
As a follow up on a discussion on slack we start this discusion to see what the potential is to use Wirespec as a Domain Specific language to define Pact contracts.
Wirespec envisions a contract-first approach using simple, human-readable specifications. By acting as the single source of truth and generating aligned code for both producers and consumers, it prevents errors before development even begins.
This design-first methodology is a perfect match for Pact. While Wirespec defines the contract upfront, PactFlow continuously verifies that implementations never break it in a live CI/CD environment. Together, they create a powerful end-to-end workflow, reducing integration errors and providing unparalleled confidence in your APIs.
The Challenge: The Missing Link for Pact Compatibility
Currently, Wirespec excels at defining the shape and type of data in a contract (e.g., a userId is a String, a createdAt is a String with a date-time format). However, to generate a valid Pact contract, we need to provide two additional pieces of information that are central to how Pact works:
To bridge this gap, we propose extending the Wirespec DSL to incorporate these two concepts directly into the contract definition.
Proposed Solution: Extending the Wirespec DSL
We propose to solve this gap by enhancing Wirespec's core type system. The proposal is to allow refinement of primitive types, baking the validation rules directly into the type definitions. Also define defaults for the values direct in het type system.
This syntax elegantly solves the matcher requirement. A Wirespec-to-Pact generator can directly map these refined types to Pact's matching rules.
Example
This shows how the wirespec dsl would translate to the Pact JS DSL
Beta Was this translation helpful? Give feedback.
All reactions