mirror of
https://github.com/postmanlabs/openapi-to-postman.git
synced 2022-11-29 22:05:00 +03:00
Fixed issue where content-type with wild characters resulted in mismacthes for valid collection headrs
This commit is contained in:
@@ -556,6 +556,38 @@ describe('VALIDATE FUNCTION TESTS ', function () {
|
||||
});
|
||||
});
|
||||
|
||||
it('Should correctly match and validate content type headers having wildcard characters' +
|
||||
' with collection req/res body', function (done) {
|
||||
let differentContentTypesSpec = fs.readFileSync(path.join(__dirname, VALIDATION_DATA_FOLDER_PATH +
|
||||
'/differentContentTypesSpec.yaml'), 'utf-8'),
|
||||
differentContentTypesCollection = fs.readFileSync(path.join(__dirname, VALIDATION_DATA_FOLDER_PATH +
|
||||
'/differentContentTypesCollection.json'), 'utf-8'),
|
||||
resultObj,
|
||||
historyRequest = [],
|
||||
options = {
|
||||
showMissingInSchemaErrors: true,
|
||||
suggestAvailableFixes: true
|
||||
},
|
||||
schemaPack = new Converter.SchemaPack({ type: 'string', data: differentContentTypesSpec }, options);
|
||||
|
||||
getAllTransactions(JSON.parse(differentContentTypesCollection), historyRequest);
|
||||
|
||||
schemaPack.validateTransaction(historyRequest, (err, result) => {
|
||||
expect(err).to.be.null;
|
||||
expect(result).to.be.an('object');
|
||||
resultObj = result.requests[historyRequest[1].id].endpoints[0];
|
||||
|
||||
/**
|
||||
* Both req and res body should have matched content types
|
||||
*/
|
||||
expect(resultObj.matched).to.eql(true);
|
||||
expect(resultObj.mismatches).to.have.lengthOf(0);
|
||||
expect(resultObj.responses[_.keys(resultObj.responses)[0]].matched).to.eql(true);
|
||||
expect(resultObj.responses[_.keys(resultObj.responses)[0]].mismatches).to.have.lengthOf(0);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('Should be able to validate and suggest correct value for body with primitive data type', function (done) {
|
||||
let primitiveDataTypeBodySpec = fs.readFileSync(path.join(__dirname, VALIDATION_DATA_FOLDER_PATH +
|
||||
'/primitiveDataTypeBodySpec.yaml'), 'utf-8'),
|
||||
|
||||
Reference in New Issue
Block a user