jan.krejci
2020-10-20 12:52
Hello guys, anyone that already has used the CLI tool `swagger-mock-validator` of Atlassian and experienced the behaviour below?
1 - I have a *consumer* that publish a contract on PACT Broker like that below:
*Interactions*
Given get balance of accountId 1, upon receiving a request to /v1/accounts/1/balance/ from consumer, with:
```{
"method": "GET",
"path": "/v1/accounts/1/balance/"
}```
provider will respond with:
```{
"status": 200,
"headers": {
"Content-Type": "application/json"
},
"body": {
"accountId": 100,
"clientId": 100,
"balance": 100,
"credit": 100
}
}```
2 - and the in the *Provider* Side I have a Open API specification like that :
```{
"...": "...",
"paths":{
"/v1/accounts/{accountId}/balance/":{
"get":{
"...": "...",
"responses":{
"404":{
"description":"Account id not found"
},
"200":{
"description":"Return the balance for the account",
"content":{
"application/json":{
"schema":{
"$ref":"#/components/schemas/BalanceDTO"
}
}
}
}
}
}
}
},
"components":{
"schemas":{
"...": "...",
"BalanceDTO":{
"type":"object",
"properties":{
"clientId":{
"type":"integer",
"format":"int32"
},
"accountId":{
"type":"integer",
"format":"int32"
},
"balance":{
"type":"number"
}
}
}
}
}
}
}```
If I run the swagger-mock-validator CLI against the Pact Broker to verify the contract by the Provider, the contract between the participants is supposed to be invalid because I don't have a *credit field* into the Provider response BUT It runs without failures :
```0 error(s)
0 warning(s)```