Skip to content

Instantly share code, notes, and snippets.

@ian-ellis
Created March 23, 2017 01:52
Show Gist options
  • Save ian-ellis/4a67cae80aac9e2230086a6deda9c9ef to your computer and use it in GitHub Desktop.
Save ian-ellis/4a67cae80aac9e2230086a6deda9c9ef to your computer and use it in GitHub Desktop.
V2 Pact Matcher
{
"description": "A request for products",
"request": {
"method": "GET",
"path": "/catalog/products",
"headers": {
"Accept": "application/json"
},
"query": "gender=male"
},
"response": {
"status": 200,
"headers": {
"Content-Type": "application/hal+json"
},
"body": {
"_embedded": {
"product": [
{
"_embedded": {
"brand": {
"id": 1234,
"name": "Awesome Brand",
"url_key": "awesome"
},
"gender": {
"id": 15,
"name": "male"
},
"images": [
{
"url": "http://static.theiconic.com.au/p/fresh-soul-1697-864712-1.jpg"
}
],
"shops": [
{
"is_default": false,
"name": "sports"
}
]
},
"link": "Alaska-Coat-217468.html",
"name": "Alaska Coat",
"price": 169.95,
"ribbon": "new",
"short_description": "A product description",
"sku": "FR760AA31JSE",
"special_price": 4853133752
},
{
"_embedded": {
"brand": {
"id": 1234,
"name": "Awesome Brand",
"url_key": "awesome"
},
"gender": {
"id": 15,
"name": "male"
},
"images": [
{
"url": "http://static.theiconic.com.au/p/fresh-soul-1697-864712-1.jpg"
}
],
"shops": [
{
"is_default": false,
"name": "sports"
}
]
},
"link": "Alaska-Coat-217468.html",
"name": "Alaska Coat",
"price": 169.95,
"ribbon": "new",
"short_description": "A product description",
"sku": "FR760AA31JSE",
"special_price": 7758240886
}
]
},
"_links": {
"self": {
"href": "http://eve.theiconic.com.au/v1/catalog/products?page=1"
}
},
"page_count": 1,
"page_size": 24,
"total_items": 2
},
"matchingRules": {
"$.body._embedded.product": {
"min": 1,
"match": "type"
},
"$.body._embedded.product[*].sku": {
"match": "type"
},
"$.body._embedded.product[*].name": {
"match": "type"
},
"$.body._embedded.product[*].ribbon": {
"match": "type"
},
"$.body._embedded.product[*].short_description": {
"match": "type"
},
"$.body._embedded.product[*].price": {
"match": "number"
},
"$.body._embedded.product[*].special_price": {
"match": "number"
},
"$.body._embedded.product[*].link": {
"match": "type"
},
"$.body._embedded.product[*]._embedded.brand.id": {
"match": "integer"
},
"$.body._embedded.product[*]._embedded.brand.url_key": {
"match": "type"
},
"$.body._embedded.product[*]._embedded.brand.name": {
"match": "type"
},
"$.body._embedded.product[*]._embedded.gender.id": {
"match": "integer"
},
"$.body._embedded.product[*]._embedded.gender.name": {
"match": "regex",
"regex": "male|female|unisex"
},
"$.body._embedded.product[*]._embedded.shops": {
"min": 1,
"match": "type"
},
"$.body._embedded.product[*]._embedded.shops[*].name": {
"match": "type"
},
"$.body._embedded.product[*]._embedded.images": {
"min": 1,
"match": "type"
},
"$.body._embedded.product[*]._embedded.images[*].url": {
"match": "type"
},
"$.body._links.self.href": {
"match": "type"
},
"$.body.page_count": {
"match": "type"
},
"$.body.page_size": {
"match": "type"
},
"$.body.total_items": {
"match": "type"
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment