{
"consumer": {
"name": "MyConsumer"
},
"interactions": [
{
"description": "a request for all urls",
"key": "285dde1d2816ddad",
"pending": false,
"providerStates": [
{
"name": "I have a list of urls"
}
],
"request": {
"headers": {
"Accept": [
"application/json"
]
},
"method": "GET",
"path": "/urls"
},
"response": {
"body": {
"content": {
"urls": [
{
"url": "http://localhost:8080/example/path"
}
]
},
"contentType": "application/json",
"encoded": false
},
"generators": {
"body": {
"$.urls[*].url": {
"example": "http://localhost:8080/example/path",
"regex": ".*(\\/example/path)$",
"type": "MockServerURL"
}
}
},
"headers": {
"Content-Type": [
"application/json"
]
},
"matchingRules": {
"body": {
"$.urls": {
"combine": "AND",
"matchers": [
{
"match": "type",
"min": 1
}
]
},
"$.urls[*].url": {
"combine": "AND",
"matchers": [
{
"match": "regex",
"regex": ".*(\\/example/path)$"
}
]
}
},
"header": {}
},
"status": 200
},
"type": "Synchronous/HTTP"
},
{
"description": "a request the url http://provider.com/example/path",
"key": "7824381c6cca0583",
"pending": false,
"providerStates": [
{
"name": "I have a url http://provider.com/example/path"
}
],
"request": {
"headers": {
"Accept": [
"application/json"
]
},
"method": "GET",
"path": "/example/path"
},
"response": {
"body": {
"content": {
"key": "value"
},
"contentType": "application/json",
"encoded": false
},
"headers": {
"Content-Type": [
"application/json"
]
},
"matchingRules": {
"body": {
"$.key": {
"combine": "AND",
"matchers": [
{
"match": "type"
}
]
}
},
"header": {}
},
"status": 200
},
"type": "Synchronous/HTTP"
}
],
"metadata": {
"pact-js": {
"version": "11.0.2"
},
"pactRust": {
"ffi": "0.4.0",
"models": "1.0.4"
},
"pactSpecification": {
"version": "4.0"
}
},
"provider": {
"name": "MyProvider"
}
}
Generator
MockServerURLis used like this:Mock Server support this generator (obviously from its name), so Consumer's contract test passed.
But Stub Server doesn't support this generator, so Consumer's integration test failed.
I think:
RandomInt)MockServerURLto something else that say that Stub Server support it too? I don't have suggestion, naming is hard.Here are some additional information:
Pact file from the above demo project
In case you don't want to run the demo project to see the contract file
{ "consumer": { "name": "MyConsumer" }, "interactions": [ { "description": "a request for all urls", "key": "285dde1d2816ddad", "pending": false, "providerStates": [ { "name": "I have a list of urls" } ], "request": { "headers": { "Accept": [ "application/json" ] }, "method": "GET", "path": "/urls" }, "response": { "body": { "content": { "urls": [ { "url": "http://localhost:8080/example/path" } ] }, "contentType": "application/json", "encoded": false }, "generators": { "body": { "$.urls[*].url": { "example": "http://localhost:8080/example/path", "regex": ".*(\\/example/path)$", "type": "MockServerURL" } } }, "headers": { "Content-Type": [ "application/json" ] }, "matchingRules": { "body": { "$.urls": { "combine": "AND", "matchers": [ { "match": "type", "min": 1 } ] }, "$.urls[*].url": { "combine": "AND", "matchers": [ { "match": "regex", "regex": ".*(\\/example/path)$" } ] } }, "header": {} }, "status": 200 }, "type": "Synchronous/HTTP" }, { "description": "a request the url http://provider.com/example/path", "key": "7824381c6cca0583", "pending": false, "providerStates": [ { "name": "I have a url http://provider.com/example/path" } ], "request": { "headers": { "Accept": [ "application/json" ] }, "method": "GET", "path": "/example/path" }, "response": { "body": { "content": { "key": "value" }, "contentType": "application/json", "encoded": false }, "headers": { "Content-Type": [ "application/json" ] }, "matchingRules": { "body": { "$.key": { "combine": "AND", "matchers": [ { "match": "type" } ] } }, "header": {} }, "status": 200 }, "type": "Synchronous/HTTP" } ], "metadata": { "pact-js": { "version": "11.0.2" }, "pactRust": { "ffi": "0.4.0", "models": "1.0.4" }, "pactSpecification": { "version": "4.0" } }, "provider": { "name": "MyProvider" } }