Abhishek
06/10/2022, 10:18 AMYousaf Nabi (pactflow.io)
Yousaf Nabi (pactflow.io)
npx @pactflow/swagger-mock-validator Matching.yaml CA.json
❯ npx @pactflow/swagger-mock-validator Matching.yaml CA.json
Mock file "CA.json" is not compatible with spec file "Matching.yaml"
2 error(s)
request.authorization.missing: 1
request.header.incompatible: 1
0 warning(s)
{
warnings: [],
errors: [
{
code: 'request.authorization.missing',
message: 'Request Authorization header is missing but is required by the spec file',
mockDetails: {
interactionDescription: 'A valid post response',
interactionState: 'We have resposne from Ontology',
location: '[root].interactions[0]',
mockFile: 'CA.json',
value: {
description: 'A valid post response',
providerState: 'We have resposne from Ontology',
request: [Object],
response: [Object]
}
},
source: 'spec-mock-validation',
specDetails: {
location: '[root].security[0].apiKeyHeader',
pathMethod: 'post',
pathName: '/api/v1/ontology/normalizations',
specFile: 'Matching.yaml',
value: []
},
type: 'error'
},
{
code: 'request.header.incompatible',
message: "Value is incompatible with the parameter defined in the spec file: should have required property 'value'",
mockDetails: {
interactionDescription: 'A valid post response',
interactionState: 'We have resposne from Ontology',
location: '[root].interactions[0]',
mockFile: 'CA.json',
value: {
description: 'A valid post response',
providerState: 'We have resposne from Ontology',
request: [Object],
response: [Object]
}
},
source: 'spec-mock-validation',
specDetails: {
location: '[root].paths./api/v1/ontology/normalizations.post.parameters[0]',
pathMethod: 'post',
pathName: '/api/v1/ontology/normalizations',
specFile: 'Matching.yaml',
value: {
name: 'X-Tenant-ID',
in: 'header',
description: 'Internal Tenant ID',
required: true,
schema: [Object]
}
},
type: 'error'
}
]
}
Error: Mock file "CA.json" is not compatible with spec file "Matching.yaml"
Abhishek
06/10/2022, 1:43 PM{
code: 'request.header.incompatible',
message: "Value is incompatible with the parameter defined in the spec file: should have required property 'value'",
mockDetails: {
interactionDescription: 'A valid post response',
interactionState: 'We have resposne from Ontology',
location: '[root].interactions[0]',
mockFile: 'CA.json',
value: {
description: 'A valid post response',
providerState: 'We have resposne from Ontology',
request: [Object],
response: [Object]
}
Abhishek
06/10/2022, 1:44 PMYousaf Nabi (pactflow.io)
{
code: 'request.header.incompatible',
message: "Value is incompatible with the parameter defined in the spec file: should have required property 'value'",
mockDetails: {
interactionDescription: 'A valid post response',
interactionState: 'We have resposne from Ontology',
location: '[root].interactions[0]',
mockFile: 'CA.json',
value: {
description: 'A valid post response',
providerState: 'We have resposne from Ontology',
request: [Object],
response: [Object]
}
},
source: 'spec-mock-validation',
specDetails: {
location: '[root].paths./api/v1/ontology/normalizations.post.parameters[0]',
pathMethod: 'post',
pathName: '/api/v1/ontology/normalizations',
specFile: 'Matching.yaml',
value: {
name: 'X-Tenant-ID',
in: 'header',
description: 'Internal Tenant ID',
required: true,
schema: [Object]
}
},
type: 'error'
}
X-Tenant-ID
is required but not in your Pact fileYousaf Nabi (pactflow.io)
{
code: 'request.authorization.missing',
message: 'Request Authorization header is missing but is required by the spec file',
mockDetails: {
interactionDescription: 'A valid post response',
interactionState: 'We have resposne from Ontology',
location: '[root].interactions[0]',
mockFile: 'CA.json',
value: {
description: 'A valid post response',
providerState: 'We have resposne from Ontology',
request: [Object],
response: [Object]
}
},
source: 'spec-mock-validation',
specDetails: {
location: '[root].security[0].apiKeyHeader',
pathMethod: 'post',
pathName: '/api/v1/ontology/normalizations',
specFile: 'Matching.yaml',
value: []
},
type: 'error'
},
there are two `apiKeyHeader`'s defined in the spec
securitySchemes:
apiKeyHeader:
type: apiKey
name: Ocp-Apim-Subscription-Key
in: header
apiKeyQuery:
type: apiKey
name: subscription-key
in: query
it is an error because Ocp-Apim-Subscription-Key
is a defined header but is not present in the pact fileAbhishek
06/10/2022, 1:51 PMAbhishek
06/10/2022, 1:51 PMAbhishek
06/10/2022, 1:51 PMYousaf Nabi (pactflow.io)