merged from develop
This commit is contained in:
3
dist/index.html
vendored
3
dist/index.html
vendored
@@ -16,6 +16,7 @@
|
|||||||
<script src='lib/underscore-min.js' type='text/javascript'></script>
|
<script src='lib/underscore-min.js' type='text/javascript'></script>
|
||||||
<script src='lib/backbone-min.js' type='text/javascript'></script>
|
<script src='lib/backbone-min.js' type='text/javascript'></script>
|
||||||
<script src='lib/swagger.js' type='text/javascript'></script>
|
<script src='lib/swagger.js' type='text/javascript'></script>
|
||||||
|
<script src='lib/swagger-client.js' type='text/javascript'></script>
|
||||||
<script src='swagger-ui.js' type='text/javascript'></script>
|
<script src='swagger-ui.js' type='text/javascript'></script>
|
||||||
<script src='lib/highlight.7.3.pack.js' type='text/javascript'></script>
|
<script src='lib/highlight.7.3.pack.js' type='text/javascript'></script>
|
||||||
|
|
||||||
@@ -25,7 +26,7 @@
|
|||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
$(function () {
|
$(function () {
|
||||||
window.swaggerUi = new SwaggerUi({
|
window.swaggerUi = new SwaggerUi({
|
||||||
url: "http://petstore.swagger.wordnik.com/api/api-docs",
|
url: "http://petstore.swagger.wordnik.com/v2/swagger.json",
|
||||||
dom_id: "swagger-ui-container",
|
dom_id: "swagger-ui-container",
|
||||||
supportedSubmitMethods: ['get', 'post', 'put', 'delete'],
|
supportedSubmitMethods: ['get', 'post', 'put', 'delete'],
|
||||||
onComplete: function(swaggerApi, swaggerUi){
|
onComplete: function(swaggerApi, swaggerUi){
|
||||||
|
|||||||
1342
dist/lib/swagger-client.js
vendored
Normal file
1342
dist/lib/swagger-client.js
vendored
Normal file
File diff suppressed because it is too large
Load Diff
72
dist/lib/swagger.js
vendored
72
dist/lib/swagger.js
vendored
@@ -1,5 +1,7 @@
|
|||||||
// swagger.js
|
// swagger.js
|
||||||
// version 2.0.39
|
// version 2.0.41
|
||||||
|
|
||||||
|
(function () {
|
||||||
|
|
||||||
var __bind = function (fn, me) {
|
var __bind = function (fn, me) {
|
||||||
return function () {
|
return function () {
|
||||||
@@ -7,7 +9,7 @@ var __bind = function(fn, me){
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
log = function(){
|
var log = function () {
|
||||||
log.history = log.history || [];
|
log.history = log.history || [];
|
||||||
log.history.push(arguments);
|
log.history.push(arguments);
|
||||||
if (this.console) {
|
if (this.console) {
|
||||||
@@ -16,12 +18,12 @@ log = function(){
|
|||||||
};
|
};
|
||||||
|
|
||||||
// if you want to apply conditional formatting of parameter values
|
// if you want to apply conditional formatting of parameter values
|
||||||
parameterMacro = function(value) {
|
var parameterMacro = function (value) {
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
// if you want to apply conditional formatting of model property values
|
// if you want to apply conditional formatting of model property values
|
||||||
modelPropertyMacro = function(value) {
|
var modelPropertyMacro = function (value) {
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -99,6 +101,7 @@ var SwaggerApi = function(url, options) {
|
|||||||
this.info = null;
|
this.info = null;
|
||||||
this.useJQuery = false;
|
this.useJQuery = false;
|
||||||
this.modelsArray = [];
|
this.modelsArray = [];
|
||||||
|
this.isValid;
|
||||||
|
|
||||||
options = (options || {});
|
options = (options || {});
|
||||||
if (url)
|
if (url)
|
||||||
@@ -201,18 +204,19 @@ SwaggerApi.prototype.buildFromSpec = function(response) {
|
|||||||
if (isApi) {
|
if (isApi) {
|
||||||
var newName = response.resourcePath.replace(/\//g, '');
|
var newName = response.resourcePath.replace(/\//g, '');
|
||||||
this.resourcePath = response.resourcePath;
|
this.resourcePath = response.resourcePath;
|
||||||
res = new SwaggerResource(response, this);
|
var res = new SwaggerResource(response, this);
|
||||||
this.apis[newName] = res;
|
this.apis[newName] = res;
|
||||||
this.apisArray.push(res);
|
this.apisArray.push(res);
|
||||||
} else {
|
} else {
|
||||||
var k;
|
var k;
|
||||||
for (k = 0; k < response.apis.length; k++) {
|
for (k = 0; k < response.apis.length; k++) {
|
||||||
var resource = response.apis[k];
|
var resource = response.apis[k];
|
||||||
res = new SwaggerResource(resource, this);
|
var res = new SwaggerResource(resource, this);
|
||||||
this.apis[res.name] = res;
|
this.apis[res.name] = res;
|
||||||
this.apisArray.push(res);
|
this.apisArray.push(res);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
this.isValid = true;
|
||||||
if (this.success) {
|
if (this.success) {
|
||||||
this.success();
|
this.success();
|
||||||
}
|
}
|
||||||
@@ -255,11 +259,12 @@ SwaggerApi.prototype.buildFrom1_1Spec = function(response) {
|
|||||||
} else {
|
} else {
|
||||||
for (k = 0; k < response.apis.length; k++) {
|
for (k = 0; k < response.apis.length; k++) {
|
||||||
resource = response.apis[k];
|
resource = response.apis[k];
|
||||||
res = new SwaggerResource(resource, this);
|
var res = new SwaggerResource(resource, this);
|
||||||
this.apis[res.name] = res;
|
this.apis[res.name] = res;
|
||||||
this.apisArray.push(res);
|
this.apisArray.push(res);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
this.isValid = true;
|
||||||
if (this.success) {
|
if (this.success) {
|
||||||
this.success();
|
this.success();
|
||||||
}
|
}
|
||||||
@@ -336,8 +341,8 @@ var SwaggerResource = function(resourceObj, api) {
|
|||||||
var _this = this;
|
var _this = this;
|
||||||
this.api = api;
|
this.api = api;
|
||||||
this.api = this.api;
|
this.api = this.api;
|
||||||
consumes = (this.consumes | []);
|
var consumes = (this.consumes | []);
|
||||||
produces = (this.produces | []);
|
var produces = (this.produces | []);
|
||||||
this.path = this.api.resourcePath != null ? this.api.resourcePath : resourceObj.path;
|
this.path = this.api.resourcePath != null ? this.api.resourcePath : resourceObj.path;
|
||||||
this.description = resourceObj.description;
|
this.description = resourceObj.description;
|
||||||
|
|
||||||
@@ -363,7 +368,7 @@ var SwaggerResource = function(resourceObj, api) {
|
|||||||
this.url = this.api.basePath + this.path.replace('{format}', 'json');
|
this.url = this.api.basePath + this.path.replace('{format}', 'json');
|
||||||
}
|
}
|
||||||
this.api.progress('fetching resource ' + this.name + ': ' + this.url);
|
this.api.progress('fetching resource ' + this.name + ': ' + this.url);
|
||||||
obj = {
|
var obj = {
|
||||||
url: this.url,
|
url: this.url,
|
||||||
method: "get",
|
method: "get",
|
||||||
useJQuery: this.useJQuery,
|
useJQuery: this.useJQuery,
|
||||||
@@ -445,7 +450,7 @@ SwaggerResource.prototype.addModels = function(models) {
|
|||||||
}
|
}
|
||||||
var output = [];
|
var output = [];
|
||||||
for (var i = 0; i < this.modelsArray.length; i++) {
|
for (var i = 0; i < this.modelsArray.length; i++) {
|
||||||
model = this.modelsArray[i];
|
var model = this.modelsArray[i];
|
||||||
output.push(model.setReferencedModels(this.models));
|
output.push(model.setReferencedModels(this.models));
|
||||||
}
|
}
|
||||||
return output;
|
return output;
|
||||||
@@ -454,9 +459,9 @@ SwaggerResource.prototype.addModels = function(models) {
|
|||||||
|
|
||||||
SwaggerResource.prototype.addOperations = function (resource_path, ops, consumes, produces) {
|
SwaggerResource.prototype.addOperations = function (resource_path, ops, consumes, produces) {
|
||||||
if (ops) {
|
if (ops) {
|
||||||
output = [];
|
var output = [];
|
||||||
for (var i = 0; i < ops.length; i++) {
|
for (var i = 0; i < ops.length; i++) {
|
||||||
o = ops[i];
|
var o = ops[i];
|
||||||
consumes = this.consumes;
|
consumes = this.consumes;
|
||||||
produces = this.produces;
|
produces = this.produces;
|
||||||
if (o.consumes != null)
|
if (o.consumes != null)
|
||||||
@@ -468,7 +473,7 @@ SwaggerResource.prototype.addOperations = function(resource_path, ops, consumes,
|
|||||||
produces = o.produces;
|
produces = o.produces;
|
||||||
else
|
else
|
||||||
produces = this.produces;
|
produces = this.produces;
|
||||||
type = (o.type||o.responseClass);
|
var type = (o.type || o.responseClass);
|
||||||
|
|
||||||
if (type === "array") {
|
if (type === "array") {
|
||||||
ref = null;
|
ref = null;
|
||||||
@@ -476,8 +481,8 @@ SwaggerResource.prototype.addOperations = function(resource_path, ops, consumes,
|
|||||||
ref = o.items["type"] || o.items["$ref"];
|
ref = o.items["type"] || o.items["$ref"];
|
||||||
type = "array[" + ref + "]";
|
type = "array[" + ref + "]";
|
||||||
}
|
}
|
||||||
responseMessages = o.responseMessages;
|
var responseMessages = o.responseMessages;
|
||||||
method = o.method;
|
var method = o.method;
|
||||||
if (o.httpMethod) {
|
if (o.httpMethod) {
|
||||||
method = o.httpMethod;
|
method = o.httpMethod;
|
||||||
}
|
}
|
||||||
@@ -493,7 +498,7 @@ SwaggerResource.prototype.addOperations = function(resource_path, ops, consumes,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
o.nickname = this.sanitize(o.nickname);
|
o.nickname = this.sanitize(o.nickname);
|
||||||
op = new SwaggerOperation(o.nickname, resource_path, method, o.parameters, o.summary, o.notes, type, responseMessages, this, consumes, produces, o.authorizations);
|
var op = new SwaggerOperation(o.nickname, resource_path, method, o.parameters, o.summary, o.notes, type, responseMessages, this, consumes, produces, o.authorizations);
|
||||||
this.operations[op.nickname] = op;
|
this.operations[op.nickname] = op;
|
||||||
output.push(this.operationsArray.push(op));
|
output.push(this.operationsArray.push(op));
|
||||||
}
|
}
|
||||||
@@ -539,7 +544,7 @@ var SwaggerModel = function(modelName, obj) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
prop = new SwaggerModelProperty(propertyName, obj.properties[propertyName]);
|
var prop = new SwaggerModelProperty(propertyName, obj.properties[propertyName]);
|
||||||
this.properties.push(prop);
|
this.properties.push(prop);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -562,7 +567,7 @@ SwaggerModel.prototype.setReferencedModels = function(allModels) {
|
|||||||
SwaggerModel.prototype.getMockSignature = function (modelsToIgnore) {
|
SwaggerModel.prototype.getMockSignature = function (modelsToIgnore) {
|
||||||
var propertiesStr = [];
|
var propertiesStr = [];
|
||||||
for (var i = 0; i < this.properties.length; i++) {
|
for (var i = 0; i < this.properties.length; i++) {
|
||||||
prop = this.properties[i];
|
var prop = this.properties[i];
|
||||||
propertiesStr.push(prop.toString());
|
propertiesStr.push(prop.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -577,7 +582,7 @@ SwaggerModel.prototype.getMockSignature = function(modelsToIgnore) {
|
|||||||
modelsToIgnore.push(this.name);
|
modelsToIgnore.push(this.name);
|
||||||
|
|
||||||
for (var i = 0; i < this.properties.length; i++) {
|
for (var i = 0; i < this.properties.length; i++) {
|
||||||
prop = this.properties[i];
|
var prop = this.properties[i];
|
||||||
if ((prop.refModel != null) && modelsToIgnore.indexOf(prop.refModel.name) === -1) {
|
if ((prop.refModel != null) && modelsToIgnore.indexOf(prop.refModel.name) === -1) {
|
||||||
returnVal = returnVal + ('<br>' + prop.refModel.getMockSignature(modelsToIgnore));
|
returnVal = returnVal + ('<br>' + prop.refModel.getMockSignature(modelsToIgnore));
|
||||||
}
|
}
|
||||||
@@ -594,7 +599,7 @@ SwaggerModel.prototype.createJSONSample = function(modelsToIgnore) {
|
|||||||
var modelsToIgnore = (modelsToIgnore || [])
|
var modelsToIgnore = (modelsToIgnore || [])
|
||||||
modelsToIgnore.push(this.name);
|
modelsToIgnore.push(this.name);
|
||||||
for (var i = 0; i < this.properties.length; i++) {
|
for (var i = 0; i < this.properties.length; i++) {
|
||||||
prop = this.properties[i];
|
var prop = this.properties[i];
|
||||||
result[prop.name] = prop.getSampleValue(modelsToIgnore);
|
result[prop.name] = prop.getSampleValue(modelsToIgnore);
|
||||||
}
|
}
|
||||||
modelsToIgnore.pop(this.name);
|
modelsToIgnore.pop(this.name);
|
||||||
@@ -636,7 +641,7 @@ var SwaggerModelProperty = function(name, obj) {
|
|||||||
|
|
||||||
SwaggerModelProperty.prototype.getSampleValue = function (modelsToIgnore) {
|
SwaggerModelProperty.prototype.getSampleValue = function (modelsToIgnore) {
|
||||||
var result;
|
var result;
|
||||||
if ((this.refModel != null) && (modelsToIgnore.indexOf(prop.refModel.name) === -1)) {
|
if ((this.refModel != null) && (modelsToIgnore.indexOf(this.refModel.name) === -1)) {
|
||||||
result = this.refModel.createJSONSample(modelsToIgnore);
|
result = this.refModel.createJSONSample(modelsToIgnore);
|
||||||
} else {
|
} else {
|
||||||
if (this.isCollection) {
|
if (this.isCollection) {
|
||||||
@@ -704,8 +709,10 @@ var SwaggerOperation = function(nickname, path, method, parameters, summary, not
|
|||||||
this.authorizations = authorizations;
|
this.authorizations = authorizations;
|
||||||
this["do"] = __bind(this["do"], this);
|
this["do"] = __bind(this["do"], this);
|
||||||
|
|
||||||
if (errors.length > 0)
|
if (errors.length > 0) {
|
||||||
|
console.error('SwaggerOperation errors', errors, arguments);
|
||||||
this.resource.api.fail(errors);
|
this.resource.api.fail(errors);
|
||||||
|
}
|
||||||
|
|
||||||
this.path = this.path.replace('{format}', 'json');
|
this.path = this.path.replace('{format}', 'json');
|
||||||
this.method = this.method.toLowerCase();
|
this.method = this.method.toLowerCase();
|
||||||
@@ -907,7 +914,7 @@ SwaggerOperation.prototype["do"] = function(args, opts, callback, error) {
|
|||||||
if (possibleParams) {
|
if (possibleParams) {
|
||||||
var key;
|
var key;
|
||||||
for (key in possibleParams) {
|
for (key in possibleParams) {
|
||||||
value = possibleParams[key];
|
var value = possibleParams[key];
|
||||||
if (args[value.name]) {
|
if (args[value.name]) {
|
||||||
params[value.name] = args[value.name];
|
params[value.name] = args[value.name];
|
||||||
}
|
}
|
||||||
@@ -954,7 +961,7 @@ SwaggerOperation.prototype.urlify = function(args) {
|
|||||||
if (param.paramType === 'path') {
|
if (param.paramType === 'path') {
|
||||||
if (args[param.name]) {
|
if (args[param.name]) {
|
||||||
// apply path params and remove from args
|
// apply path params and remove from args
|
||||||
var reg = new RegExp('\{' + param.name + '[^\}]*\}', 'gi');
|
var reg = new RegExp('\\{\\s*?' + param.name + '.*?\\}(?=\\s*?(\\/|$))', 'gi');
|
||||||
url = url.replace(reg, this.encodePathParam(args[param.name]));
|
url = url.replace(reg, this.encodePathParam(args[param.name]));
|
||||||
delete args[param.name];
|
delete args[param.name];
|
||||||
}
|
}
|
||||||
@@ -1135,7 +1142,7 @@ var SwaggerRequest = function(type, url, params, opts, successCallback, errorCal
|
|||||||
|
|
||||||
if (headers["Content-Type"].indexOf("application/x-www-form-urlencoded") === 0) {
|
if (headers["Content-Type"].indexOf("application/x-www-form-urlencoded") === 0) {
|
||||||
var encoded = "";
|
var encoded = "";
|
||||||
var key;
|
var key, value;
|
||||||
for (key in values) {
|
for (key in values) {
|
||||||
value = this.params[key];
|
value = this.params[key];
|
||||||
if (typeof value !== 'undefined') {
|
if (typeof value !== 'undefined') {
|
||||||
@@ -1150,7 +1157,7 @@ var SwaggerRequest = function(type, url, params, opts, successCallback, errorCal
|
|||||||
// encode the body for form submits
|
// encode the body for form submits
|
||||||
var data = "";
|
var data = "";
|
||||||
var boundary = "----SwaggerFormBoundary" + Date.now();
|
var boundary = "----SwaggerFormBoundary" + Date.now();
|
||||||
var key;
|
var key, value;
|
||||||
for (key in values) {
|
for (key in values) {
|
||||||
value = this.params[key];
|
value = this.params[key];
|
||||||
if (typeof value !== 'undefined') {
|
if (typeof value !== 'undefined') {
|
||||||
@@ -1166,6 +1173,7 @@ var SwaggerRequest = function(type, url, params, opts, successCallback, errorCal
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var obj;
|
||||||
if (!((this.headers != null) && (this.headers.mock != null))) {
|
if (!((this.headers != null) && (this.headers.mock != null))) {
|
||||||
obj = {
|
obj = {
|
||||||
url: this.url,
|
url: this.url,
|
||||||
@@ -1194,7 +1202,7 @@ var SwaggerRequest = function(type, url, params, opts, successCallback, errorCal
|
|||||||
} else {
|
} else {
|
||||||
e = exports;
|
e = exports;
|
||||||
}
|
}
|
||||||
status = e.authorizations.apply(obj, this.operation.authorizations);
|
var status = e.authorizations.apply(obj, this.operation.authorizations);
|
||||||
if (opts.mock == null) {
|
if (opts.mock == null) {
|
||||||
if (status !== false) {
|
if (status !== false) {
|
||||||
new SwaggerHttp().execute(obj);
|
new SwaggerHttp().execute(obj);
|
||||||
@@ -1205,6 +1213,7 @@ var SwaggerRequest = function(type, url, params, opts, successCallback, errorCal
|
|||||||
return obj;
|
return obj;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return obj;
|
||||||
};
|
};
|
||||||
|
|
||||||
SwaggerRequest.prototype.setHeaders = function (params, operation) {
|
SwaggerRequest.prototype.setHeaders = function (params, operation) {
|
||||||
@@ -1500,7 +1509,7 @@ ShredHttpClient.prototype.execute = function(obj) {
|
|||||||
return out;
|
return out;
|
||||||
};
|
};
|
||||||
|
|
||||||
res = {
|
var res = {
|
||||||
error: function (response) {
|
error: function (response) {
|
||||||
if (obj)
|
if (obj)
|
||||||
return cb.error(transform(response));
|
return cb.error(transform(response));
|
||||||
@@ -1547,7 +1556,7 @@ SwaggerAuthorizations.prototype.remove = function(name) {
|
|||||||
|
|
||||||
SwaggerAuthorizations.prototype.apply = function (obj, authorizations) {
|
SwaggerAuthorizations.prototype.apply = function (obj, authorizations) {
|
||||||
var status = null;
|
var status = null;
|
||||||
var key;
|
var key, value, result;
|
||||||
|
|
||||||
// if the "authorizations" key is undefined, or has an empty array, add all keys
|
// if the "authorizations" key is undefined, or has an empty array, add all keys
|
||||||
if (typeof authorizations === 'undefined' || Object.keys(authorizations).length == 0) {
|
if (typeof authorizations === 'undefined' || Object.keys(authorizations).length == 0) {
|
||||||
@@ -1651,3 +1660,6 @@ e.SwaggerModel = SwaggerModel;
|
|||||||
e.SwaggerModelProperty = SwaggerModelProperty;
|
e.SwaggerModelProperty = SwaggerModelProperty;
|
||||||
e.SwaggerResource = SwaggerResource;
|
e.SwaggerResource = SwaggerResource;
|
||||||
e.SwaggerApi = SwaggerApi;
|
e.SwaggerApi = SwaggerApi;
|
||||||
|
e.log = log;
|
||||||
|
|
||||||
|
})();
|
||||||
|
|||||||
1342
lib/swagger-client.js
Normal file
1342
lib/swagger-client.js
Normal file
File diff suppressed because it is too large
Load Diff
@@ -1,5 +1,7 @@
|
|||||||
// swagger.js
|
// swagger.js
|
||||||
// version 2.0.39
|
// version 2.0.41
|
||||||
|
|
||||||
|
(function () {
|
||||||
|
|
||||||
var __bind = function (fn, me) {
|
var __bind = function (fn, me) {
|
||||||
return function () {
|
return function () {
|
||||||
@@ -7,7 +9,7 @@ var __bind = function(fn, me){
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
log = function(){
|
var log = function () {
|
||||||
log.history = log.history || [];
|
log.history = log.history || [];
|
||||||
log.history.push(arguments);
|
log.history.push(arguments);
|
||||||
if (this.console) {
|
if (this.console) {
|
||||||
@@ -16,12 +18,12 @@ log = function(){
|
|||||||
};
|
};
|
||||||
|
|
||||||
// if you want to apply conditional formatting of parameter values
|
// if you want to apply conditional formatting of parameter values
|
||||||
parameterMacro = function(value) {
|
var parameterMacro = function (value) {
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
// if you want to apply conditional formatting of model property values
|
// if you want to apply conditional formatting of model property values
|
||||||
modelPropertyMacro = function(value) {
|
var modelPropertyMacro = function (value) {
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -99,6 +101,7 @@ var SwaggerApi = function(url, options) {
|
|||||||
this.info = null;
|
this.info = null;
|
||||||
this.useJQuery = false;
|
this.useJQuery = false;
|
||||||
this.modelsArray = [];
|
this.modelsArray = [];
|
||||||
|
this.isValid;
|
||||||
|
|
||||||
options = (options || {});
|
options = (options || {});
|
||||||
if (url)
|
if (url)
|
||||||
@@ -201,18 +204,19 @@ SwaggerApi.prototype.buildFromSpec = function(response) {
|
|||||||
if (isApi) {
|
if (isApi) {
|
||||||
var newName = response.resourcePath.replace(/\//g, '');
|
var newName = response.resourcePath.replace(/\//g, '');
|
||||||
this.resourcePath = response.resourcePath;
|
this.resourcePath = response.resourcePath;
|
||||||
res = new SwaggerResource(response, this);
|
var res = new SwaggerResource(response, this);
|
||||||
this.apis[newName] = res;
|
this.apis[newName] = res;
|
||||||
this.apisArray.push(res);
|
this.apisArray.push(res);
|
||||||
} else {
|
} else {
|
||||||
var k;
|
var k;
|
||||||
for (k = 0; k < response.apis.length; k++) {
|
for (k = 0; k < response.apis.length; k++) {
|
||||||
var resource = response.apis[k];
|
var resource = response.apis[k];
|
||||||
res = new SwaggerResource(resource, this);
|
var res = new SwaggerResource(resource, this);
|
||||||
this.apis[res.name] = res;
|
this.apis[res.name] = res;
|
||||||
this.apisArray.push(res);
|
this.apisArray.push(res);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
this.isValid = true;
|
||||||
if (this.success) {
|
if (this.success) {
|
||||||
this.success();
|
this.success();
|
||||||
}
|
}
|
||||||
@@ -255,11 +259,12 @@ SwaggerApi.prototype.buildFrom1_1Spec = function(response) {
|
|||||||
} else {
|
} else {
|
||||||
for (k = 0; k < response.apis.length; k++) {
|
for (k = 0; k < response.apis.length; k++) {
|
||||||
resource = response.apis[k];
|
resource = response.apis[k];
|
||||||
res = new SwaggerResource(resource, this);
|
var res = new SwaggerResource(resource, this);
|
||||||
this.apis[res.name] = res;
|
this.apis[res.name] = res;
|
||||||
this.apisArray.push(res);
|
this.apisArray.push(res);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
this.isValid = true;
|
||||||
if (this.success) {
|
if (this.success) {
|
||||||
this.success();
|
this.success();
|
||||||
}
|
}
|
||||||
@@ -336,8 +341,8 @@ var SwaggerResource = function(resourceObj, api) {
|
|||||||
var _this = this;
|
var _this = this;
|
||||||
this.api = api;
|
this.api = api;
|
||||||
this.api = this.api;
|
this.api = this.api;
|
||||||
consumes = (this.consumes | []);
|
var consumes = (this.consumes | []);
|
||||||
produces = (this.produces | []);
|
var produces = (this.produces | []);
|
||||||
this.path = this.api.resourcePath != null ? this.api.resourcePath : resourceObj.path;
|
this.path = this.api.resourcePath != null ? this.api.resourcePath : resourceObj.path;
|
||||||
this.description = resourceObj.description;
|
this.description = resourceObj.description;
|
||||||
|
|
||||||
@@ -363,7 +368,7 @@ var SwaggerResource = function(resourceObj, api) {
|
|||||||
this.url = this.api.basePath + this.path.replace('{format}', 'json');
|
this.url = this.api.basePath + this.path.replace('{format}', 'json');
|
||||||
}
|
}
|
||||||
this.api.progress('fetching resource ' + this.name + ': ' + this.url);
|
this.api.progress('fetching resource ' + this.name + ': ' + this.url);
|
||||||
obj = {
|
var obj = {
|
||||||
url: this.url,
|
url: this.url,
|
||||||
method: "get",
|
method: "get",
|
||||||
useJQuery: this.useJQuery,
|
useJQuery: this.useJQuery,
|
||||||
@@ -445,7 +450,7 @@ SwaggerResource.prototype.addModels = function(models) {
|
|||||||
}
|
}
|
||||||
var output = [];
|
var output = [];
|
||||||
for (var i = 0; i < this.modelsArray.length; i++) {
|
for (var i = 0; i < this.modelsArray.length; i++) {
|
||||||
model = this.modelsArray[i];
|
var model = this.modelsArray[i];
|
||||||
output.push(model.setReferencedModels(this.models));
|
output.push(model.setReferencedModels(this.models));
|
||||||
}
|
}
|
||||||
return output;
|
return output;
|
||||||
@@ -454,9 +459,9 @@ SwaggerResource.prototype.addModels = function(models) {
|
|||||||
|
|
||||||
SwaggerResource.prototype.addOperations = function (resource_path, ops, consumes, produces) {
|
SwaggerResource.prototype.addOperations = function (resource_path, ops, consumes, produces) {
|
||||||
if (ops) {
|
if (ops) {
|
||||||
output = [];
|
var output = [];
|
||||||
for (var i = 0; i < ops.length; i++) {
|
for (var i = 0; i < ops.length; i++) {
|
||||||
o = ops[i];
|
var o = ops[i];
|
||||||
consumes = this.consumes;
|
consumes = this.consumes;
|
||||||
produces = this.produces;
|
produces = this.produces;
|
||||||
if (o.consumes != null)
|
if (o.consumes != null)
|
||||||
@@ -468,7 +473,7 @@ SwaggerResource.prototype.addOperations = function(resource_path, ops, consumes,
|
|||||||
produces = o.produces;
|
produces = o.produces;
|
||||||
else
|
else
|
||||||
produces = this.produces;
|
produces = this.produces;
|
||||||
type = (o.type||o.responseClass);
|
var type = (o.type || o.responseClass);
|
||||||
|
|
||||||
if (type === "array") {
|
if (type === "array") {
|
||||||
ref = null;
|
ref = null;
|
||||||
@@ -476,8 +481,8 @@ SwaggerResource.prototype.addOperations = function(resource_path, ops, consumes,
|
|||||||
ref = o.items["type"] || o.items["$ref"];
|
ref = o.items["type"] || o.items["$ref"];
|
||||||
type = "array[" + ref + "]";
|
type = "array[" + ref + "]";
|
||||||
}
|
}
|
||||||
responseMessages = o.responseMessages;
|
var responseMessages = o.responseMessages;
|
||||||
method = o.method;
|
var method = o.method;
|
||||||
if (o.httpMethod) {
|
if (o.httpMethod) {
|
||||||
method = o.httpMethod;
|
method = o.httpMethod;
|
||||||
}
|
}
|
||||||
@@ -493,7 +498,7 @@ SwaggerResource.prototype.addOperations = function(resource_path, ops, consumes,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
o.nickname = this.sanitize(o.nickname);
|
o.nickname = this.sanitize(o.nickname);
|
||||||
op = new SwaggerOperation(o.nickname, resource_path, method, o.parameters, o.summary, o.notes, type, responseMessages, this, consumes, produces, o.authorizations);
|
var op = new SwaggerOperation(o.nickname, resource_path, method, o.parameters, o.summary, o.notes, type, responseMessages, this, consumes, produces, o.authorizations);
|
||||||
this.operations[op.nickname] = op;
|
this.operations[op.nickname] = op;
|
||||||
output.push(this.operationsArray.push(op));
|
output.push(this.operationsArray.push(op));
|
||||||
}
|
}
|
||||||
@@ -539,7 +544,7 @@ var SwaggerModel = function(modelName, obj) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
prop = new SwaggerModelProperty(propertyName, obj.properties[propertyName]);
|
var prop = new SwaggerModelProperty(propertyName, obj.properties[propertyName]);
|
||||||
this.properties.push(prop);
|
this.properties.push(prop);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -562,7 +567,7 @@ SwaggerModel.prototype.setReferencedModels = function(allModels) {
|
|||||||
SwaggerModel.prototype.getMockSignature = function (modelsToIgnore) {
|
SwaggerModel.prototype.getMockSignature = function (modelsToIgnore) {
|
||||||
var propertiesStr = [];
|
var propertiesStr = [];
|
||||||
for (var i = 0; i < this.properties.length; i++) {
|
for (var i = 0; i < this.properties.length; i++) {
|
||||||
prop = this.properties[i];
|
var prop = this.properties[i];
|
||||||
propertiesStr.push(prop.toString());
|
propertiesStr.push(prop.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -577,7 +582,7 @@ SwaggerModel.prototype.getMockSignature = function(modelsToIgnore) {
|
|||||||
modelsToIgnore.push(this.name);
|
modelsToIgnore.push(this.name);
|
||||||
|
|
||||||
for (var i = 0; i < this.properties.length; i++) {
|
for (var i = 0; i < this.properties.length; i++) {
|
||||||
prop = this.properties[i];
|
var prop = this.properties[i];
|
||||||
if ((prop.refModel != null) && modelsToIgnore.indexOf(prop.refModel.name) === -1) {
|
if ((prop.refModel != null) && modelsToIgnore.indexOf(prop.refModel.name) === -1) {
|
||||||
returnVal = returnVal + ('<br>' + prop.refModel.getMockSignature(modelsToIgnore));
|
returnVal = returnVal + ('<br>' + prop.refModel.getMockSignature(modelsToIgnore));
|
||||||
}
|
}
|
||||||
@@ -594,7 +599,7 @@ SwaggerModel.prototype.createJSONSample = function(modelsToIgnore) {
|
|||||||
var modelsToIgnore = (modelsToIgnore || [])
|
var modelsToIgnore = (modelsToIgnore || [])
|
||||||
modelsToIgnore.push(this.name);
|
modelsToIgnore.push(this.name);
|
||||||
for (var i = 0; i < this.properties.length; i++) {
|
for (var i = 0; i < this.properties.length; i++) {
|
||||||
prop = this.properties[i];
|
var prop = this.properties[i];
|
||||||
result[prop.name] = prop.getSampleValue(modelsToIgnore);
|
result[prop.name] = prop.getSampleValue(modelsToIgnore);
|
||||||
}
|
}
|
||||||
modelsToIgnore.pop(this.name);
|
modelsToIgnore.pop(this.name);
|
||||||
@@ -636,7 +641,7 @@ var SwaggerModelProperty = function(name, obj) {
|
|||||||
|
|
||||||
SwaggerModelProperty.prototype.getSampleValue = function (modelsToIgnore) {
|
SwaggerModelProperty.prototype.getSampleValue = function (modelsToIgnore) {
|
||||||
var result;
|
var result;
|
||||||
if ((this.refModel != null) && (modelsToIgnore.indexOf(prop.refModel.name) === -1)) {
|
if ((this.refModel != null) && (modelsToIgnore.indexOf(this.refModel.name) === -1)) {
|
||||||
result = this.refModel.createJSONSample(modelsToIgnore);
|
result = this.refModel.createJSONSample(modelsToIgnore);
|
||||||
} else {
|
} else {
|
||||||
if (this.isCollection) {
|
if (this.isCollection) {
|
||||||
@@ -704,8 +709,10 @@ var SwaggerOperation = function(nickname, path, method, parameters, summary, not
|
|||||||
this.authorizations = authorizations;
|
this.authorizations = authorizations;
|
||||||
this["do"] = __bind(this["do"], this);
|
this["do"] = __bind(this["do"], this);
|
||||||
|
|
||||||
if (errors.length > 0)
|
if (errors.length > 0) {
|
||||||
|
console.error('SwaggerOperation errors', errors, arguments);
|
||||||
this.resource.api.fail(errors);
|
this.resource.api.fail(errors);
|
||||||
|
}
|
||||||
|
|
||||||
this.path = this.path.replace('{format}', 'json');
|
this.path = this.path.replace('{format}', 'json');
|
||||||
this.method = this.method.toLowerCase();
|
this.method = this.method.toLowerCase();
|
||||||
@@ -907,7 +914,7 @@ SwaggerOperation.prototype["do"] = function(args, opts, callback, error) {
|
|||||||
if (possibleParams) {
|
if (possibleParams) {
|
||||||
var key;
|
var key;
|
||||||
for (key in possibleParams) {
|
for (key in possibleParams) {
|
||||||
value = possibleParams[key];
|
var value = possibleParams[key];
|
||||||
if (args[value.name]) {
|
if (args[value.name]) {
|
||||||
params[value.name] = args[value.name];
|
params[value.name] = args[value.name];
|
||||||
}
|
}
|
||||||
@@ -954,7 +961,7 @@ SwaggerOperation.prototype.urlify = function(args) {
|
|||||||
if (param.paramType === 'path') {
|
if (param.paramType === 'path') {
|
||||||
if (args[param.name]) {
|
if (args[param.name]) {
|
||||||
// apply path params and remove from args
|
// apply path params and remove from args
|
||||||
var reg = new RegExp('\{' + param.name + '[^\}]*\}', 'gi');
|
var reg = new RegExp('\\{\\s*?' + param.name + '.*?\\}(?=\\s*?(\\/|$))', 'gi');
|
||||||
url = url.replace(reg, this.encodePathParam(args[param.name]));
|
url = url.replace(reg, this.encodePathParam(args[param.name]));
|
||||||
delete args[param.name];
|
delete args[param.name];
|
||||||
}
|
}
|
||||||
@@ -1135,7 +1142,7 @@ var SwaggerRequest = function(type, url, params, opts, successCallback, errorCal
|
|||||||
|
|
||||||
if (headers["Content-Type"].indexOf("application/x-www-form-urlencoded") === 0) {
|
if (headers["Content-Type"].indexOf("application/x-www-form-urlencoded") === 0) {
|
||||||
var encoded = "";
|
var encoded = "";
|
||||||
var key;
|
var key, value;
|
||||||
for (key in values) {
|
for (key in values) {
|
||||||
value = this.params[key];
|
value = this.params[key];
|
||||||
if (typeof value !== 'undefined') {
|
if (typeof value !== 'undefined') {
|
||||||
@@ -1150,7 +1157,7 @@ var SwaggerRequest = function(type, url, params, opts, successCallback, errorCal
|
|||||||
// encode the body for form submits
|
// encode the body for form submits
|
||||||
var data = "";
|
var data = "";
|
||||||
var boundary = "----SwaggerFormBoundary" + Date.now();
|
var boundary = "----SwaggerFormBoundary" + Date.now();
|
||||||
var key;
|
var key, value;
|
||||||
for (key in values) {
|
for (key in values) {
|
||||||
value = this.params[key];
|
value = this.params[key];
|
||||||
if (typeof value !== 'undefined') {
|
if (typeof value !== 'undefined') {
|
||||||
@@ -1166,6 +1173,7 @@ var SwaggerRequest = function(type, url, params, opts, successCallback, errorCal
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var obj;
|
||||||
if (!((this.headers != null) && (this.headers.mock != null))) {
|
if (!((this.headers != null) && (this.headers.mock != null))) {
|
||||||
obj = {
|
obj = {
|
||||||
url: this.url,
|
url: this.url,
|
||||||
@@ -1194,7 +1202,7 @@ var SwaggerRequest = function(type, url, params, opts, successCallback, errorCal
|
|||||||
} else {
|
} else {
|
||||||
e = exports;
|
e = exports;
|
||||||
}
|
}
|
||||||
status = e.authorizations.apply(obj, this.operation.authorizations);
|
var status = e.authorizations.apply(obj, this.operation.authorizations);
|
||||||
if (opts.mock == null) {
|
if (opts.mock == null) {
|
||||||
if (status !== false) {
|
if (status !== false) {
|
||||||
new SwaggerHttp().execute(obj);
|
new SwaggerHttp().execute(obj);
|
||||||
@@ -1205,6 +1213,7 @@ var SwaggerRequest = function(type, url, params, opts, successCallback, errorCal
|
|||||||
return obj;
|
return obj;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return obj;
|
||||||
};
|
};
|
||||||
|
|
||||||
SwaggerRequest.prototype.setHeaders = function (params, operation) {
|
SwaggerRequest.prototype.setHeaders = function (params, operation) {
|
||||||
@@ -1500,7 +1509,7 @@ ShredHttpClient.prototype.execute = function(obj) {
|
|||||||
return out;
|
return out;
|
||||||
};
|
};
|
||||||
|
|
||||||
res = {
|
var res = {
|
||||||
error: function (response) {
|
error: function (response) {
|
||||||
if (obj)
|
if (obj)
|
||||||
return cb.error(transform(response));
|
return cb.error(transform(response));
|
||||||
@@ -1547,7 +1556,7 @@ SwaggerAuthorizations.prototype.remove = function(name) {
|
|||||||
|
|
||||||
SwaggerAuthorizations.prototype.apply = function (obj, authorizations) {
|
SwaggerAuthorizations.prototype.apply = function (obj, authorizations) {
|
||||||
var status = null;
|
var status = null;
|
||||||
var key;
|
var key, value, result;
|
||||||
|
|
||||||
// if the "authorizations" key is undefined, or has an empty array, add all keys
|
// if the "authorizations" key is undefined, or has an empty array, add all keys
|
||||||
if (typeof authorizations === 'undefined' || Object.keys(authorizations).length == 0) {
|
if (typeof authorizations === 'undefined' || Object.keys(authorizations).length == 0) {
|
||||||
@@ -1651,3 +1660,6 @@ e.SwaggerModel = SwaggerModel;
|
|||||||
e.SwaggerModelProperty = SwaggerModelProperty;
|
e.SwaggerModelProperty = SwaggerModelProperty;
|
||||||
e.SwaggerResource = SwaggerResource;
|
e.SwaggerResource = SwaggerResource;
|
||||||
e.SwaggerApi = SwaggerApi;
|
e.SwaggerApi = SwaggerApi;
|
||||||
|
e.log = log;
|
||||||
|
|
||||||
|
})();
|
||||||
|
|||||||
@@ -22,9 +22,16 @@ class SwaggerUi extends Backbone.Router
|
|||||||
@options = options
|
@options = options
|
||||||
|
|
||||||
# Set the callbacks
|
# Set the callbacks
|
||||||
@options.success = => @render()
|
@options.success = =>
|
||||||
|
@render()
|
||||||
@options.progress = (d) => @showMessage(d)
|
@options.progress = (d) => @showMessage(d)
|
||||||
@options.failure = (d) => @onLoadFailure(d)
|
@options.failure = (d) =>
|
||||||
|
if @api and @api.isValid is false
|
||||||
|
log "not a valid 2.0 spec, loading legacy client"
|
||||||
|
@api = new SwaggerApi(@options)
|
||||||
|
@api.build()
|
||||||
|
else
|
||||||
|
@onLoadFailure(d)
|
||||||
|
|
||||||
# Create view to handle the header inputs
|
# Create view to handle the header inputs
|
||||||
@headerView = new HeaderView({el: $('#header')})
|
@headerView = new HeaderView({el: $('#header')})
|
||||||
@@ -47,9 +54,9 @@ class SwaggerUi extends Backbone.Router
|
|||||||
|
|
||||||
@options.url = url
|
@options.url = url
|
||||||
@headerView.update(url)
|
@headerView.update(url)
|
||||||
@api = new SwaggerApi(@options)
|
|
||||||
|
@api = new SwaggerClient(@options)
|
||||||
@api.build()
|
@api.build()
|
||||||
@api
|
|
||||||
|
|
||||||
# This is bound to success handler for SwaggerApi
|
# This is bound to success handler for SwaggerApi
|
||||||
# so it gets called when SwaggerApi completes loading
|
# so it gets called when SwaggerApi completes loading
|
||||||
|
|||||||
@@ -8,11 +8,20 @@ class MainView extends Backbone.View
|
|||||||
if opts.swaggerOptions.sorter
|
if opts.swaggerOptions.sorter
|
||||||
sorterName = opts.swaggerOptions.sorter
|
sorterName = opts.swaggerOptions.sorter
|
||||||
sorter = sorters[sorterName]
|
sorter = sorters[sorterName]
|
||||||
|
if @model.apisArray
|
||||||
for route in @model.apisArray
|
for route in @model.apisArray
|
||||||
route.operationsArray.sort sorter
|
route.operationsArray.sort sorter
|
||||||
if (sorterName == "alpha") # sort top level paths if alpha
|
if (sorterName == "alpha") # sort top level paths if alpha
|
||||||
@model.apisArray.sort sorter
|
@model.apisArray.sort sorter
|
||||||
|
|
||||||
|
log @model
|
||||||
|
if @model.info.license and typeof @model.info.license is 'string'
|
||||||
|
name = @model.info.license
|
||||||
|
url = @model.info.licenseUrl
|
||||||
|
@model.info.license = {}
|
||||||
|
@model.info.license.name = name
|
||||||
|
@model.info.license.url = url
|
||||||
|
|
||||||
render: ->
|
render: ->
|
||||||
# Render the outer container for resources
|
# Render the outer container for resources
|
||||||
$(@el).html(Handlebars.templates.main(@model))
|
$(@el).html(Handlebars.templates.main(@model))
|
||||||
@@ -33,6 +42,7 @@ class MainView extends Backbone.View
|
|||||||
|
|
||||||
addResource: (resource) ->
|
addResource: (resource) ->
|
||||||
# Render a resource and add it to resources li
|
# Render a resource and add it to resources li
|
||||||
|
resource.id = resource.id.replace(/\s/g, '_')
|
||||||
resourceView = new ResourceView({model: resource, tagName: 'li', id: 'resource_' + resource.id, className: 'resource', swaggerOptions: @options.swaggerOptions})
|
resourceView = new ResourceView({model: resource, tagName: 'li', id: 'resource_' + resource.id, className: 'resource', swaggerOptions: @options.swaggerOptions})
|
||||||
$('#resources').append resourceView.render().el
|
$('#resources').append resourceView.render().el
|
||||||
|
|
||||||
|
|||||||
@@ -66,6 +66,7 @@ class OperationView extends Backbone.View
|
|||||||
responseSignatureView = new SignatureView({model: signatureModel, tagName: 'div'})
|
responseSignatureView = new SignatureView({model: signatureModel, tagName: 'div'})
|
||||||
$('.model-signature', $(@el)).append responseSignatureView.render().el
|
$('.model-signature', $(@el)).append responseSignatureView.render().el
|
||||||
else
|
else
|
||||||
|
@model.responseClassSignature = 'string'
|
||||||
$('.model-signature', $(@el)).html(@model.type)
|
$('.model-signature', $(@el)).html(@model.type)
|
||||||
|
|
||||||
contentTypeModel =
|
contentTypeModel =
|
||||||
@@ -76,10 +77,18 @@ class OperationView extends Backbone.View
|
|||||||
|
|
||||||
for param in @model.parameters
|
for param in @model.parameters
|
||||||
type = param.type || param.dataType
|
type = param.type || param.dataType
|
||||||
if type.toLowerCase() == 'file'
|
if typeof type is 'undefined'
|
||||||
|
schema = param.schema
|
||||||
|
if schema['$ref']
|
||||||
|
ref = schema['$ref']
|
||||||
|
if ref.indexOf('#/definitions/') is 0
|
||||||
|
type = ref.substring('#/definitions/'.length)
|
||||||
|
else
|
||||||
|
type = ref
|
||||||
|
if type and type.toLowerCase() == 'file'
|
||||||
if !contentTypeModel.consumes
|
if !contentTypeModel.consumes
|
||||||
log "set content type "
|
|
||||||
contentTypeModel.consumes = 'multipart/form-data'
|
contentTypeModel.consumes = 'multipart/form-data'
|
||||||
|
param.type = type
|
||||||
|
|
||||||
responseContentTypeView = new ResponseContentTypeView({model: contentTypeModel})
|
responseContentTypeView = new ResponseContentTypeView({model: contentTypeModel})
|
||||||
$('.response-content-type', $(@el)).append responseContentTypeView.render().el
|
$('.response-content-type', $(@el)).append responseContentTypeView.render().el
|
||||||
@@ -88,6 +97,8 @@ class OperationView extends Backbone.View
|
|||||||
@addParameter param, contentTypeModel.consumes for param in @model.parameters
|
@addParameter param, contentTypeModel.consumes for param in @model.parameters
|
||||||
|
|
||||||
# Render each response code
|
# Render each response code
|
||||||
|
if typeof @model.responseMessages is 'undefined'
|
||||||
|
@model.responseMessages = []
|
||||||
@addStatusCode statusCode for statusCode in @model.responseMessages
|
@addStatusCode statusCode for statusCode in @model.responseMessages
|
||||||
|
|
||||||
@
|
@
|
||||||
@@ -171,8 +182,6 @@ class OperationView extends Backbone.View
|
|||||||
if param.paramType is 'header'
|
if param.paramType is 'header'
|
||||||
headerParams[param.name] = map[param.name]
|
headerParams[param.name] = map[param.name]
|
||||||
|
|
||||||
log headerParams
|
|
||||||
|
|
||||||
# add files
|
# add files
|
||||||
for el in form.find('input[type~="file"]')
|
for el in form.find('input[type~="file"]')
|
||||||
if typeof el.files[0] isnt 'undefined'
|
if typeof el.files[0] isnt 'undefined'
|
||||||
|
|||||||
@@ -9,8 +9,21 @@ class ParameterView extends Backbone.View
|
|||||||
|
|
||||||
render: ->
|
render: ->
|
||||||
type = @model.type || @model.dataType
|
type = @model.type || @model.dataType
|
||||||
|
|
||||||
|
if typeof type is 'undefined'
|
||||||
|
schema = @model.schema
|
||||||
|
if schema['$ref']
|
||||||
|
ref = schema['$ref']
|
||||||
|
if ref.indexOf('#/definitions/') is 0
|
||||||
|
type = ref.substring('#/definitions/'.length)
|
||||||
|
else
|
||||||
|
type = ref
|
||||||
|
|
||||||
|
@model.type = type
|
||||||
|
@model.paramType = @model.in || @model.paramType
|
||||||
@model.isBody = true if @model.paramType == 'body'
|
@model.isBody = true if @model.paramType == 'body'
|
||||||
@model.isFile = true if type.toLowerCase() == 'file'
|
@model.isFile = true if type and type.toLowerCase() == 'file'
|
||||||
|
#@model.signature = type
|
||||||
|
|
||||||
template = @template()
|
template = @template()
|
||||||
$(@el).html(template(@model))
|
$(@el).html(template(@model))
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
class ResourceView extends Backbone.View
|
class ResourceView extends Backbone.View
|
||||||
initialize: ->
|
initialize: ->
|
||||||
|
if "" is @model.description
|
||||||
|
@model.description = null
|
||||||
|
|
||||||
render: ->
|
render: ->
|
||||||
$(@el).html(Handlebars.templates.resource(@model))
|
$(@el).html(Handlebars.templates.resource(@model))
|
||||||
|
|||||||
@@ -16,6 +16,7 @@
|
|||||||
<script src='lib/underscore-min.js' type='text/javascript'></script>
|
<script src='lib/underscore-min.js' type='text/javascript'></script>
|
||||||
<script src='lib/backbone-min.js' type='text/javascript'></script>
|
<script src='lib/backbone-min.js' type='text/javascript'></script>
|
||||||
<script src='lib/swagger.js' type='text/javascript'></script>
|
<script src='lib/swagger.js' type='text/javascript'></script>
|
||||||
|
<script src='lib/swagger-client.js' type='text/javascript'></script>
|
||||||
<script src='swagger-ui.js' type='text/javascript'></script>
|
<script src='swagger-ui.js' type='text/javascript'></script>
|
||||||
<script src='lib/highlight.7.3.pack.js' type='text/javascript'></script>
|
<script src='lib/highlight.7.3.pack.js' type='text/javascript'></script>
|
||||||
|
|
||||||
@@ -25,7 +26,7 @@
|
|||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
$(function () {
|
$(function () {
|
||||||
window.swaggerUi = new SwaggerUi({
|
window.swaggerUi = new SwaggerUi({
|
||||||
url: "http://petstore.swagger.wordnik.com/api/api-docs",
|
url: "http://petstore.swagger.wordnik.com/v2/swagger.json",
|
||||||
dom_id: "swagger-ui-container",
|
dom_id: "swagger-ui-container",
|
||||||
supportedSubmitMethods: ['get', 'post', 'put', 'delete'],
|
supportedSubmitMethods: ['get', 'post', 'put', 'delete'],
|
||||||
onComplete: function(swaggerApi, swaggerUi){
|
onComplete: function(swaggerApi, swaggerUi){
|
||||||
|
|||||||
@@ -91,7 +91,6 @@ var Docs = {
|
|||||||
switch (fragments.length) {
|
switch (fragments.length) {
|
||||||
case 1:
|
case 1:
|
||||||
// Expand all operations for the resource and scroll to it
|
// Expand all operations for the resource and scroll to it
|
||||||
log('shebang resource:' + fragments[0]);
|
|
||||||
var dom_id = 'resource_' + fragments[0];
|
var dom_id = 'resource_' + fragments[0];
|
||||||
|
|
||||||
Docs.expandEndpointListForResource(fragments[0]);
|
Docs.expandEndpointListForResource(fragments[0]);
|
||||||
@@ -99,7 +98,6 @@ var Docs = {
|
|||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
// Refer to the endpoint DOM element, e.g. #words_get_search
|
// Refer to the endpoint DOM element, e.g. #words_get_search
|
||||||
log('shebang endpoint: ' + fragments.join('_'));
|
|
||||||
|
|
||||||
// Expand Resource
|
// Expand Resource
|
||||||
Docs.expandEndpointListForResource(fragments[0]);
|
Docs.expandEndpointListForResource(fragments[0]);
|
||||||
@@ -109,8 +107,6 @@ var Docs = {
|
|||||||
var li_dom_id = fragments.join('_');
|
var li_dom_id = fragments.join('_');
|
||||||
var li_content_dom_id = li_dom_id + "_content";
|
var li_content_dom_id = li_dom_id + "_content";
|
||||||
|
|
||||||
log("li_dom_id " + li_dom_id);
|
|
||||||
log("li_content_dom_id " + li_content_dom_id);
|
|
||||||
|
|
||||||
Docs.expandOperation($('#'+li_content_dom_id));
|
Docs.expandOperation($('#'+li_content_dom_id));
|
||||||
$('#'+li_dom_id).slideto({highlight: false});
|
$('#'+li_dom_id).slideto({highlight: false});
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
<div class="info_description">{{{info.description}}}</div>
|
<div class="info_description">{{{info.description}}}</div>
|
||||||
{{#if info.termsOfServiceUrl}}<div class="info_tos"><a href="{{info.termsOfServiceUrl}}">Terms of service</a></div>{{/if}}
|
{{#if info.termsOfServiceUrl}}<div class="info_tos"><a href="{{info.termsOfServiceUrl}}">Terms of service</a></div>{{/if}}
|
||||||
{{#if info.contact}}<div class='info_contact'><a href="mailto:{{info.contact}}">Contact the developer</a></div>{{/if}}
|
{{#if info.contact}}<div class='info_contact'><a href="mailto:{{info.contact}}">Contact the developer</a></div>{{/if}}
|
||||||
{{#if info.license}}<div class='info_license'><a href='{{info.licenseUrl}}'>{{info.license}}</a></div>{{/if}}
|
{{#if info.license}}<div class='info_license'><a href='{{info.license.name}}'>{{info.license.url}}</a></div>{{/if}}
|
||||||
{{/if}}
|
{{/if}}
|
||||||
</div>
|
</div>
|
||||||
<div class='container' id='resources_container'>
|
<div class='container' id='resources_container'>
|
||||||
|
|||||||
Reference in New Issue
Block a user