Skip to content

Commit

Permalink
Merge pull request #764 from postmanlabs/revert-760-feature/add-descr…
Browse files Browse the repository at this point in the history
…iption

Revert "Add description for path variables to the request if present in OpenAPI schema"
  • Loading branch information
jatin3893 authored Sep 12, 2023
2 parents 17211ac + 8a582a1 commit 22cebb8
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 91 deletions.
9 changes: 0 additions & 9 deletions libV2/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,15 +66,6 @@ const sdk = require('postman-collection'),
});

requestItem.request.url.variables.assimilate(pathParams);
_.forEach(pathParams, (param) => {
if (param.description) {
const item = requestItem.request.url.variables.one(param.key);
if (!_.isEmpty(item)) {
item.description = param.description;
}
}
});

requestItem.request.auth = auth;

_.forEach(responses, (response) => {
Expand Down
55 changes: 0 additions & 55 deletions test/data/valid_openapi/path_params_with_description.json

This file was deleted.

48 changes: 21 additions & 27 deletions test/unit/convertV2.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ const expect = require('chai').expect,
examplesOutsideSchema = path.join(__dirname, VALID_OPENAPI_PATH + '/examples_outside_schema.json'),
exampleOutsideSchema = path.join(__dirname, VALID_OPENAPI_PATH + '/example_outside_schema.json'),
descriptionInBodyParams = path.join(__dirname, VALID_OPENAPI_PATH + '/description_in_body_params.json'),
descriptionInPathParams = path.join(__dirname, VALID_OPENAPI_PATH + '/path_params_with_description.json'),
zeroDefaultValueSpec = path.join(__dirname, VALID_OPENAPI_PATH + '/zero_in_default_value.json'),
requiredInParams = path.join(__dirname, VALID_OPENAPI_PATH, '/required_in_parameters.json'),
multipleRefs = path.join(__dirname, VALID_OPENAPI_PATH, '/multiple_refs.json'),
Expand Down Expand Up @@ -554,16 +553,6 @@ describe('The convert v2 Function', function() {
});
});

it('should add description in path params', function (done) {
var openapi = fs.readFileSync(descriptionInPathParams, 'utf-8');
Converter.convertV2({ type: 'string', data: openapi }, { schemaFaker: true }, (err, conversionResult) => {
let description = conversionResult.output[0].data.item[0].item[0].item[0].request.url.variable[0].description;
expect(err).to.be.null;
expect(description).to.equal('(Required) Id of pet');
done();
});
});

it('Should create collection from folder having one root file for browser', function(done) {
let folderPath = path.join(__dirname, '../data/petstore separate yaml'),
files = [],
Expand Down Expand Up @@ -1177,23 +1166,28 @@ describe('The convert v2 Function', function() {
Converter.convertV2({ type: 'string', data: openapi },
{}, (err, conversionResult) => {
expect(
conversionResult.output[0].data.item[0].item[0].item[0].request.url.query[0].description.content)
.to.equal('(Required) QUERY PARAM DESCRIPTION');
conversionResult.output[0].data.item[0].item[0].item[0].request.url.query[0].description.content
).to.equal('(Required) QUERY PARAM DESCRIPTION');

expect(
conversionResult.output[0].data.item[0].item[0].item[0].request.url.query[1].description.content)
.to.equal('QUERY PARAM Optional');
expect(conversionResult.output[0].data.item[0].item[0].item[0].request.url.variable[0].description).to.equal(
'(Required) Required spacecraftId path param'
);
expect(conversionResult.output[0].data.item[0].item[0].item[0].request.url.variable[1].description).to.equal(
'Path param optional description'
);
expect(conversionResult.output[0].data.item[0].item[0].item[0].request.header[0].description.content).to.equal(
'(Required) HEADER PARAM DESCRIPTION'
);
expect(conversionResult.output[0].data.item[0].item[0].item[0].request.header[1].description.content).to.equal(
'HEADER PARAM Optional'
);
conversionResult.output[0].data.item[0].item[0].item[0].request.url.query[1].description.content
).to.equal('QUERY PARAM Optional');

expect(
conversionResult.output[0].data.item[0].item[0].item[0].request.url.variable[0].description.content
).to.equal('(Required) Required spacecraftId path param');

expect(
conversionResult.output[0].data.item[0].item[0].item[0].request.url.variable[1].description.content
).to.equal('Path param optional description');

expect(
conversionResult.output[0].data.item[0].item[0].item[0].request.header[0].description.content
).to.equal('(Required) HEADER PARAM DESCRIPTION');

expect(
conversionResult.output[0].data.item[0].item[0].item[0].request.header[1].description.content
).to.equal('HEADER PARAM Optional');
done();
});
});
Expand Down

0 comments on commit 22cebb8

Please sign in to comment.