Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion lib/types/operation.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,10 @@ var Operation = module.exports = function (parent, scheme, operationId, httpMeth
if (param.type === 'array') {
param.isList = true;
param.allowMultiple = true;
// the enum can be defined at the items level
if (param.items && param.items.enum) {
param['enum'] = param.items.enum;
}
}

var innerType = this.getType(param);
Expand All @@ -92,7 +96,7 @@ var Operation = module.exports = function (parent, scheme, operationId, httpMeth

for (id = 0; id < param['enum'].length; id++) {
var value = param['enum'][id];
var isDefault = (value === param.default) ? true : false;
var isDefault = this.isDefaultArrayItemValue(value, param);

param.allowableValues.values.push(value);
param.allowableValues.descriptiveValues.push({value : value, isDefault: isDefault});
Expand Down Expand Up @@ -188,6 +192,13 @@ var Operation = module.exports = function (parent, scheme, operationId, httpMeth
return this;
};

Operation.prototype.isDefaultArrayItemValue = function(value, param) {
if (param.default && Array.isArray(param.default)) {
return param.default.indexOf(value) !== -1;
}
return value === param.default;
};

Operation.prototype.getType = function (param) {
var type = param.type;
var format = param.format;
Expand Down