Last active
February 17, 2022 12:27
-
-
Save absent1706/7fa781db7c62ee054d706d9df12e0c59 to your computer and use it in GitHub Desktop.
Pact contract example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"consumer": { | |
"name": "OrderService" | |
}, | |
"provider": { | |
"name": "UserService" | |
}, | |
"interactions": [ | |
{ | |
"description": "GetUser API call for UserA", | |
"providerState": "UserA exists", | |
"request": { | |
"method": "get", | |
"path": "/users/UserA" | |
}, | |
"response": { | |
"status": 200, | |
"headers": { | |
}, | |
"body": { | |
"name": "UserA", | |
"id": "fc763eba-0905-41c5-a27f-3934ab26786c", | |
"created_on": "2016-12-15T20:16:01", | |
"ip_address": "127.0.0.1", | |
"admin": false | |
}, | |
"matchingRules": { | |
"$.body": { | |
"match": "type" | |
}, | |
"$.body.id": { | |
"match": "regex", | |
"regex": "[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}" | |
}, | |
"$.body.created_on": { | |
"match": "regex", | |
"regex": "\\d+-\\d+-\\d+T\\d+:\\d+:\\d+" | |
}, | |
"$.body.ip_address": { | |
"match": "regex", | |
"regex": "(\\d{1,3}\\.)+\\d{1,3}" | |
} | |
} | |
} | |
} | |
], | |
"metadata": { | |
"pactSpecification": { | |
"version": "2.0.0" | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment