validator fails for interaction with body as array of numbers
For the attached swagger and pact file, the validation fails with the following error:
{
code: 'request.body.incompatible',
message: 'Request body is incompatible with the request body schema in the spec file: should pass "formatInt64" keyword validation',
mockDetails: {
interactionDescription: 'dummy desc',
interactionState: '[none]',
location: '[root].interactions[0].request.body[0]',
mockFile: 'swaggers/pact.json',
value: 101
},
source: 'spec-mock-validation',
specDetails: {
location: '[root].paths./testpath/1.post.parameters[0].schema.items.formatInt64',
pathMethod: 'post',
pathName: '/testpath/1',
specFile: 'swaggers/swagger.json',
value: undefined
},
type: 'error'
}
It seems like it only happens when request body (most likely it will also happen with response body) is an array of integers.
in lib/swagger-mock-validator/validate-spec-and-mock/validate-json.ts
line 48 if I print values of rawJson
and dataPath
they come out to be [101]
and [0]
respectively.
Hence in getRawValueFromJson
function when we do dataPath.substring(1)
it makes the dataPath to be 0]
and hence the function returns undefined
.
Is the behavior expected? am i missing something in my pact file which might solve this issue?
Comments (5)
-
Account Deactivated -
Account Deactivated I did a bit of digging and it seems the problem exists only when the array is the root value. I.e.:
- schema for a value like
[101]
hits the bug - schema for a value like
{“value”: [100]}
doesn’t.
I’ll try to get a fix ready sometime this week.
- schema for a value like
-
Account Deactivated - changed status to resolved
-
reporter Thanks @{557057:526b7077-83d4-4cfb-955a-e261d129103c} for the quick fix!!
-
Account Deactivated @Vasudev Patel The fix has been released with version v10.1.1
- Log in to comment
Hi @Vasudev Patel , thanks for reporting the issue. I was able to reproduce the issue. I’ll try to see what’s going on and come back to you