In my client code, I use json schemas to validate json responses (using ajv). I am planning to use pact-js to generate pacts to run against the provider for contract testing.
I would like a single source of truth for the schema that my client code uses during runtime validation and that the contract tests use during pact verification. Is there a way to generate json (or swagger) schemas from the pact file, or alternatively is there a library which uses the pact file itself for runtime validation of individual http responses (as opposed to just being used for contract verifications in contract tests)?
I realize this is a bit of a chicken and egg problem because I would need to first run the client code as part of a test run to generate the pacts (and in turn the json schema), so I would have to figure out a good work flow for that.
I also realize that contract tests should reduce the need for runtime validation, but contract testing is still not comprehensive enough to catch all real world scenarios.