how should one read this `swagger-mock-validator` ...
# pactflow
e
how should one read this
swagger-mock-validator
output? What confuses me is comparison of mock response body to
value: [ [Object], [Object] ]
. It's not clear what is incompatible. I've omitted a bunch of fields in the mock for brevity.
Copy code
1 error(s)
	response.body.incompatible: 1
0 warning(s)
{
  warnings: [],
  errors: [
    {
      code: 'response.body.incompatible',
      message: 'Response body is incompatible with the response body schema in the spec file: should match exactly one schema in oneOf',
      mockDetails: {
        interactionDescription: '6cee5dad-fe47-4ab7-9384-d53d5260427a',
        interactionState: '[none]',
        location: '[root].interactions[27].response.body',
        mockFile: './msw_generated_pacts/dashboard-web-api-1675179158185.json',
        value: {
          createdAt: '2022-10-30T00:00:00Z',
          "...": "...",
          status: 'DRAFT',
        }
      },
      source: 'spec-mock-validation',
      specDetails: {
        location: '[root].paths./api/invoices/{id}/payment-status.put.responses.200.content.application/json.schema.oneOf',
        pathMethod: 'put',
        pathName: '/api/invoices/{id}/payment-status',
        specFile: 'dereferencedSchema.json',
        value: [ [Object], [Object] ]
      },
      type: 'error'
    }
  ]
}
c
Hi again Eugene, it looks like the objects in your oneOf section do not have required fields marked on them. Without required fields the tool does the comparison on the type only, in this case [Object]. Since both of the options in the oneOf are that type it doesn't match to only 1. Try marking the fields that are different between the objects as required, then it will do a deeper comparison on the objects and hopefully match to just one as intended. There are some docs on it here: https://docs.pactflow.io/docs/bi-directional-contract-testing/contracts/oas/keyword-support#oneof-anyof
If you don't have any luck with it happy to have more of a look if you want to share the contracts here or via the pactflow support email 🙂
e
thank you for the context on how comparison works @Candy Goodison, i think it might be helpful to others too 👍 In our case the oneOf schemas were pretty much the same, which is an oversight on our end. Fixed 🙂
🙌 1
also sent an email to support@ for one last remaining oneOf bit that i cannot figure out. thank you!
c
awesome! we'll get back to you on that soon
1
🙏 1