Tatiana Shepeleva
05/17/2022, 10:53 AMa48afdec7
currnently, and bi-directional contract verification started failing suddenly without any obvious reason on our side (or I haven’t found it yet). So, I wanted to double-check if this is on Pactflow side. Thanks!Matt (pactflow.io / pact-js / pact-go)
additionalProperties
set to false
Matt (pactflow.io / pact-js / pact-go)
Matt (pactflow.io / pact-js / pact-go)
Matt (pactflow.io / pact-js / pact-go)
Tatiana Shepeleva
05/17/2022, 11:36 AMWhat error are you getting?
Response body is incompatible with the response body schema in the spec file: should NOT have additional properties
looks like it’s related to the changes.Tatiana Shepeleva
05/17/2022, 11:36 AMIf you were having passing tests before, it’s likely you were getting false positivesinteresting, thank you!
Matt (pactflow.io / pact-js / pact-go)
Matt (pactflow.io / pact-js / pact-go)
true
(or omitted) it meant that the consumer could ask for any fields in the response, and it would always passMatt (pactflow.io / pact-js / pact-go)
Matt (pactflow.io / pact-js / pact-go)
Yousaf Nabi (pactflow.io)
Test incorrectly passes when mock expects a field that is not in the spechttps://bitbucket.org/atlassian/swagger-mock-validator/issues/84/test-incorrectly-passes-when-mock-expects Will look to the get the documentation on the Pactflow docs site updated asap, and I could probably add some additional error messaging back to the user, if it's relevant. (Would a link to the issue help save you searching for help?)
Tatiana Shepeleva
05/17/2022, 3:09 PMYousaf Nabi (pactflow.io)
Tatiana Shepeleva
05/19/2022, 9:14 AMallOf
notation in OAS. I prepared an example with contract and OAS files. I actually took that example from swagger.io. I’d appreciate if you have a look and share if something is wrong with the files.
Run npx @pactflow/swagger-mock-validator ./swagger.yaml ./contract.json
Tatiana Shepeleva
05/19/2022, 9:17 AM{
code: 'response.body.incompatible',
message: 'Response body is incompatible with the response body schema in the spec file: should NOT have additional properties - name',
mockDetails: {
interactionDescription: '46745cc6-f980-4d57-95b8-3c85539f7812',
interactionState: '[none]',
location: '[root].interactions[0].response.body[0]',
mockFile: './contract.json',
value: { name: 'Meow', petType: 'Cat' }
},
source: 'spec-mock-validation',
specDetails: {
location: '[root].paths./cats.get.responses.200.content.application/json.schema.items.allOf.0.additionalProperties',
pathMethod: 'get',
pathName: '/cats',
specFile: './swagger.yaml',
value: undefined
},
type: 'error'
},
{
code: 'response.body.incompatible',
message: 'Response body is incompatible with the response body schema in the spec file: should NOT have additional properties - petType',
mockDetails: {
interactionDescription: '46745cc6-f980-4d57-95b8-3c85539f7812',
interactionState: '[none]',
location: '[root].interactions[0].response.body[0]',
mockFile: './contract.json',
value: { name: 'Meow', petType: 'Cat' }
},
source: 'spec-mock-validation',
specDetails: {
location: '[root].paths./cats.get.responses.200.content.application/json.schema.items.allOf.1.additionalProperties',
pathMethod: 'get',
pathName: '/cats',
specFile: './swagger.yaml',
value: undefined
},
type: 'error'
}
Yousaf Nabi (pactflow.io)
@pactflow/swagger-mock-validator
v11 with the default flags?
I think this falls in line with the comments made by Ben Sayers here
https://bitbucket.org/atlassian/swagger-mock-validator/issues/84/test-incorrectly-passes-when-mock-expects#comment-59384182
You'll note at the bottom someone advises a tool which will resolve the anyOf schemas which may make the tool perform in the way you are expecting, I've yet to try it out.
Just thinking on these examples, it might be good to add these in CI, showing the output with the 4 diff combinations of flags,
Looking at the spec, the only required field is petType
but the Pact expects both?Tatiana Shepeleva
05/19/2022, 9:37 AM@pactflow/swagger-mock-validator
v11 and used with the default flags.
Looking at the spec, the only required field isthere are notbut the Pact expects both?petType
required
fields in my example. it’s just an object which consists from 2 other objects using allOf
. Pact complains that they are both present. I assume that Pact expects them not to be present at all.Yousaf Nabi (pactflow.io)
petType
is shown as required on line 28 of the swagger, name is not on 38
Tatiana Shepeleva
05/19/2022, 9:42 AMswagger-mock-validator
complains about both fieldsYousaf Nabi (pactflow.io)
allOf
is saying you can have a response with
• Pet with its required field PetType
and no name (as its optional)
• Pet with its required field PetType
and name (as its optional)
Your Pact file is expecting both to be presentYousaf Nabi (pactflow.io)
Yousaf Nabi (pactflow.io)
yeah, you are right, sorry about it. Anyway,No problem. Just want to clarify so we are on the same page 🙂complains about both fieldsswagger-mock-validator
Tatiana Shepeleva
05/19/2022, 9:53 AMallOf
takes an array of object definitions that are validated independently but together compose a single object. So, Pact file is expecting both to be present and I expect it to be the correct behaviour. https://swagger.io/docs/specification/data-models/oneof-anyof-allof-not/Tatiana Shepeleva
05/19/2022, 9:59 AMYousaf Nabi (pactflow.io)
Tatiana Shepeleva
05/19/2022, 10:07 AM"body": []
.