mirror of
https://github.com/postmanlabs/openapi-to-postman.git
synced 2022-11-29 22:05:00 +03:00
Fix swagger to openapi convertion
Removing async await implementation and using callback implementation instead. Fixin the related tests
This commit is contained in:
@@ -6,25 +6,24 @@ const { convertSwaggerToOpenapi } = require('../../lib/swaggerUtils/swaggerToOpe
|
||||
utils = require('../../lib/swaggerUtils/schemaUtilsSwagger'),
|
||||
expect = require('chai').expect;
|
||||
|
||||
describe('Test swaggerToOpenapi method', async function() {
|
||||
it('Should convert a swagger file to an openapi', async function() {
|
||||
describe('Test swaggerToOpenapi method', function() {
|
||||
it('Should convert a swagger file to an openapi', function() {
|
||||
const fileSource = path.join(__dirname, SWAGGER_20_FOLDER_JSON + '/sampleswagger.json'),
|
||||
fileData = fs.readFileSync(fileSource, 'utf8'),
|
||||
parsedSpec = utils.parseSpec(fileData);
|
||||
let result = await convertSwaggerToOpenapi(parsedSpec.openapi);
|
||||
expect(result.openapi.openapi).to.be.equal('3.0.0');
|
||||
convertSwaggerToOpenapi(utils, parsedSpec.openapi, (error, openapi) => {
|
||||
expect(error).to.be.null;
|
||||
expect(openapi.openapi).to.be.equal('3.0.0');
|
||||
});
|
||||
});
|
||||
|
||||
it('Should throw an error when swagger file is not complete', async function() {
|
||||
it('Should throw an error when swagger file is not complete', function() {
|
||||
const fileSource = path.join(__dirname, SWAGGER_20_INVALID_FOLDER_JSON + '/invalid_no_info.json'),
|
||||
fileData = fs.readFileSync(fileSource, 'utf8'),
|
||||
parsedSpec = utils.parseSpec(fileData);
|
||||
try {
|
||||
await convertSwaggerToOpenapi(parsedSpec.openapi);
|
||||
expect.fail();
|
||||
}
|
||||
catch (error) {
|
||||
convertSwaggerToOpenapi(utils, parsedSpec.openapi, (error, openapi) => {
|
||||
expect(error.message).to.be.equal('Unsupported swagger/OpenAPI version: undefined');
|
||||
}
|
||||
expect(openapi).to.be.undefined;
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user