mirror of
https://github.com/postmanlabs/openapi-to-postman.git
synced 2022-11-29 22:05:00 +03:00
changed safeschemafaker funcgion signature
This commit is contained in:
3
.gitignore
vendored
3
.gitignore
vendored
@@ -42,5 +42,4 @@ test/data/.temp
|
||||
*.orig
|
||||
|
||||
# Prevent unit test coverage reports from being added
|
||||
.coverage
|
||||
tempOutput.json
|
||||
.coverage
|
||||
@@ -151,7 +151,6 @@ module.exports = {
|
||||
// shallow cloning schema object except properties object
|
||||
let tempSchema = _.omit(schema, 'properties');
|
||||
tempSchema.properties = {};
|
||||
|
||||
for (prop in schema.properties) {
|
||||
if (schema.properties.hasOwnProperty(prop)) {
|
||||
/* eslint-disable max-depth */
|
||||
|
||||
@@ -64,13 +64,13 @@ schemaFaker.option({
|
||||
* Safe wrapper for schemaFaker that resolves references and
|
||||
* removes things that might make schemaFaker crash
|
||||
* @param {*} oldSchema the schema to fake
|
||||
* @param {string} bodyType tells that the schema object is of request or response
|
||||
* @param {*} components list of predefined components (with schemas)
|
||||
* @param {string} schemaFormat default or xml
|
||||
* @param {string} indentCharacter char for 1 unit of indentation
|
||||
* @param {string} bodyType tells that the schema object is of request or response
|
||||
* @returns {object} fakedObject
|
||||
*/
|
||||
function safeSchemaFaker(oldSchema, components, schemaFormat, indentCharacter, bodyType) {
|
||||
function safeSchemaFaker(oldSchema, bodyType, components, schemaFormat, indentCharacter) {
|
||||
var prop,
|
||||
schema = deref.resolveRefs(oldSchema, bodyType, components);
|
||||
|
||||
@@ -756,7 +756,7 @@ module.exports = {
|
||||
if (this.getHeaderFamily(contentType) === HEADER_TYPE.XML) {
|
||||
schemaType = SCHEMA_FORMATS.XML;
|
||||
}
|
||||
bodyData = safeSchemaFaker(bodyObj.schema || {}, this.components, schemaType, indentCharacter, bodyType);
|
||||
bodyData = safeSchemaFaker(bodyObj.schema || {}, bodyType, this.components, schemaType, indentCharacter);
|
||||
}
|
||||
else {
|
||||
// do not fake if the option is false
|
||||
|
||||
@@ -29,9 +29,10 @@ describe('UTILITY FUNCTION TESTS ', function () {
|
||||
$ref: '#/components/schemas/schema2'
|
||||
}
|
||||
}
|
||||
};
|
||||
},
|
||||
bodyType = 'REQUEST';
|
||||
|
||||
expect(Utils.safeSchemaFaker(schema, components)).to.equal('<string>');
|
||||
expect(Utils.safeSchemaFaker(schema, bodyType, components)).to.equal('<string>');
|
||||
done();
|
||||
});
|
||||
|
||||
@@ -62,10 +63,11 @@ describe('UTILITY FUNCTION TESTS ', function () {
|
||||
$ref: '#/components/schem2'
|
||||
}
|
||||
}
|
||||
};
|
||||
},
|
||||
bodyType = 'REQUEST';
|
||||
|
||||
expect(function() {
|
||||
Utils.safeSchemaFaker(schema, components);
|
||||
Utils.safeSchemaFaker(schema, bodyType, components);
|
||||
}).to.throw(openApiErr, 'Invalid schema reference: #/components/schem2');
|
||||
done();
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user