PactFlow Contract Testing

Availability: Enterprise, Team, and Trial plans

SwaggerHub now supports contract testing with PactFlow's Bi-Directional Contract Testing feature. API designers and developers can use PactFlow to ensure that changes to their API will not break applications and can be deployed confidently. This is available for:

  • Private APIs

  • OpenAPI 2.0/3.0 API definitions

To perform contract testing with PactFlow, you must first set up an account at PactFlow. Your account must be set up with the correct role, as described in the Setting up your PactFlow account for use with SwaggerHub documentation.

A Video Introduction


Setting up PactFlow

To set up contract checking for an API, use the pactflow-button.png button at the top of the editing pane for the API definition file, as shown below.


The first time you use PactFlow with your API, hover over the pactflow-button.png button and click Set up Integration.


Choose PactFlow from the pulldown of possible integration types.


The Manage Integrations screen will appear.


From the setup dialog, you must specify:

  • Name – a name for this integration

  • URL – PactFlow Base URL. This can be retrieved from PactFlow with the command Settings > API Tokens > Copy PactFlow Base URL.

  • PactFlow Token – the read/write authentication token for your PactFlow account. This can be retrieved from PactFlow with the command Settings > API Tokens > Read/write token > Copy.

Once you have entered these values, click Next and SwaggerHub will retrieve the available applications (as defined in PactFlow). You can then choose the desired application from the pulldown list.


Once the setup is complete, click CREATE to save your PactFlow settings.

Checking Compatibility

Once you have set up PactFlow, hover over the pactflow-button.png button and click on Check Compatibility to verify that the API is compatible with its consumers. Compatibility is checked across all application consumers on the main branch and those that have been deployed or released. If your API is compatible with its consumers, the pactflow-button.png button will turn green, Compatible will display in the dialog, and you can click View Compatibility Check Result to see the details.



SwaggerHub coordinates with PactFlow when compatibility is checkedto discover all known consumers of the current application (providers in PactFlow terminology). This process is called "cross-contract validation" or simply "contract comparison". For more information on selectors, consult the PactFlow documentation.

If there is an error, the pactflow-button.png button will turn red. Some details of the problem(s) are provided within SwaggerHub and you can also go to your PactFlow account to determine additional details.


Note that contract testing will not be performed automatically. You must save your file and use the pactflow-button.png button to run your test.

See Also

Publication date: