Skip to content

Commit

Permalink
Merge pull request #73 from APIs-guru/master
Browse files Browse the repository at this point in the history
1.2.0
  • Loading branch information
IvanGoncharov committed Feb 25, 2016
2 parents 675cccc + 4a3816e commit 8c26b1a
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 20 deletions.
30 changes: 17 additions & 13 deletions browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -603,9 +603,9 @@ prototype.buildParameter = function(oldParameter) {
required: fixNonStringValue(oldParameter.required)
});

Object.keys(oldParameter).forEach(function(property) {
if (property.match(/^X-/i) !== null) {
parameter[property] = oldParameter[property];
this.forEach(oldParameter, function(oldProperty, name) {
if (name.match(/^X-/i) !== null) {
parameter[name] = oldProperty;
}
});

Expand Down Expand Up @@ -740,30 +740,32 @@ prototype.buildSecurityDefinitions = function(oldAuthorizations) {
prototype.buildModel = function(oldModel) {
var required = [];
var properties = {};
var items;

this.forEach(oldModel.properties, function(oldProperty, propertyName) {
if (fixNonStringValue(oldProperty.required) === true) {
required.push(propertyName);
}

properties[propertyName] = extend({},
this.buildDataType(oldProperty, true),
{
description: oldProperty.description,
example: oldProperty.example
}
);
properties[propertyName] = this.buildModel(oldProperty);
});

required = oldModel.required || required;
if (Array.isArray(oldModel.required)) {
required = oldModel.required;
}

if (isValue(oldModel.items)) {
items = this.buildModel(oldModel.items);
}

return extend(this.buildDataType(oldModel, true),
{
description: oldModel.description,
required: undefinedIfEmpty(required),
properties: undefinedIfEmpty(properties),
discriminator: oldModel.discriminator,
example: oldModel.example
example: oldModel.example,
items: undefinedIfEmpty(items),
});
};

Expand Down Expand Up @@ -835,7 +837,9 @@ prototype.forEach = function(collection, iteratee) {
collection.forEach(iteratee);
}
else {
Object.keys(collection).forEach(function(key) {
//In some cases order of iteration influence order of arrays in output.
//To have stable result of convertion, keys need to be sorted.
Object.keys(collection).sort().forEach(function(key) {
iteratee(collection[key], key);
});
}
Expand Down
Loading

0 comments on commit 8c26b1a

Please sign in to comment.