Skip to content

Commit

Permalink
feat: wip import-pact-file
Browse files Browse the repository at this point in the history
  • Loading branch information
YOU54F committed May 22, 2024
1 parent 7990e4b commit 0e4ba9f
Show file tree
Hide file tree
Showing 7 changed files with 2,577 additions and 2 deletions.
154 changes: 154 additions & 0 deletions pact-v3.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,154 @@
{
"consumer": {
"name": "swaggerhub-pactflow-consumer-codegen"
},
"interactions": [
{
"description": "a request to get a product",
"providerStates": [
{
"name": "a product with ID 10 exists"
}
],
"request": {
"method": "GET",
"path": "/product/10"
},
"response": {
"body": {
"id": "10",
"name": "28 Degrees",
"type": "CREDIT_CARD"
},
"headers": {
"Content-Type": "application/json"
},
"matchingRules": {
"body": {
"$": {
"combine": "AND",
"matchers": [
{
"match": "type"
}
]
}
},
"header": {}
},
"status": 200
}
},
{
"description": "a request for to create product 1234",
"providerStates": [
{
"name": "a product with id 1234 does not exist"
}
],
"request": {
"body": {
"id": "1234",
"name": "burger",
"price": 42,
"type": "food"
},
"headers": {
"Content-Type": "application/json"
},
"matchingRules": {
"body": {
"$": {
"combine": "AND",
"matchers": [
{
"match": "type"
}
]
}
}
},
"method": "POST",
"path": "/products"
},
"response": {
"body": {
"id": "1234",
"name": "burger",
"price": 42,
"type": "food"
},
"headers": {
"Content-Type": "application/json"
},
"matchingRules": {
"body": {
"$": {
"combine": "AND",
"matchers": [
{
"match": "type"
}
]
}
},
"header": {}
},
"status": 200
}
},
{
"description": "a request to get all products",
"providerStates": [
{
"name": "products exist"
}
],
"request": {
"method": "GET",
"path": "/products"
},
"response": {
"body": [
{
"id": "10",
"name": "28 Degrees",
"type": "CREDIT_CARD"
}
],
"headers": {
"Content-Type": "application/json"
},
"matchingRules": {
"body": {
"$": {
"combine": "AND",
"matchers": [
{
"match": "type"
}
]
}
},
"header": {}
},
"status": 200
}
}
],
"metadata": {
"pact-js": {
"version": "10.1.4"
},
"pactRust": {
"ffi": "0.3.12",
"models": "0.4.5"
},
"pactSpecification": {
"version": "3.0.0"
}
},
"provider": {
"name": "swaggerhub-pactflow-provider"
}
}
5 changes: 3 additions & 2 deletions src/Explore.Cli/PactMappingHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,9 @@ public static string getPactVersion(string json)
var version = pactSpecification["version"].ToString();
var validVersions = new List<string> { "1.0.0", "2.0.0", "3.0.0", "4.0.0" };
if (version != null && validVersions.Contains(version))
{
return $"pact-v{version}";
{
var formattedVersion = version.Split('.')[0];
return $"pact-v{formattedVersion}";
}
}
}
Expand Down
Loading

0 comments on commit 0e4ba9f

Please sign in to comment.