Skip to content

Instantly share code, notes, and snippets.

@absent1706
Last active February 17, 2022 12:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save absent1706/7fa781db7c62ee054d706d9df12e0c59 to your computer and use it in GitHub Desktop.
Save absent1706/7fa781db7c62ee054d706d9df12e0c59 to your computer and use it in GitHub Desktop.
Pact contract example
{
"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