mirror of
https://github.com/postmanlabs/openapi-to-postman.git
synced 2022-11-29 22:05:00 +03:00
Change deepObject generation
Change deepObject generation
This commit is contained in:
@@ -1550,9 +1550,9 @@ module.exports = {
|
||||
*/
|
||||
extractDeepObjectParams: function (deepObject, objectKey) {
|
||||
let extractedParams = [];
|
||||
// console.log(deepObject);
|
||||
|
||||
_.forEach(deepObject, (value, key) => {
|
||||
Object.keys(deepObject).forEach((key) => {
|
||||
let value = deepObject[key];
|
||||
if (typeof value === 'object') {
|
||||
extractedParams = _.concat(extractedParams, this.extractDeepObjectParams(value, objectKey + '[' + key + ']'));
|
||||
}
|
||||
|
||||
34
test/data/valid_openapi/deepObjectLengthProperty.yaml
Normal file
34
test/data/valid_openapi/deepObjectLengthProperty.yaml
Normal file
@@ -0,0 +1,34 @@
|
||||
openapi: 3.0.1
|
||||
info:
|
||||
title: Demo
|
||||
version: "1.0"
|
||||
paths:
|
||||
/get:
|
||||
get:
|
||||
operationId: someRequest
|
||||
parameters:
|
||||
- $ref: '#/components/parameters/DeepObjectNestedList'
|
||||
- $ref: '#/components/parameters/DeepObjectLengthParameter'
|
||||
responses:
|
||||
'200':
|
||||
description: Response on success.
|
||||
components:
|
||||
parameters:
|
||||
DeepObjectLengthParameter:
|
||||
name: deepObjectLengthParameter
|
||||
in: query
|
||||
required: false
|
||||
style: deepObject
|
||||
schema:
|
||||
$ref: '#/components/schemas/DeepObjectLengthParameter'
|
||||
explode: true
|
||||
schemas:
|
||||
DeepObjectLengthParameter:
|
||||
type: object
|
||||
properties:
|
||||
length:
|
||||
nullable: true
|
||||
type: integer
|
||||
format: int32
|
||||
minimum: 1
|
||||
example: 20
|
||||
@@ -45,7 +45,8 @@ describe('CONVERT FUNCTION TESTS ', function() {
|
||||
emptySecurityTestCase = path.join(__dirname, VALID_OPENAPI_PATH + '/empty-security-test-case.yaml'),
|
||||
rootUrlServerWithVariables = path.join(__dirname, VALID_OPENAPI_PATH + '/root_url_server_with_variables.json'),
|
||||
parameterExamples = path.join(__dirname, VALID_OPENAPI_PATH + '/parameteres_with_examples.yaml'),
|
||||
issue10229 = path.join(__dirname, VALID_OPENAPI_PATH, '/issue#10229.json');
|
||||
issue10229 = path.join(__dirname, VALID_OPENAPI_PATH, '/issue#10229.json'),
|
||||
deepObjectLengthProperty = path.join(__dirname, VALID_OPENAPI_PATH, '/deepObjectLengthProperty.yaml');
|
||||
|
||||
|
||||
it('Should add collection level auth with type as `bearer`' +
|
||||
@@ -1094,6 +1095,20 @@ describe('CONVERT FUNCTION TESTS ', function() {
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('[Github #10752]: Should convert deepObject length property' +
|
||||
deepObjectLengthProperty, function(done) {
|
||||
var openapi = fs.readFileSync(deepObjectLengthProperty, 'utf8');
|
||||
Converter.convert({ type: 'string', data: openapi },
|
||||
{ schemaFaker: true, requestParametersResolution: 'Example' }, (err, conversionResult) => {
|
||||
expect(err).to.be.null;
|
||||
expect(conversionResult.result).to.equal(true);
|
||||
expect(conversionResult.output[0].data.item[0].request.url.query[0].key)
|
||||
.to.equal('deepObjectLengthParameter[length]');
|
||||
expect(conversionResult.output[0].data.item[0].request.url.query[0].value).to.equal('20');
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('requestNameSource option', function() {
|
||||
|
||||
Reference in New Issue
Block a user