API Hub for Contract Testing
API Hub for Design now supports contract testing with API Hub for Contract Testing's Bi-Directional Contract Testing feature. API designers and developers can use it 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, your account must be set up with the correct role inAPI Hub for Contract Testing, as described in the Setting up your API Hub for Contract Testing account for use with API Hub for Design documentation.
Setup
To set up contract checking for an API, use the button at the top of the editing pane for the API definition file, as shown below.
The first time you use API Hub for Contract Testing with your API, hover over the button and click Set up Integration.
The Manage Integrations screen will appear.
From the setup dialog, you must specify:
Name – a name for this integration.
PactFlow Base URL – API Hub for Contract Testing Base URL. This can be retrieved from API Hub for Contract Testing with the command Settings > API Tokens > Copy API Hub for Contract Testing Base URL.
Read/Write Token – the read/write authentication token for your API Hub for Contract Testing account. This can be retrieved from API Hub for Contract Testing with the command Settings > API Tokens > Read/write token > Copy.
Once you have entered these values, click Next and API Hub for Design will retrieve the available applications (as defined in API Hub for Contract Testing). You can then choose the desired option from the Applications dropdown list.
Once the setup is complete, click Create to save your API Hub for Contract Testing settings.
Compatibility
Once you have set up API Hub for Contract Testing, hover over the 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 button will turn green, Compatible will display in the dialog, and you can click View Compatibility Check Result to see the details.
Note
API Hub for Design coordinates with API Hub for Contract Testing when compatibility is checked to discover all known consumers of the current application (providers in API Hub for Contract Testing terminology). This process is called "cross-contract validation" or simply "contract comparison". For more information on selectors, consult the API Hub for Contract Testing documentation.
If there is an error, the button will turn red. Some details of the problems are provided within API Hub for Design and you can also go to your API Hub for Contract Testing account to determine additional details.
Note that contract testing will not be performed automatically. You must save your file and use the button to run your test.