fixed enum, required flags
This commit is contained in:
38
dist/lib/swagger.js
vendored
38
dist/lib/swagger.js
vendored
@@ -385,10 +385,17 @@
|
||||
SwaggerModel = (function() {
|
||||
|
||||
function SwaggerModel(modelName, obj) {
|
||||
var propertyName;
|
||||
var propertyName, value;
|
||||
this.name = obj.id != null ? obj.id : modelName;
|
||||
this.properties = [];
|
||||
for (propertyName in obj.properties) {
|
||||
if (obj["enum"] != null) {
|
||||
for (value in obj["enum"]) {
|
||||
if (propertyName === value) {
|
||||
obj.properties[propertyName].required = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
this.properties.push(new SwaggerModelProperty(propertyName, obj.properties[propertyName]));
|
||||
}
|
||||
}
|
||||
@@ -464,6 +471,7 @@
|
||||
this.isCollection = this.dataType && (this.dataType.toLowerCase() === 'array' || this.dataType.toLowerCase() === 'list' || this.dataType.toLowerCase() === 'set');
|
||||
this.descr = obj.description;
|
||||
this.required = obj.required;
|
||||
console.log(this);
|
||||
if (obj.items != null) {
|
||||
if (obj.items.type != null) {
|
||||
this.refDataType = obj.items.type;
|
||||
@@ -524,7 +532,7 @@
|
||||
SwaggerOperation = (function() {
|
||||
|
||||
function SwaggerOperation(nickname, path, method, parameters, summary, notes, type, responseMessages, resource, consumes, produces) {
|
||||
var parameter, v, _i, _j, _len, _len1, _ref, _ref1, _ref2,
|
||||
var parameter, v, _i, _j, _k, _len, _len1, _len2, _ref, _ref1, _ref2, _ref3,
|
||||
_this = this;
|
||||
this.nickname = nickname;
|
||||
this.path = path;
|
||||
@@ -572,6 +580,26 @@
|
||||
}
|
||||
parameter.signature = this.getSignature(type, this.resource.models);
|
||||
parameter.sampleJSON = this.getSampleJSON(type, this.resource.models);
|
||||
if (parameter["enum"] != null) {
|
||||
parameter.isList = true;
|
||||
parameter.allowableValues = {};
|
||||
parameter.allowableValues.descriptiveValues = [];
|
||||
_ref2 = parameter["enum"];
|
||||
for (_j = 0, _len1 = _ref2.length; _j < _len1; _j++) {
|
||||
v = _ref2[_j];
|
||||
if ((parameter.defaultValue != null) && parameter.defaultValue === v) {
|
||||
parameter.allowableValues.descriptiveValues.push({
|
||||
value: v,
|
||||
isDefault: true
|
||||
});
|
||||
} else {
|
||||
parameter.allowableValues.descriptiveValues.push({
|
||||
value: v,
|
||||
isDefault: false
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
if (parameter.allowableValues != null) {
|
||||
if (parameter.allowableValues.valueType === "RANGE") {
|
||||
parameter.isRange = true;
|
||||
@@ -580,9 +608,9 @@
|
||||
}
|
||||
if (parameter.allowableValues.values != null) {
|
||||
parameter.allowableValues.descriptiveValues = [];
|
||||
_ref2 = parameter.allowableValues.values;
|
||||
for (_j = 0, _len1 = _ref2.length; _j < _len1; _j++) {
|
||||
v = _ref2[_j];
|
||||
_ref3 = parameter.allowableValues.values;
|
||||
for (_k = 0, _len2 = _ref3.length; _k < _len2; _k++) {
|
||||
v = _ref3[_k];
|
||||
if ((parameter.defaultValue != null) && parameter.defaultValue === v) {
|
||||
parameter.allowableValues.descriptiveValues.push({
|
||||
value: v,
|
||||
|
||||
75
dist/swagger-ui.js
vendored
75
dist/swagger-ui.js
vendored
@@ -317,45 +317,45 @@ helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
|
||||
function program1(depth0,data) {
|
||||
|
||||
var buffer = "", stack1;
|
||||
buffer += "\n <h4>Implementation Notes</h4>\n <p>";
|
||||
buffer += "\n <h4>Implementation Notes</h4>\n <p>";
|
||||
if (stack1 = helpers.notes) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
|
||||
else { stack1 = depth0.notes; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
|
||||
if(stack1 || stack1 === 0) { buffer += stack1; }
|
||||
buffer += "</p>\n ";
|
||||
buffer += "</p>\n ";
|
||||
return buffer;
|
||||
}
|
||||
|
||||
function program3(depth0,data) {
|
||||
|
||||
|
||||
return "\n <h4>Response Class</h4>\n <p><span class=\"model-signature\" /></p>\n <br/>\n <div class=\"response-content-type\" />\n ";
|
||||
return "\n <h4>Response Class</h4>\n <p><span class=\"model-signature\" /></p>\n <br/>\n <div class=\"response-content-type\" />\n ";
|
||||
}
|
||||
|
||||
function program5(depth0,data) {
|
||||
|
||||
|
||||
return "\n <h4>Parameters</h4>\n <table class='fullwidth'>\n <thead>\n <tr>\n <th style=\"width: 100px; max-width: 100px\">Parameter</th>\n <th style=\"width: 310px; max-width: 310px\">Value</th>\n <th style=\"width: 200px; max-width: 200px\">Description</th>\n <th style=\"width: 100px; max-width: 100px\">Parameter Type</th>\n <th style=\"width: 220px; max-width: 230px\">Data Type</th>\n </tr>\n </thead>\n <tbody class=\"operation-params\">\n\n </tbody>\n </table>\n ";
|
||||
return "\n <h4>Parameters</h4>\n <table class='fullwidth'>\n <thead>\n <tr>\n <th style=\"width: 100px; max-width: 100px\">Parameter</th>\n <th style=\"width: 310px; max-width: 310px\">Value</th>\n <th style=\"width: 200px; max-width: 200px\">Description</th>\n <th style=\"width: 100px; max-width: 100px\">Parameter Type</th>\n <th style=\"width: 220px; max-width: 230px\">Data Type</th>\n </tr>\n </thead>\n <tbody class=\"operation-params\">\n\n </tbody>\n </table>\n ";
|
||||
}
|
||||
|
||||
function program7(depth0,data) {
|
||||
|
||||
|
||||
return "\n <div style='margin:0;padding:0;display:inline'></div>\n <h4>Error Status Codes</h4>\n <table class='fullwidth'>\n <thead>\n <tr>\n <th>HTTP Status Code</th>\n <th>Reason</th>\n </tr>\n </thead>\n <tbody class=\"operation-status\">\n \n </tbody>\n </table>\n ";
|
||||
return "\n <div style='margin:0;padding:0;display:inline'></div>\n <h4>Error Status Codes</h4>\n <table class='fullwidth'>\n <thead>\n <tr>\n <th>HTTP Status Code</th>\n <th>Reason</th>\n </tr>\n </thead>\n <tbody class=\"operation-status\">\n \n </tbody>\n </table>\n ";
|
||||
}
|
||||
|
||||
function program9(depth0,data) {
|
||||
|
||||
|
||||
return "\n ";
|
||||
return "\n ";
|
||||
}
|
||||
|
||||
function program11(depth0,data) {
|
||||
|
||||
|
||||
return "\n <div class='sandbox_header'>\n <input class='submit' name='commit' type='button' value='Try it out!' />\n <a href='#' class='response_hider' style='display:none'>Hide Response</a>\n <img alt='Throbber' class='response_throbber' src='images/throbber.gif' style='display:none' />\n </div>\n ";
|
||||
return "\n <div class='sandbox_header'>\n <input class='submit' name='commit' type='button' value='Try it out!' />\n <a href='#' class='response_hider' style='display:none'>Hide Response</a>\n <img alt='Throbber' class='response_throbber' src='images/throbber.gif' style='display:none' />\n </div>\n ";
|
||||
}
|
||||
|
||||
buffer += "\n <ul class='operations' >\n <li class='";
|
||||
buffer += "\n <ul class='operations' >\n <li class='";
|
||||
if (stack1 = helpers.method) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
|
||||
else { stack1 = depth0.method; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
|
||||
buffer += escapeExpression(stack1)
|
||||
@@ -375,7 +375,7 @@ function program11(depth0,data) {
|
||||
if (stack1 = helpers.number) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
|
||||
else { stack1 = depth0.number; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
|
||||
buffer += escapeExpression(stack1)
|
||||
+ "'>\n <div class='heading'>\n <h3>\n <span class='http_method'>\n <a href='#!/";
|
||||
+ "'>\n <div class='heading'>\n <h3>\n <span class='http_method'>\n <a href='#!/";
|
||||
if (stack1 = helpers.resourceName) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
|
||||
else { stack1 = depth0.resourceName; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
|
||||
buffer += escapeExpression(stack1)
|
||||
@@ -395,7 +395,7 @@ function program11(depth0,data) {
|
||||
if (stack1 = helpers.method) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
|
||||
else { stack1 = depth0.method; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
|
||||
buffer += escapeExpression(stack1)
|
||||
+ "</a>\n </span>\n <span class='path'>\n <a href='#!/";
|
||||
+ "</a>\n </span>\n <span class='path'>\n <a href='#!/";
|
||||
if (stack1 = helpers.resourceName) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
|
||||
else { stack1 = depth0.resourceName; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
|
||||
buffer += escapeExpression(stack1)
|
||||
@@ -415,7 +415,7 @@ function program11(depth0,data) {
|
||||
if (stack1 = helpers.path) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
|
||||
else { stack1 = depth0.path; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
|
||||
buffer += escapeExpression(stack1)
|
||||
+ "</a>\n </span>\n </h3>\n <ul class='options'>\n <li>\n <a href='#!/";
|
||||
+ "</a>\n </span>\n </h3>\n <ul class='options'>\n <li>\n <a href='#!/";
|
||||
if (stack1 = helpers.resourceName) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
|
||||
else { stack1 = depth0.resourceName; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
|
||||
buffer += escapeExpression(stack1)
|
||||
@@ -435,7 +435,7 @@ function program11(depth0,data) {
|
||||
if (stack1 = helpers.summary) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
|
||||
else { stack1 = depth0.summary; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
|
||||
if(stack1 || stack1 === 0) { buffer += stack1; }
|
||||
buffer += "</a>\n </li>\n </ul>\n </div>\n <div class='content' id='";
|
||||
buffer += "</a>\n </li>\n </ul>\n </div>\n <div class='content' id='";
|
||||
if (stack1 = helpers.resourceName) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
|
||||
else { stack1 = depth0.resourceName; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
|
||||
buffer += escapeExpression(stack1)
|
||||
@@ -451,22 +451,22 @@ function program11(depth0,data) {
|
||||
if (stack1 = helpers.number) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
|
||||
else { stack1 = depth0.number; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
|
||||
buffer += escapeExpression(stack1)
|
||||
+ "_content' style='display:none'>\n ";
|
||||
+ "_content' style='display:none'>\n ";
|
||||
stack1 = helpers['if'].call(depth0, depth0.notes, {hash:{},inverse:self.noop,fn:self.program(1, program1, data),data:data});
|
||||
if(stack1 || stack1 === 0) { buffer += stack1; }
|
||||
buffer += "\n ";
|
||||
buffer += "\n ";
|
||||
stack1 = helpers['if'].call(depth0, depth0.type, {hash:{},inverse:self.noop,fn:self.program(3, program3, data),data:data});
|
||||
if(stack1 || stack1 === 0) { buffer += stack1; }
|
||||
buffer += "\n <form accept-charset='UTF-8' class='sandbox'>\n <div style='margin:0;padding:0;display:inline'></div>\n ";
|
||||
buffer += "\n <form accept-charset='UTF-8' class='sandbox'>\n <div style='margin:0;padding:0;display:inline'></div>\n ";
|
||||
stack1 = helpers['if'].call(depth0, depth0.parameters, {hash:{},inverse:self.noop,fn:self.program(5, program5, data),data:data});
|
||||
if(stack1 || stack1 === 0) { buffer += stack1; }
|
||||
buffer += "\n ";
|
||||
buffer += "\n ";
|
||||
stack1 = helpers['if'].call(depth0, depth0.errorResponses, {hash:{},inverse:self.noop,fn:self.program(7, program7, data),data:data});
|
||||
if(stack1 || stack1 === 0) { buffer += stack1; }
|
||||
buffer += "\n ";
|
||||
buffer += "\n ";
|
||||
stack1 = helpers['if'].call(depth0, depth0.isReadOnly, {hash:{},inverse:self.program(11, program11, data),fn:self.program(9, program9, data),data:data});
|
||||
if(stack1 || stack1 === 0) { buffer += stack1; }
|
||||
buffer += "\n </form>\n <div class='response' style='display:none'>\n <h4>Request URL</h4>\n <div class='block request_url'></div>\n <h4>Response Body</h4>\n <div class='block response_body'></div>\n <h4>Response Code</h4>\n <div class='block response_code'></div>\n <h4>Response Headers</h4>\n <div class='block response_headers'></div>\n </div>\n </div>\n </li>\n </ul>\n";
|
||||
buffer += "\n </form>\n <div class='response' style='display:none'>\n <h4>Request URL</h4>\n <div class='block request_url'></div>\n <h4>Response Body</h4>\n <div class='block response_body'></div>\n <h4>Response Code</h4>\n <div class='block response_code'></div>\n <h4>Response Headers</h4>\n <div class='block response_headers'></div>\n </div>\n </div>\n </li>\n </ul>\n";
|
||||
return buffer;
|
||||
});
|
||||
})();
|
||||
@@ -598,43 +598,43 @@ helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
|
||||
function program1(depth0,data) {
|
||||
|
||||
|
||||
return "\n ";
|
||||
return "\n ";
|
||||
}
|
||||
|
||||
function program3(depth0,data) {
|
||||
|
||||
var buffer = "", stack1;
|
||||
buffer += "\n ";
|
||||
buffer += "\n ";
|
||||
stack1 = helpers['if'].call(depth0, depth0.defaultValue, {hash:{},inverse:self.program(6, program6, data),fn:self.program(4, program4, data),data:data});
|
||||
if(stack1 || stack1 === 0) { buffer += stack1; }
|
||||
buffer += "\n ";
|
||||
buffer += "\n ";
|
||||
return buffer;
|
||||
}
|
||||
function program4(depth0,data) {
|
||||
|
||||
|
||||
return "\n ";
|
||||
return "\n ";
|
||||
}
|
||||
|
||||
function program6(depth0,data) {
|
||||
|
||||
|
||||
return "\n <option selected=\"\" value=''></option>\n ";
|
||||
return "\n <option selected=\"\" value=''></option>\n ";
|
||||
}
|
||||
|
||||
function program8(depth0,data) {
|
||||
|
||||
var buffer = "", stack1;
|
||||
buffer += "\n ";
|
||||
buffer += "\n ";
|
||||
stack1 = helpers['if'].call(depth0, depth0.isDefault, {hash:{},inverse:self.program(11, program11, data),fn:self.program(9, program9, data),data:data});
|
||||
if(stack1 || stack1 === 0) { buffer += stack1; }
|
||||
buffer += "\n ";
|
||||
buffer += "\n ";
|
||||
return buffer;
|
||||
}
|
||||
function program9(depth0,data) {
|
||||
|
||||
var buffer = "", stack1;
|
||||
buffer += "\n <option value='";
|
||||
buffer += "\n <option value='";
|
||||
if (stack1 = helpers.value) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
|
||||
else { stack1 = depth0.value; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
|
||||
buffer += escapeExpression(stack1)
|
||||
@@ -642,14 +642,14 @@ function program9(depth0,data) {
|
||||
if (stack1 = helpers.value) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
|
||||
else { stack1 = depth0.value; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
|
||||
buffer += escapeExpression(stack1)
|
||||
+ " (default)</option>\n ";
|
||||
+ " (default)</option>\n ";
|
||||
return buffer;
|
||||
}
|
||||
|
||||
function program11(depth0,data) {
|
||||
|
||||
var buffer = "", stack1;
|
||||
buffer += "\n <option value='";
|
||||
buffer += "\n <option value='";
|
||||
if (stack1 = helpers.value) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
|
||||
else { stack1 = depth0.value; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
|
||||
buffer += escapeExpression(stack1)
|
||||
@@ -657,7 +657,7 @@ function program11(depth0,data) {
|
||||
if (stack1 = helpers.value) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
|
||||
else { stack1 = depth0.value; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
|
||||
buffer += escapeExpression(stack1)
|
||||
+ "</option>\n ";
|
||||
+ "</option>\n ";
|
||||
return buffer;
|
||||
}
|
||||
|
||||
@@ -665,17 +665,17 @@ function program11(depth0,data) {
|
||||
if (stack1 = helpers.name) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
|
||||
else { stack1 = depth0.name; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
|
||||
buffer += escapeExpression(stack1)
|
||||
+ "</td>\n<td>\n <select class='parameter' name='";
|
||||
+ "</td>\n<td>\n <select class='parameter' name='";
|
||||
if (stack1 = helpers.name) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
|
||||
else { stack1 = depth0.name; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
|
||||
buffer += escapeExpression(stack1)
|
||||
+ "'>\n ";
|
||||
+ "'>\n ";
|
||||
stack1 = helpers['if'].call(depth0, depth0.required, {hash:{},inverse:self.program(3, program3, data),fn:self.program(1, program1, data),data:data});
|
||||
if(stack1 || stack1 === 0) { buffer += stack1; }
|
||||
buffer += "\n ";
|
||||
buffer += "\n ";
|
||||
stack2 = helpers.each.call(depth0, ((stack1 = depth0.allowableValues),stack1 == null || stack1 === false ? stack1 : stack1.descriptiveValues), {hash:{},inverse:self.noop,fn:self.program(8, program8, data),data:data});
|
||||
if(stack2 || stack2 === 0) { buffer += stack2; }
|
||||
buffer += "\n </select>\n</td>\n<td>";
|
||||
buffer += "\n </select>\n</td>\n<td>";
|
||||
if (stack2 = helpers.description) { stack2 = stack2.call(depth0, {hash:{},data:data}); }
|
||||
else { stack2 = depth0.description; stack2 = typeof stack2 === functionType ? stack2.apply(depth0) : stack2; }
|
||||
if(stack2 || stack2 === 0) { buffer += stack2; }
|
||||
@@ -1515,7 +1515,7 @@ helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
|
||||
};
|
||||
|
||||
OperationView.prototype.submitOperation = function(e) {
|
||||
var error_free, form, map, o, opts, _i, _j, _len, _len1, _ref, _ref1;
|
||||
var error_free, form, map, o, opts, _i, _j, _k, _len, _len1, _len2, _ref, _ref1, _ref2;
|
||||
if (e != null) {
|
||||
e.preventDefault();
|
||||
}
|
||||
@@ -1553,6 +1553,13 @@ helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
|
||||
map["body"] = o.value;
|
||||
}
|
||||
}
|
||||
_ref2 = form.find("select");
|
||||
for (_k = 0, _len2 = _ref2.length; _k < _len2; _k++) {
|
||||
o = _ref2[_k];
|
||||
if ((o.value != null) && jQuery.trim(o.value).length > 0) {
|
||||
map[o.name] = o.value;
|
||||
}
|
||||
}
|
||||
opts.responseContentType = $("div select[name=responseContentType]", $(this.el)).val();
|
||||
opts.requestContentType = $("div select[name=parameterContentType]", $(this.el)).val();
|
||||
return this.model["do"](map, opts, this.showCompleteStatus, this.showErrorStatus, this);
|
||||
|
||||
2
dist/swagger-ui.min.js
vendored
2
dist/swagger-ui.min.js
vendored
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user