Contract Testing: Generate Pact Tests
contract-testing_generate_pact_testsGenerate Pact contract tests from API request/response pairs, source code, or OpenAPI specs. AI analyzes inputs to produce consumer-driven contract tests for reliable API integration.
Instructions
Generate Pact tests using PactFlow AI. You can provide one or more of the following input types: (1) request/response pairs for specific interactions, (2) code files to analyze and extract interactions from, and/or (3) OpenAPI document to generate tests for specific endpoints. When providing an OpenAPI document, a matcher is required to specify which endpoints to generate tests for.
Toolset: Generate Pact Tests
Parameters:
language (enum): Target language for the generated Pact tests. If not provided, will be inferred from other inputs.
requestResponse (object): Direct request/response pair for a specific interaction. Use this when you have concrete examples of API requests and responses
code (array): Collection of source code files to analyze and extract API interactions from. Include client code, data models, existing tests, or any code that makes API calls
openapi (any)
additionalInstructions (string): Optional free-form instructions to guide the generation process (e.g., 'Focus on error scenarios', 'Include authentication headers', 'Use specific test framework patterns')
testTemplate (object): Optional test template to use as a basis for generation. Helps ensure generated tests follow your specific patterns, frameworks, and coding standards
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| code | No | Collection of source code files to analyze and extract API interactions from. Include client code, data models, existing tests, or any code that makes API calls | |
| openapi | No | If provided, the OpenAPI document which describes the API being tested and is accompanied by a matcher which will be used to identify the interactions in the OpenAPI document which are relevant to the Pact refinement process. | |
| language | No | Target language for the generated Pact tests. If not provided, will be inferred from other inputs. | |
| testTemplate | No | Optional test template to use as a basis for generation. Helps ensure generated tests follow your specific patterns, frameworks, and coding standards | |
| requestResponse | No | Direct request/response pair for a specific interaction. Use this when you have concrete examples of API requests and responses | |
| additionalInstructions | No | Optional free-form instructions to guide the generation process (e.g., 'Focus on error scenarios', 'Include authentication headers', 'Use specific test framework patterns') |