mirror of
https://github.com/postmanlabs/openapi-to-postman.git
synced 2022-11-29 22:05:00 +03:00
Adding descriptions as fallback in webhooks name, Avoid webhooks folder creation when there are not any webhook in the file and includeWebhooks is true, ignoring local and global servers in webhooks
This commit is contained in:
@@ -660,6 +660,10 @@ module.exports = {
|
||||
variableStore = {},
|
||||
webhooksVariables = [];
|
||||
|
||||
if (Object.keys(webhooksTree.root.children).length === 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (let child in webhooksTree.root.children) {
|
||||
if (
|
||||
webhooksTree.root.children.hasOwnProperty(child) &&
|
||||
@@ -2232,10 +2236,10 @@ module.exports = {
|
||||
pmBody,
|
||||
authMeta,
|
||||
swagResponse,
|
||||
localServers = _.get(operationItem, 'properties.servers'),
|
||||
localServers = fromWebhooks ? '' : _.get(operationItem, 'properties.servers'),
|
||||
exampleRequestBody,
|
||||
sanitizeResult,
|
||||
globalServers = _.get(operationItem, 'servers'),
|
||||
globalServers = fromWebhooks ? '' : _.get(operationItem, 'servers'),
|
||||
responseMediaTypes,
|
||||
acceptHeader;
|
||||
|
||||
@@ -2341,7 +2345,7 @@ module.exports = {
|
||||
if (fromWebhooks) {
|
||||
reqName = utils.insertSpacesInName(operation.operationId) ||
|
||||
operation.summary ||
|
||||
`${this.cleanWebhookName(operationItem.path)} - ${operationItem.method}`;
|
||||
operation.description;
|
||||
}
|
||||
else {
|
||||
reqName = operation.summary || utils.insertSpacesInName(operation.operationId) || reqUrl;
|
||||
|
||||
2334
test/data/valid_openapi31X/webhooks/only-paths.yaml
Normal file
2334
test/data/valid_openapi31X/webhooks/only-paths.yaml
Normal file
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -822,4 +822,53 @@ describe('Webhooks support', function() {
|
||||
.with.length(3);
|
||||
});
|
||||
});
|
||||
|
||||
it('Should resolve correctly a file with only paths, with includeWebhooks in true',
|
||||
function() {
|
||||
const fileSource = path.join(__dirname, OPENAPI_31_FOLDER + '/webhooks/only-paths.yaml'),
|
||||
fileData = fs.readFileSync(fileSource, 'utf8'),
|
||||
input = {
|
||||
type: 'string',
|
||||
data: fileData
|
||||
},
|
||||
converter = new SchemaPack(input, { includeWebhooks: true });
|
||||
|
||||
converter.convert((err, result) => {
|
||||
expect(err).to.be.null;
|
||||
expect(result.result).to.be.true;
|
||||
expect(result.output[0].data.item).to.be.an('array')
|
||||
.with.length(1);
|
||||
expect(result.output[0].data.item).to.be.an('array').with.length(1);
|
||||
expect(result.output[0].data.item[0].name).to.equal('pets');
|
||||
expect(result.output[0].data.item[0].item).to.be.an('array')
|
||||
.with.length(3);
|
||||
});
|
||||
});
|
||||
|
||||
it('Should resolve correctly a file and ignore servers object in webhook, with includeWebhooks in true',
|
||||
function() {
|
||||
const fileSource = path.join(__dirname, OPENAPI_31_FOLDER +
|
||||
'/webhooks/payments-webhook-with-servers-in-webhook.yaml'),
|
||||
fileData = fs.readFileSync(fileSource, 'utf8'),
|
||||
input = {
|
||||
type: 'string',
|
||||
data: fileData
|
||||
},
|
||||
converter = new SchemaPack(input, { includeWebhooks: true });
|
||||
|
||||
converter.convert((err, result) => {
|
||||
expect(err).to.be.null;
|
||||
expect(result.result).to.be.true;
|
||||
expect(result.output[0].data.item).to.be.an('array')
|
||||
.with.length(1);
|
||||
expect(result.output[0].data.item).to.be.an('array').with.length(1);
|
||||
expect(result.output[0].data.item[0].name).to.equal('Webhooks');
|
||||
expect(result.output[0].data.item[0].item[0].request.url.host).to.be.an('array')
|
||||
.with.length(1);
|
||||
expect(result.output[0].data.item[0].item[0].request.url.host[0])
|
||||
.to.be.equal('{{ACCOUNT_CLOSED}}');
|
||||
expect(result.output[0].data.item[0].item).to.be.an('array')
|
||||
.with.length(19);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user