merged with swagger.js-2.0-develop
This commit is contained in:
16
dist/index.html
vendored
16
dist/index.html
vendored
@@ -5,6 +5,7 @@
|
|||||||
<link href='//fonts.googleapis.com/css?family=Droid+Sans:400,700' rel='stylesheet' type='text/css'/>
|
<link href='//fonts.googleapis.com/css?family=Droid+Sans:400,700' rel='stylesheet' type='text/css'/>
|
||||||
<link href='css/hightlight.default.css' media='screen' rel='stylesheet' type='text/css'/>
|
<link href='css/hightlight.default.css' media='screen' rel='stylesheet' type='text/css'/>
|
||||||
<link href='css/screen.css' media='screen' rel='stylesheet' type='text/css'/>
|
<link href='css/screen.css' media='screen' rel='stylesheet' type='text/css'/>
|
||||||
|
<script type="text/javascript" src="lib/shred.bundle.js" /></script>
|
||||||
<script src='lib/jquery-1.8.0.min.js' type='text/javascript'></script>
|
<script src='lib/jquery-1.8.0.min.js' type='text/javascript'></script>
|
||||||
<script src='lib/jquery.slideto.min.js' type='text/javascript'></script>
|
<script src='lib/jquery.slideto.min.js' type='text/javascript'></script>
|
||||||
<script src='lib/jquery.wiggle.min.js' type='text/javascript'></script>
|
<script src='lib/jquery.wiggle.min.js' type='text/javascript'></script>
|
||||||
@@ -15,15 +16,14 @@
|
|||||||
<script src='lib/swagger.js' type='text/javascript'></script>
|
<script src='lib/swagger.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>
|
||||||
|
<script src='lib/highlight.7.3.pack.js' type='text/javascript'></script>
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
$(function () {
|
$(function () {
|
||||||
window.swaggerUi = new SwaggerUi({
|
window.swaggerUi = new SwaggerUi({
|
||||||
discoveryUrl:"http://localhost:8002/api/api-docs",
|
discoveryUrl:"http://localhost:8002/api/api-docs",
|
||||||
apiKey:"special-key",
|
|
||||||
dom_id:"swagger-ui-container",
|
dom_id:"swagger-ui-container",
|
||||||
supportHeaderParams: false,
|
supportHeaderParams: false,
|
||||||
supportedSubmitMethods: ['get', 'post', 'put'],
|
supportedSubmitMethods: ['get', 'post', 'put', 'delete'],
|
||||||
onComplete: function(swaggerApi, swaggerUi){
|
onComplete: function(swaggerApi, swaggerUi){
|
||||||
if(console) {
|
if(console) {
|
||||||
console.log("Loaded SwaggerUI")
|
console.log("Loaded SwaggerUI")
|
||||||
@@ -41,6 +41,13 @@
|
|||||||
docExpansion: "none"
|
docExpansion: "none"
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$('#input_apiKey').change(function() {
|
||||||
|
var key = $('#input_apiKey')[0].value;
|
||||||
|
console.log("key: " + key);
|
||||||
|
if(key && key.trim() != "") {
|
||||||
|
window.authorizations.add("key", new ApiKeyAuthorization("api_key", key, "query"));
|
||||||
|
}
|
||||||
|
})
|
||||||
window.swaggerUi.load();
|
window.swaggerUi.load();
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -59,8 +66,7 @@
|
|||||||
<div class='input icon-btn'>
|
<div class='input icon-btn'>
|
||||||
<img id="show-wordnik-dev-icon" src="images/wordnik_api.png" title="Show Wordnik Developer Apis">
|
<img id="show-wordnik-dev-icon" src="images/wordnik_api.png" title="Show Wordnik Developer Apis">
|
||||||
</div>
|
</div>
|
||||||
<div class='input'><input placeholder="http://example.com/api" id="input_baseUrl" name="baseUrl"
|
<div class='input'><input placeholder="http://example.com/api" id="input_baseUrl" name="baseUrl" type="text"/></div>
|
||||||
type="text"/></div>
|
|
||||||
<div class='input'><input placeholder="api_key" id="input_apiKey" name="apiKey" type="text"/></div>
|
<div class='input'><input placeholder="api_key" id="input_apiKey" name="apiKey" type="text"/></div>
|
||||||
<div class='input'><a id="explore" href="#">Explore</a></div>
|
<div class='input'><a id="explore" href="#">Explore</a></div>
|
||||||
</form>
|
</form>
|
||||||
|
|||||||
588
dist/lib/swagger.js
vendored
588
dist/lib/swagger.js
vendored
@@ -1,6 +1,6 @@
|
|||||||
// Generated by CoffeeScript 1.4.0
|
// Generated by CoffeeScript 1.4.0
|
||||||
(function() {
|
(function() {
|
||||||
var SwaggerApi, SwaggerModel, SwaggerModelProperty, SwaggerOperation, SwaggerRequest, SwaggerResource,
|
var ApiKeyAuthorization, SwaggerApi, SwaggerAuthorizations, SwaggerHttp, SwaggerModel, SwaggerModelProperty, SwaggerOperation, SwaggerRequest, SwaggerResource,
|
||||||
__bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };
|
__bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };
|
||||||
|
|
||||||
SwaggerApi = (function() {
|
SwaggerApi = (function() {
|
||||||
@@ -9,10 +9,12 @@
|
|||||||
|
|
||||||
SwaggerApi.prototype.debug = false;
|
SwaggerApi.prototype.debug = false;
|
||||||
|
|
||||||
SwaggerApi.prototype.api_key = null;
|
|
||||||
|
|
||||||
SwaggerApi.prototype.basePath = null;
|
SwaggerApi.prototype.basePath = null;
|
||||||
|
|
||||||
|
SwaggerApi.prototype.authorizations = null;
|
||||||
|
|
||||||
|
SwaggerApi.prototype.authorizationScheme = null;
|
||||||
|
|
||||||
function SwaggerApi(options) {
|
function SwaggerApi(options) {
|
||||||
if (options == null) {
|
if (options == null) {
|
||||||
options = {};
|
options = {};
|
||||||
@@ -20,87 +22,27 @@
|
|||||||
if (options.discoveryUrl != null) {
|
if (options.discoveryUrl != null) {
|
||||||
this.discoveryUrl = options.discoveryUrl;
|
this.discoveryUrl = options.discoveryUrl;
|
||||||
}
|
}
|
||||||
if (options.debug != null) {
|
|
||||||
this.debug = options.debug;
|
|
||||||
}
|
|
||||||
this.apiKeyName = options.apiKeyName != null ? options.apiKeyName : 'api_key';
|
|
||||||
if (options.apiKey != null) {
|
|
||||||
this.api_key = options.apiKey;
|
|
||||||
}
|
|
||||||
if (options.api_key != null) {
|
|
||||||
this.api_key = options.api_key;
|
|
||||||
}
|
|
||||||
if (options.verbose != null) {
|
|
||||||
this.verbose = options.verbose;
|
|
||||||
}
|
|
||||||
this.supportHeaderParams = options.supportHeaderParams != null ? options.supportHeaderParams : false;
|
|
||||||
this.supportedSubmitMethods = options.supportedSubmitMethods != null ? options.supportedSubmitMethods : ['get'];
|
this.supportedSubmitMethods = options.supportedSubmitMethods != null ? options.supportedSubmitMethods : ['get'];
|
||||||
if (options.success != null) {
|
if (options.success != null) {
|
||||||
this.success = options.success;
|
this.success = options.success;
|
||||||
}
|
}
|
||||||
this.failure = options.failure != null ? options.failure : function() {};
|
this.failure = options.failure != null ? options.failure : function() {};
|
||||||
this.progress = options.progress != null ? options.progress : function() {};
|
this.progress = options.progress != null ? options.progress : function() {};
|
||||||
this.headers = options.headers != null ? options.headers : {};
|
this.defaultHeaders = options.headers != null ? options.headers : {};
|
||||||
this.booleanValues = options.booleanValues != null ? options.booleanValues : new Array('true', 'false');
|
|
||||||
this.discoveryUrl = this.suffixApiKey(this.discoveryUrl);
|
|
||||||
if (options.success != null) {
|
if (options.success != null) {
|
||||||
this.build();
|
this.build();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SwaggerApi.prototype.build = function() {
|
SwaggerApi.prototype.build = function() {
|
||||||
var _this = this;
|
var obj,
|
||||||
|
_this = this;
|
||||||
this.progress('fetching resource list: ' + this.discoveryUrl);
|
this.progress('fetching resource list: ' + this.discoveryUrl);
|
||||||
return jQuery.getJSON(this.discoveryUrl, function(response) {
|
obj = {
|
||||||
var res, resource, _i, _j, _len, _len1, _ref, _ref1;
|
url: this.discoveryUrl,
|
||||||
if (response.apiVersion != null) {
|
method: "get",
|
||||||
_this.apiVersion = response.apiVersion;
|
on: {
|
||||||
}
|
error: function(response) {
|
||||||
if ((response.basePath != null) && jQuery.trim(response.basePath).length > 0) {
|
|
||||||
_this.basePath = response.basePath;
|
|
||||||
if (_this.basePath.match(/^HTTP/i) == null) {
|
|
||||||
_this.fail("discoveryUrl basePath must be a URL.");
|
|
||||||
}
|
|
||||||
_this.basePath = _this.basePath.replace(/\/$/, '');
|
|
||||||
} else {
|
|
||||||
if (_this.discoveryUrl.indexOf('?') > 0) {
|
|
||||||
_this.basePath = _this.discoveryUrl.substring(0, _this.discoveryUrl.lastIndexOf('?'));
|
|
||||||
} else {
|
|
||||||
_this.basePath = _this.discoveryUrl;
|
|
||||||
}
|
|
||||||
log('derived basepath from discoveryUrl as ' + _this.basePath);
|
|
||||||
}
|
|
||||||
_this.apis = {};
|
|
||||||
_this.apisArray = [];
|
|
||||||
if (response.resourcePath != null) {
|
|
||||||
_this.resourcePath = response.resourcePath;
|
|
||||||
res = null;
|
|
||||||
_ref = response.apis;
|
|
||||||
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
|
||||||
resource = _ref[_i];
|
|
||||||
if (res === null) {
|
|
||||||
res = new SwaggerResource(resource, _this);
|
|
||||||
} else {
|
|
||||||
res.addOperations(resource.path, resource.operations);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (res != null) {
|
|
||||||
_this.apis[res.name] = res;
|
|
||||||
_this.apisArray.push(res);
|
|
||||||
res.ready = true;
|
|
||||||
_this.selfReflect();
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
_ref1 = response.apis;
|
|
||||||
for (_j = 0, _len1 = _ref1.length; _j < _len1; _j++) {
|
|
||||||
resource = _ref1[_j];
|
|
||||||
res = new SwaggerResource(resource, _this);
|
|
||||||
_this.apis[res.name] = res;
|
|
||||||
_this.apisArray.push(res);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return _this;
|
|
||||||
}).error(function(error) {
|
|
||||||
if (_this.discoveryUrl.substring(0, 4) !== 'http') {
|
if (_this.discoveryUrl.substring(0, 4) !== 'http') {
|
||||||
return _this.fail('Please specify the protocol for ' + _this.discoveryUrl);
|
return _this.fail('Please specify the protocol for ' + _this.discoveryUrl);
|
||||||
} else if (error.status === 0) {
|
} else if (error.status === 0) {
|
||||||
@@ -110,7 +52,34 @@
|
|||||||
} else {
|
} else {
|
||||||
return _this.fail(error.status + ' : ' + error.statusText + ' ' + _this.discoveryUrl);
|
return _this.fail(error.status + ' : ' + error.statusText + ' ' + _this.discoveryUrl);
|
||||||
}
|
}
|
||||||
});
|
},
|
||||||
|
response: function(rawResponse) {
|
||||||
|
var res, resource, response, _i, _len, _ref;
|
||||||
|
response = JSON.parse(rawResponse.content.data);
|
||||||
|
if (response.apiVersion != null) {
|
||||||
|
_this.apiVersion = response.apiVersion;
|
||||||
|
}
|
||||||
|
_this.apis = {};
|
||||||
|
_this.apisArray = [];
|
||||||
|
if (response.basePath) {
|
||||||
|
_this.basePath = response.basePath;
|
||||||
|
} else if (_this.discoveryUrl.indexOf('?') > 0) {
|
||||||
|
_this.basePath = _this.discoveryUrl.substring(0, _this.discoveryUrl.lastIndexOf('?'));
|
||||||
|
} else {
|
||||||
|
_this.basePath = _this.discoveryUrl;
|
||||||
|
}
|
||||||
|
_ref = response.apis;
|
||||||
|
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
||||||
|
resource = _ref[_i];
|
||||||
|
res = new SwaggerResource(resource, _this);
|
||||||
|
_this.apis[res.name] = res;
|
||||||
|
_this.apisArray.push(res);
|
||||||
|
}
|
||||||
|
return _this;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
return new SwaggerHttp().execute(obj);
|
||||||
};
|
};
|
||||||
|
|
||||||
SwaggerApi.prototype.selfReflect = function() {
|
SwaggerApi.prototype.selfReflect = function() {
|
||||||
@@ -160,16 +129,6 @@
|
|||||||
return _results;
|
return _results;
|
||||||
};
|
};
|
||||||
|
|
||||||
SwaggerApi.prototype.suffixApiKey = function(url) {
|
|
||||||
var sep;
|
|
||||||
if ((this.api_key != null) && jQuery.trim(this.api_key).length > 0 && (url != null)) {
|
|
||||||
sep = url.indexOf('?') > 0 ? '&' : '?';
|
|
||||||
return url + sep + this.apiKeyName + '=' + this.api_key;
|
|
||||||
} else {
|
|
||||||
return url;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
SwaggerApi.prototype.help = function() {
|
SwaggerApi.prototype.help = function() {
|
||||||
var operation, operation_name, parameter, resource, resource_name, _i, _len, _ref, _ref1, _ref2;
|
var operation, operation_name, parameter, resource, resource_name, _i, _len, _ref, _ref1, _ref2;
|
||||||
_ref = this.apis;
|
_ref = this.apis;
|
||||||
@@ -196,16 +155,24 @@
|
|||||||
|
|
||||||
SwaggerResource = (function() {
|
SwaggerResource = (function() {
|
||||||
|
|
||||||
|
SwaggerResource.prototype.api = null;
|
||||||
|
|
||||||
|
SwaggerResource.prototype.produces = null;
|
||||||
|
|
||||||
|
SwaggerResource.prototype.consumes = null;
|
||||||
|
|
||||||
function SwaggerResource(resourceObj, api) {
|
function SwaggerResource(resourceObj, api) {
|
||||||
var parts,
|
var consumes, obj, parts, produces,
|
||||||
_this = this;
|
_this = this;
|
||||||
this.api = api;
|
this.api = api;
|
||||||
|
this.api = this.api;
|
||||||
|
produces = [];
|
||||||
|
consumes = [];
|
||||||
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;
|
||||||
parts = this.path.split("/");
|
parts = this.path.split("/");
|
||||||
this.name = parts[parts.length - 1].replace('.{format}', '');
|
this.name = parts[parts.length - 1].replace('.{format}', '');
|
||||||
this.basePath = this.api.basePath;
|
this.basePath = this.api.basePath;
|
||||||
console.log('bp: ' + this.basePath);
|
|
||||||
this.operations = {};
|
this.operations = {};
|
||||||
this.operationsArray = [];
|
this.operationsArray = [];
|
||||||
this.modelsArray = [];
|
this.modelsArray = [];
|
||||||
@@ -219,15 +186,26 @@
|
|||||||
if (this.path == null) {
|
if (this.path == null) {
|
||||||
this.api.fail("SwaggerResources must have a path.");
|
this.api.fail("SwaggerResources must have a path.");
|
||||||
}
|
}
|
||||||
this.url = this.api.suffixApiKey(this.api.basePath + this.path.replace('{format}', 'json'));
|
this.url = this.api.basePath + this.path.replace('{format}', 'json');
|
||||||
console.log('basePath: ' + this.api.basePath);
|
|
||||||
console.log('url: ' + this.url);
|
|
||||||
this.api.progress('fetching resource ' + this.name + ': ' + this.url);
|
this.api.progress('fetching resource ' + this.name + ': ' + this.url);
|
||||||
jQuery.getJSON(this.url, function(response) {
|
obj = {
|
||||||
var endpoint, _i, _len, _ref;
|
url: this.url,
|
||||||
if ((response.basePath != null) && jQuery.trim(response.basePath).length > 0) {
|
method: "get",
|
||||||
|
on: {
|
||||||
|
error: function(response) {
|
||||||
|
return _this.api.fail("Unable to read api '" + _this.name + "' from path " + _this.url + " (server returned " + error.statusText + ")");
|
||||||
|
},
|
||||||
|
response: function(rawResponse) {
|
||||||
|
var endpoint, response, _i, _len, _ref;
|
||||||
|
response = JSON.parse(rawResponse.content._body);
|
||||||
|
if (response.produces != null) {
|
||||||
|
_this.produces = response.produces;
|
||||||
|
}
|
||||||
|
if (response.consumes != null) {
|
||||||
|
_this.consumes = response.consumes;
|
||||||
|
}
|
||||||
|
if ((response.basePath != null) && response.basePath.replace(/\s/g, '').length > 0) {
|
||||||
_this.basePath = response.basePath;
|
_this.basePath = response.basePath;
|
||||||
_this.basePath = _this.basePath.replace(/\/$/, '');
|
|
||||||
}
|
}
|
||||||
_this.addModels(response.models);
|
_this.addModels(response.models);
|
||||||
if (response.apis) {
|
if (response.apis) {
|
||||||
@@ -240,9 +218,10 @@
|
|||||||
_this.api[_this.name] = _this;
|
_this.api[_this.name] = _this;
|
||||||
_this.ready = true;
|
_this.ready = true;
|
||||||
return _this.api.selfReflect();
|
return _this.api.selfReflect();
|
||||||
}).error(function(error) {
|
}
|
||||||
return _this.api.fail("Unable to read api '" + _this.name + "' from path " + _this.url + " (server returned " + error.statusText + ")");
|
}
|
||||||
});
|
};
|
||||||
|
new SwaggerHttp().execute(obj);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -267,29 +246,35 @@
|
|||||||
};
|
};
|
||||||
|
|
||||||
SwaggerResource.prototype.addOperations = function(resource_path, ops) {
|
SwaggerResource.prototype.addOperations = function(resource_path, ops) {
|
||||||
var consumes, err, errorResponses, o, op, _i, _j, _len, _len1, _results;
|
var consumes, method, o, op, produces, responseMessages, _i, _len, _results;
|
||||||
if (ops) {
|
if (ops) {
|
||||||
_results = [];
|
_results = [];
|
||||||
for (_i = 0, _len = ops.length; _i < _len; _i++) {
|
for (_i = 0, _len = ops.length; _i < _len; _i++) {
|
||||||
o = ops[_i];
|
o = ops[_i];
|
||||||
|
consumes = null;
|
||||||
|
produces = null;
|
||||||
|
if (o.consumes != null) {
|
||||||
consumes = o.consumes;
|
consumes = o.consumes;
|
||||||
|
} else {
|
||||||
|
consumes = this.consumes;
|
||||||
|
}
|
||||||
|
if (o.produces != null) {
|
||||||
|
produces = o.produces;
|
||||||
|
} else {
|
||||||
|
produces = this.produces;
|
||||||
|
}
|
||||||
|
responseMessages = o.responseMessages;
|
||||||
|
method = o.method;
|
||||||
|
if (o.httpMethod) {
|
||||||
|
method = o.httpMethod;
|
||||||
|
}
|
||||||
if (o.supportedContentTypes) {
|
if (o.supportedContentTypes) {
|
||||||
consumes = o.supportedContentTypes;
|
consumes = o.supportedContentTypes;
|
||||||
}
|
}
|
||||||
errorResponses = o.responseMessages;
|
|
||||||
if (errorResponses) {
|
|
||||||
for (_j = 0, _len1 = errorResponses.length; _j < _len1; _j++) {
|
|
||||||
err = errorResponses[_j];
|
|
||||||
err.reason = err.message;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (o.errorResponses) {
|
if (o.errorResponses) {
|
||||||
errorResponses = o.errorResponses;
|
responseMessages = o.errorResponses;
|
||||||
}
|
}
|
||||||
if (o.method) {
|
op = new SwaggerOperation(o.nickname, resource_path, method, o.parameters, o.summary, o.notes, o.responseClass, responseMessages, this, consumes, produces);
|
||||||
o.httpMethod = o.method;
|
|
||||||
}
|
|
||||||
op = new SwaggerOperation(o.nickname, resource_path, o.httpMethod, o.parameters, o.summary, o.notes, o.responseClass, errorResponses, this, o.consumes, o.produces);
|
|
||||||
this.operations[op.nickname] = op;
|
this.operations[op.nickname] = op;
|
||||||
_results.push(this.operationsArray.push(op));
|
_results.push(this.operationsArray.push(op));
|
||||||
}
|
}
|
||||||
@@ -298,18 +283,20 @@
|
|||||||
};
|
};
|
||||||
|
|
||||||
SwaggerResource.prototype.help = function() {
|
SwaggerResource.prototype.help = function() {
|
||||||
var operation, operation_name, parameter, _i, _len, _ref, _ref1;
|
var msg, operation, operation_name, parameter, _i, _len, _ref, _ref1, _results;
|
||||||
_ref = this.operations;
|
_ref = this.operations;
|
||||||
|
_results = [];
|
||||||
for (operation_name in _ref) {
|
for (operation_name in _ref) {
|
||||||
operation = _ref[operation_name];
|
operation = _ref[operation_name];
|
||||||
console.log(" " + operation.nickname);
|
msg = " " + operation.nickname;
|
||||||
_ref1 = operation.parameters;
|
_ref1 = operation.parameters;
|
||||||
for (_i = 0, _len = _ref1.length; _i < _len; _i++) {
|
for (_i = 0, _len = _ref1.length; _i < _len; _i++) {
|
||||||
parameter = _ref1[_i];
|
parameter = _ref1[_i];
|
||||||
console.log(" " + parameter.name + (parameter.required ? ' (required)' : '') + " - " + parameter.description);
|
msg.concat(" " + parameter.name + (parameter.required ? ' (required)' : '') + " - " + parameter.description);
|
||||||
}
|
}
|
||||||
|
_results.push(msg);
|
||||||
}
|
}
|
||||||
return this;
|
return _results;
|
||||||
};
|
};
|
||||||
|
|
||||||
return SwaggerResource;
|
return SwaggerResource;
|
||||||
@@ -456,17 +443,17 @@
|
|||||||
|
|
||||||
SwaggerOperation = (function() {
|
SwaggerOperation = (function() {
|
||||||
|
|
||||||
function SwaggerOperation(nickname, path, httpMethod, parameters, summary, notes, responseClass, errorResponses, resource, consumes, produces) {
|
function SwaggerOperation(nickname, path, method, parameters, summary, notes, responseClass, responseMessages, resource, consumes, produces) {
|
||||||
var parameter, v, _i, _j, _len, _len1, _ref, _ref1, _ref2,
|
var parameter, v, _i, _j, _len, _len1, _ref, _ref1, _ref2,
|
||||||
_this = this;
|
_this = this;
|
||||||
this.nickname = nickname;
|
this.nickname = nickname;
|
||||||
this.path = path;
|
this.path = path;
|
||||||
this.httpMethod = httpMethod;
|
this.method = method;
|
||||||
this.parameters = parameters != null ? parameters : [];
|
this.parameters = parameters != null ? parameters : [];
|
||||||
this.summary = summary;
|
this.summary = summary;
|
||||||
this.notes = notes;
|
this.notes = notes;
|
||||||
this.responseClass = responseClass;
|
this.responseClass = responseClass;
|
||||||
this.errorResponses = errorResponses;
|
this.responseMessages = responseMessages;
|
||||||
this.resource = resource;
|
this.resource = resource;
|
||||||
this.consumes = consumes;
|
this.consumes = consumes;
|
||||||
this.produces = produces;
|
this.produces = produces;
|
||||||
@@ -478,12 +465,12 @@
|
|||||||
if (this.path == null) {
|
if (this.path == null) {
|
||||||
this.resource.api.fail("SwaggerOperation " + nickname + " is missing path.");
|
this.resource.api.fail("SwaggerOperation " + nickname + " is missing path.");
|
||||||
}
|
}
|
||||||
if (this.httpMethod == null) {
|
if (this.method == null) {
|
||||||
this.resource.api.fail("SwaggerOperation " + nickname + " is missing httpMethod.");
|
this.resource.api.fail("SwaggerOperation " + nickname + " is missing method.");
|
||||||
}
|
}
|
||||||
this.path = this.path.replace('{format}', 'json');
|
this.path = this.path.replace('{format}', 'json');
|
||||||
this.httpMethod = this.httpMethod.toLowerCase();
|
this.method = this.method.toLowerCase();
|
||||||
this.isGetMethod = this.httpMethod === "get";
|
this.isGetMethod = this.method === "get";
|
||||||
this.resourceName = this.resource.name;
|
this.resourceName = this.resource.name;
|
||||||
if (((_ref = this.responseClass) != null ? _ref.toLowerCase() : void 0) === 'void') {
|
if (((_ref = this.responseClass) != null ? _ref.toLowerCase() : void 0) === 'void') {
|
||||||
this.responseClass = void 0;
|
this.responseClass = void 0;
|
||||||
@@ -492,7 +479,7 @@
|
|||||||
this.responseClassSignature = this.getSignature(this.responseClass, this.resource.models);
|
this.responseClassSignature = this.getSignature(this.responseClass, this.resource.models);
|
||||||
this.responseSampleJSON = this.getSampleJSON(this.responseClass, this.resource.models);
|
this.responseSampleJSON = this.getSampleJSON(this.responseClass, this.resource.models);
|
||||||
}
|
}
|
||||||
this.errorResponses = this.errorResponses || [];
|
this.responseMessages = this.responseMessages || [];
|
||||||
_ref1 = this.parameters;
|
_ref1 = this.parameters;
|
||||||
for (_i = 0, _len = _ref1.length; _i < _len; _i++) {
|
for (_i = 0, _len = _ref1.length; _i < _len; _i++) {
|
||||||
parameter = _ref1[_i];
|
parameter = _ref1[_i];
|
||||||
@@ -569,10 +556,12 @@
|
|||||||
};
|
};
|
||||||
|
|
||||||
SwaggerOperation.prototype["do"] = function(args, callback, error) {
|
SwaggerOperation.prototype["do"] = function(args, callback, error) {
|
||||||
var body, headers;
|
var key, param, params, possibleParams, requestContentType, responseContentType, value;
|
||||||
if (args == null) {
|
if (args == null) {
|
||||||
args = {};
|
args = {};
|
||||||
}
|
}
|
||||||
|
requestContentType = null;
|
||||||
|
responseContentType = null;
|
||||||
if ((typeof args) === "function") {
|
if ((typeof args) === "function") {
|
||||||
error = callback;
|
error = callback;
|
||||||
callback = args;
|
callback = args;
|
||||||
@@ -585,18 +574,49 @@
|
|||||||
}
|
}
|
||||||
if (callback == null) {
|
if (callback == null) {
|
||||||
callback = function(data) {
|
callback = function(data) {
|
||||||
return console.log(data);
|
return console.log("default callback: " + data);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
params = {};
|
||||||
|
if (args.requestContentType) {
|
||||||
|
requestContentType = args.requestContentType;
|
||||||
|
}
|
||||||
|
if (args.responseContentType) {
|
||||||
|
responseContentType = args.responseContentType;
|
||||||
|
}
|
||||||
if (args.headers != null) {
|
if (args.headers != null) {
|
||||||
headers = args.headers;
|
params.headers = args.headers;
|
||||||
delete args.headers;
|
delete args.headers;
|
||||||
}
|
}
|
||||||
if (args.body != null) {
|
if (args.body != null) {
|
||||||
body = args.body;
|
params.body = args.body;
|
||||||
delete args.body;
|
delete args.body;
|
||||||
}
|
}
|
||||||
return new SwaggerRequest(this.httpMethod, this.urlify(args), headers, body, callback, error, this);
|
possibleParams = (function() {
|
||||||
|
var _i, _len, _ref, _results;
|
||||||
|
_ref = this.parameters;
|
||||||
|
_results = [];
|
||||||
|
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
||||||
|
param = _ref[_i];
|
||||||
|
if (param.paramType === "form") {
|
||||||
|
_results.push(param);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return _results;
|
||||||
|
}).call(this);
|
||||||
|
if (possibleParams) {
|
||||||
|
for (key in possibleParams) {
|
||||||
|
value = possibleParams[key];
|
||||||
|
if (args[value.name]) {
|
||||||
|
params[value.name] = args[value.name];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (args.mock != null) {
|
||||||
|
params.mock = args["mock"];
|
||||||
|
}
|
||||||
|
params["parent"] = args["parent"];
|
||||||
|
return new SwaggerRequest(this.method, this.urlify(args), params, requestContentType, responseContentType, callback, error, this);
|
||||||
};
|
};
|
||||||
|
|
||||||
SwaggerOperation.prototype.pathJson = function() {
|
SwaggerOperation.prototype.pathJson = function() {
|
||||||
@@ -607,11 +627,8 @@
|
|||||||
return this.path.replace("{format}", "xml");
|
return this.path.replace("{format}", "xml");
|
||||||
};
|
};
|
||||||
|
|
||||||
SwaggerOperation.prototype.urlify = function(args, includeApiKey) {
|
SwaggerOperation.prototype.urlify = function(args) {
|
||||||
var param, queryParams, reg, url, _i, _len, _ref;
|
var param, queryParams, reg, url, _i, _j, _len, _len1, _ref, _ref1;
|
||||||
if (includeApiKey == null) {
|
|
||||||
includeApiKey = true;
|
|
||||||
}
|
|
||||||
url = this.resource.basePath + this.pathJson();
|
url = this.resource.basePath + this.pathJson();
|
||||||
_ref = this.parameters;
|
_ref = this.parameters;
|
||||||
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
||||||
@@ -626,13 +643,18 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (includeApiKey && (this.resource.api.api_key != null) && this.resource.api.api_key.length > 0) {
|
queryParams = "";
|
||||||
args[this.apiKeyName] = this.resource.api.api_key;
|
_ref1 = this.parameters;
|
||||||
|
for (_j = 0, _len1 = _ref1.length; _j < _len1; _j++) {
|
||||||
|
param = _ref1[_j];
|
||||||
|
if (param.paramType === 'query') {
|
||||||
|
if (args[param.name]) {
|
||||||
|
if (queryParams !== "") {
|
||||||
|
queryParams += "&";
|
||||||
|
}
|
||||||
|
queryParams += encodeURIComponent(param.name) + '=' + encodeURIComponent(args[param.name]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (this.supportHeaderParams()) {
|
|
||||||
queryParams = jQuery.param(this.getQueryParams(args, includeApiKey));
|
|
||||||
} else {
|
|
||||||
queryParams = jQuery.param(this.getQueryAndHeaderParams(args, includeApiKey));
|
|
||||||
}
|
}
|
||||||
if ((queryParams != null) && queryParams.length > 0) {
|
if ((queryParams != null) && queryParams.length > 0) {
|
||||||
url += "?" + queryParams;
|
url += "?" + queryParams;
|
||||||
@@ -648,58 +670,44 @@
|
|||||||
return this.resource.api.supportedSubmitMethods;
|
return this.resource.api.supportedSubmitMethods;
|
||||||
};
|
};
|
||||||
|
|
||||||
SwaggerOperation.prototype.getQueryAndHeaderParams = function(args, includeApiKey) {
|
SwaggerOperation.prototype.getQueryParams = function(args) {
|
||||||
if (includeApiKey == null) {
|
return this.getMatchingParams(['query'], args);
|
||||||
includeApiKey = true;
|
|
||||||
}
|
|
||||||
return this.getMatchingParams(['query', 'header'], args, includeApiKey);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
SwaggerOperation.prototype.getQueryParams = function(args, includeApiKey) {
|
SwaggerOperation.prototype.getHeaderParams = function(args) {
|
||||||
if (includeApiKey == null) {
|
return this.getMatchingParams(['header'], args);
|
||||||
includeApiKey = true;
|
|
||||||
}
|
|
||||||
return this.getMatchingParams(['query'], args, includeApiKey);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
SwaggerOperation.prototype.getHeaderParams = function(args, includeApiKey) {
|
SwaggerOperation.prototype.getMatchingParams = function(paramTypes, args) {
|
||||||
if (includeApiKey == null) {
|
|
||||||
includeApiKey = true;
|
|
||||||
}
|
|
||||||
return this.getMatchingParams(['header'], args, includeApiKey);
|
|
||||||
};
|
|
||||||
|
|
||||||
SwaggerOperation.prototype.getMatchingParams = function(paramTypes, args, includeApiKey) {
|
|
||||||
var matchingParams, name, param, value, _i, _len, _ref, _ref1;
|
var matchingParams, name, param, value, _i, _len, _ref, _ref1;
|
||||||
matchingParams = {};
|
matchingParams = {};
|
||||||
_ref = this.parameters;
|
_ref = this.parameters;
|
||||||
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
||||||
param = _ref[_i];
|
param = _ref[_i];
|
||||||
if ((jQuery.inArray(param.paramType, paramTypes) >= 0) && args[param.name]) {
|
if (args && args[param.name]) {
|
||||||
matchingParams[param.name] = args[param.name];
|
matchingParams[param.name] = args[param.name];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (includeApiKey && (this.resource.api.api_key != null) && this.resource.api.api_key.length > 0) {
|
|
||||||
matchingParams[this.resource.api.apiKeyName] = this.resource.api.api_key;
|
|
||||||
}
|
|
||||||
if (jQuery.inArray('header', paramTypes) >= 0) {
|
|
||||||
_ref1 = this.resource.api.headers;
|
_ref1 = this.resource.api.headers;
|
||||||
for (name in _ref1) {
|
for (name in _ref1) {
|
||||||
value = _ref1[name];
|
value = _ref1[name];
|
||||||
matchingParams[name] = value;
|
matchingParams[name] = value;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return matchingParams;
|
return matchingParams;
|
||||||
};
|
};
|
||||||
|
|
||||||
SwaggerOperation.prototype.help = function() {
|
SwaggerOperation.prototype.help = function() {
|
||||||
var parameter, _i, _len, _ref;
|
var msg, parameter, _i, _len, _ref;
|
||||||
|
msg = "";
|
||||||
_ref = this.parameters;
|
_ref = this.parameters;
|
||||||
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
||||||
parameter = _ref[_i];
|
parameter = _ref[_i];
|
||||||
console.log(" " + parameter.name + (parameter.required ? ' (required)' : '') + " - " + parameter.description);
|
if (msg !== "") {
|
||||||
|
msg += "\n";
|
||||||
}
|
}
|
||||||
return this;
|
msg += "* " + parameter.name + (parameter.required ? ' (required)' : '') + " - " + parameter.description;
|
||||||
|
}
|
||||||
|
return msg;
|
||||||
};
|
};
|
||||||
|
|
||||||
return SwaggerOperation;
|
return SwaggerOperation;
|
||||||
@@ -708,16 +716,18 @@
|
|||||||
|
|
||||||
SwaggerRequest = (function() {
|
SwaggerRequest = (function() {
|
||||||
|
|
||||||
function SwaggerRequest(type, url, headers, body, successCallback, errorCallback, operation) {
|
function SwaggerRequest(type, url, params, requestContentType, responseContentType, successCallback, errorCallback, operation, execution) {
|
||||||
var obj,
|
var body, e, fields, headers, key, myHeaders, obj, param, parent, possibleParams, urlEncoded, value, values,
|
||||||
_this = this;
|
_this = this;
|
||||||
this.type = type;
|
this.type = type;
|
||||||
this.url = url;
|
this.url = url;
|
||||||
this.headers = headers;
|
this.params = params;
|
||||||
this.body = body;
|
this.requestContentType = requestContentType;
|
||||||
|
this.responseContentType = responseContentType;
|
||||||
this.successCallback = successCallback;
|
this.successCallback = successCallback;
|
||||||
this.errorCallback = errorCallback;
|
this.errorCallback = errorCallback;
|
||||||
this.operation = operation;
|
this.operation = operation;
|
||||||
|
this.execution = execution;
|
||||||
if (this.type == null) {
|
if (this.type == null) {
|
||||||
throw "SwaggerRequest type is required (get/post/put/delete).";
|
throw "SwaggerRequest type is required (get/post/put/delete).";
|
||||||
}
|
}
|
||||||
@@ -733,30 +743,133 @@
|
|||||||
if (this.operation == null) {
|
if (this.operation == null) {
|
||||||
throw "SwaggerRequest operation is required.";
|
throw "SwaggerRequest operation is required.";
|
||||||
}
|
}
|
||||||
if (this.operation.resource.api.verbose) {
|
this.type = this.type.toUpperCase();
|
||||||
console.log(this.asCurl());
|
headers = params.headers;
|
||||||
|
myHeaders = {};
|
||||||
|
body = params.body;
|
||||||
|
parent = params["parent"];
|
||||||
|
requestContentType = "application/json";
|
||||||
|
if (body && (this.type === "POST" || this.type === "PUT" || this.type === "PATCH")) {
|
||||||
|
if (this.requestContentType) {
|
||||||
|
requestContentType = this.requestContentType;
|
||||||
}
|
}
|
||||||
this.headers || (this.headers = {});
|
} else {
|
||||||
if (this.operation.resource.api.api_key != null) {
|
if (((function() {
|
||||||
this.headers[this.apiKeyName] = this.operation.resource.api.api_key;
|
var _i, _len, _ref, _results;
|
||||||
|
_ref = this.operation.parameters;
|
||||||
|
_results = [];
|
||||||
|
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
||||||
|
param = _ref[_i];
|
||||||
|
if (param.paramType === "form") {
|
||||||
|
_results.push(param);
|
||||||
}
|
}
|
||||||
if (this.headers.mock == null) {
|
}
|
||||||
|
return _results;
|
||||||
|
}).call(this)).length > 0) {
|
||||||
|
requestContentType = "application/x-www-form-urlencoded";
|
||||||
|
} else if (this.type !== "DELETE") {
|
||||||
|
requestContentType = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (requestContentType && this.operation.consumes) {
|
||||||
|
if (this.operation.consumes.indexOf(requestContentType) === -1) {
|
||||||
|
console.log("server doesn't consume " + requestContentType + ", try " + JSON.stringify(this.operation.consumes));
|
||||||
|
if (this.requestContentType === null) {
|
||||||
|
requestContentType = this.operation.consumes[0];
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
console.log("it's ok to send " + requestContentType);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
responseContentType = null;
|
||||||
|
if (this.type === "POST" || this.type === "GET") {
|
||||||
|
if (this.responseContentType) {
|
||||||
|
responseContentType = this.responseContentType;
|
||||||
|
} else {
|
||||||
|
responseContentType = "application/json";
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
responseContentType = null;
|
||||||
|
}
|
||||||
|
if (responseContentType && this.operation.produces) {
|
||||||
|
if (this.operation.produces.indexOf(responseContentType) === -1) {
|
||||||
|
console.log("server can't produce " + responseContentType);
|
||||||
|
} else {
|
||||||
|
console.log("get ready for " + responseContentType);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (requestContentType && requestContentType.indexOf("application/x-www-form-urlencoded") === 0) {
|
||||||
|
console.log("pulling fields");
|
||||||
|
fields = {};
|
||||||
|
possibleParams = (function() {
|
||||||
|
var _i, _len, _ref, _results;
|
||||||
|
_ref = this.operation.parameters;
|
||||||
|
_results = [];
|
||||||
|
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
||||||
|
param = _ref[_i];
|
||||||
|
if (param.paramType === "form") {
|
||||||
|
_results.push(param);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return _results;
|
||||||
|
}).call(this);
|
||||||
|
console.log(possibleParams);
|
||||||
|
values = {};
|
||||||
|
for (key in possibleParams) {
|
||||||
|
value = possibleParams[key];
|
||||||
|
if (this.params[value.name]) {
|
||||||
|
values[value.name] = this.params[value.name];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
urlEncoded = "";
|
||||||
|
for (key in values) {
|
||||||
|
value = values[key];
|
||||||
|
if (urlEncoded !== "") {
|
||||||
|
urlEncoded += "&";
|
||||||
|
}
|
||||||
|
urlEncoded += encodeURIComponent(key) + '=' + encodeURIComponent(value);
|
||||||
|
}
|
||||||
|
body = urlEncoded;
|
||||||
|
}
|
||||||
|
if (requestContentType) {
|
||||||
|
myHeaders["Content-Type"] = requestContentType;
|
||||||
|
}
|
||||||
|
if (responseContentType) {
|
||||||
|
myHeaders["Accept"] = responseContentType;
|
||||||
|
}
|
||||||
|
if (!((headers != null) && (headers.mock != null))) {
|
||||||
obj = {
|
obj = {
|
||||||
type: this.type,
|
|
||||||
url: this.url,
|
url: this.url,
|
||||||
data: JSON.stringify(this.body),
|
method: this.type,
|
||||||
dataType: 'json',
|
headers: myHeaders,
|
||||||
error: function(xhr, textStatus, error) {
|
body: body,
|
||||||
return _this.errorCallback(xhr, textStatus, error);
|
on: {
|
||||||
|
error: function(response) {
|
||||||
|
return _this.errorCallback(response, _this.params["parent"]);
|
||||||
},
|
},
|
||||||
success: function(data) {
|
redirect: function(response) {
|
||||||
return _this.successCallback(data);
|
return _this.successCallback(response, _this.params["parent"]);
|
||||||
|
},
|
||||||
|
307: function(response) {
|
||||||
|
return _this.successCallback(response, _this.params["parent"]);
|
||||||
|
},
|
||||||
|
response: function(response) {
|
||||||
|
return _this.successCallback(response, _this.params["parent"]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
if (obj.type.toLowerCase() === "post" || obj.type.toLowerCase() === "put") {
|
e = {};
|
||||||
obj.contentType = "application/json";
|
if (typeof window !== 'undefined') {
|
||||||
|
e = window;
|
||||||
|
} else {
|
||||||
|
e = exports;
|
||||||
|
}
|
||||||
|
e.authorizations.apply(obj);
|
||||||
|
if (params.mock == null) {
|
||||||
|
new SwaggerHttp().execute(obj);
|
||||||
|
} else {
|
||||||
|
return obj;
|
||||||
}
|
}
|
||||||
jQuery.ajax(obj);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -779,14 +892,115 @@
|
|||||||
|
|
||||||
})();
|
})();
|
||||||
|
|
||||||
window.SwaggerApi = SwaggerApi;
|
SwaggerHttp = (function() {
|
||||||
|
|
||||||
window.SwaggerResource = SwaggerResource;
|
SwaggerHttp.prototype.shred = null;
|
||||||
|
|
||||||
window.SwaggerOperation = SwaggerOperation;
|
function SwaggerHttp() {
|
||||||
|
var Shred;
|
||||||
|
Shred = null;
|
||||||
|
if (typeof window !== 'undefined') {
|
||||||
|
Shred = require("./shred");
|
||||||
|
} else {
|
||||||
|
Shred = require("shred");
|
||||||
|
}
|
||||||
|
this.shred = new Shred();
|
||||||
|
}
|
||||||
|
|
||||||
window.SwaggerRequest = SwaggerRequest;
|
SwaggerHttp.prototype.execute = function(obj) {
|
||||||
|
var Content, identity, toString,
|
||||||
|
_this = this;
|
||||||
|
Content = require("./shred/content");
|
||||||
|
identity = function(x) {
|
||||||
|
return x;
|
||||||
|
};
|
||||||
|
toString = function(x) {
|
||||||
|
return x.toString;
|
||||||
|
};
|
||||||
|
Content.registerProcessor(["application/json; charset=utf-8", "application/json", "json"], {
|
||||||
|
parser: identity,
|
||||||
|
stringify: toString
|
||||||
|
});
|
||||||
|
return this.shred.request(obj);
|
||||||
|
};
|
||||||
|
|
||||||
window.SwaggerModelProperty = SwaggerModelProperty;
|
return SwaggerHttp;
|
||||||
|
|
||||||
|
})();
|
||||||
|
|
||||||
|
SwaggerAuthorizations = (function() {
|
||||||
|
|
||||||
|
SwaggerAuthorizations.prototype.authz = null;
|
||||||
|
|
||||||
|
function SwaggerAuthorizations() {
|
||||||
|
this.authz = {};
|
||||||
|
}
|
||||||
|
|
||||||
|
SwaggerAuthorizations.prototype.add = function(name, auth) {
|
||||||
|
this.authz[name] = auth;
|
||||||
|
return auth;
|
||||||
|
};
|
||||||
|
|
||||||
|
SwaggerAuthorizations.prototype.apply = function(obj) {
|
||||||
|
var key, value, _ref, _results;
|
||||||
|
_ref = this.authz;
|
||||||
|
_results = [];
|
||||||
|
for (key in _ref) {
|
||||||
|
value = _ref[key];
|
||||||
|
_results.push(value.apply(obj));
|
||||||
|
}
|
||||||
|
return _results;
|
||||||
|
};
|
||||||
|
|
||||||
|
return SwaggerAuthorizations;
|
||||||
|
|
||||||
|
})();
|
||||||
|
|
||||||
|
ApiKeyAuthorization = (function() {
|
||||||
|
|
||||||
|
ApiKeyAuthorization.prototype.type = null;
|
||||||
|
|
||||||
|
ApiKeyAuthorization.prototype.name = null;
|
||||||
|
|
||||||
|
ApiKeyAuthorization.prototype.value = null;
|
||||||
|
|
||||||
|
function ApiKeyAuthorization(name, value, type) {
|
||||||
|
this.name = name;
|
||||||
|
this.value = value;
|
||||||
|
this.type = type;
|
||||||
|
}
|
||||||
|
|
||||||
|
ApiKeyAuthorization.prototype.apply = function(obj) {
|
||||||
|
if (this.type === "query") {
|
||||||
|
if (obj.url.indexOf('?') > 0) {
|
||||||
|
obj.url = obj.url + "&" + this.name + "=" + this.value;
|
||||||
|
} else {
|
||||||
|
obj.url = obj.url + "?" + this.name + "=" + this.value;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
} else if (this.type === "header") {
|
||||||
|
return obj.headers[this.name] = this.value;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
return ApiKeyAuthorization;
|
||||||
|
|
||||||
|
})();
|
||||||
|
|
||||||
|
this.SwaggerApi = SwaggerApi;
|
||||||
|
|
||||||
|
this.SwaggerResource = SwaggerResource;
|
||||||
|
|
||||||
|
this.SwaggerOperation = SwaggerOperation;
|
||||||
|
|
||||||
|
this.SwaggerRequest = SwaggerRequest;
|
||||||
|
|
||||||
|
this.SwaggerModelProperty = SwaggerModelProperty;
|
||||||
|
|
||||||
|
this.SwaggerAuthorizations = new SwaggerAuthorizations();
|
||||||
|
|
||||||
|
this.ApiKeyAuthorization = ApiKeyAuthorization;
|
||||||
|
|
||||||
|
this.authorizations = new SwaggerAuthorizations();
|
||||||
|
|
||||||
}).call(this);
|
}).call(this);
|
||||||
|
|||||||
408
dist/swagger-ui.js
vendored
408
dist/swagger-ui.js
vendored
@@ -295,7 +295,7 @@ function program1(depth0,data) {
|
|||||||
function program3(depth0,data) {
|
function program3(depth0,data) {
|
||||||
|
|
||||||
|
|
||||||
return "\n <h4>Response Class</h4>\n <p><span class=\"model-signature\" /></p>\n <br/>\n <div class=\"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) {
|
function program5(depth0,data) {
|
||||||
|
|
||||||
@@ -318,10 +318,10 @@ 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='";
|
||||||
foundHelper = helpers.httpMethod;
|
foundHelper = helpers.method;
|
||||||
stack1 = foundHelper || depth0.httpMethod;
|
stack1 = foundHelper || depth0.method;
|
||||||
if(typeof stack1 === functionType) { stack1 = stack1.call(depth0, { hash: {} }); }
|
if(typeof stack1 === functionType) { stack1 = stack1.call(depth0, { hash: {} }); }
|
||||||
else if(stack1=== undef) { stack1 = helperMissing.call(depth0, "httpMethod", { hash: {} }); }
|
else if(stack1=== undef) { stack1 = helperMissing.call(depth0, "method", { hash: {} }); }
|
||||||
buffer += escapeExpression(stack1) + " operation' id='";
|
buffer += escapeExpression(stack1) + " operation' id='";
|
||||||
foundHelper = helpers.resourceName;
|
foundHelper = helpers.resourceName;
|
||||||
stack1 = foundHelper || depth0.resourceName;
|
stack1 = foundHelper || depth0.resourceName;
|
||||||
@@ -333,10 +333,10 @@ function program11(depth0,data) {
|
|||||||
if(typeof stack1 === functionType) { stack1 = stack1.call(depth0, { hash: {} }); }
|
if(typeof stack1 === functionType) { stack1 = stack1.call(depth0, { hash: {} }); }
|
||||||
else if(stack1=== undef) { stack1 = helperMissing.call(depth0, "nickname", { hash: {} }); }
|
else if(stack1=== undef) { stack1 = helperMissing.call(depth0, "nickname", { hash: {} }); }
|
||||||
buffer += escapeExpression(stack1) + "_";
|
buffer += escapeExpression(stack1) + "_";
|
||||||
foundHelper = helpers.httpMethod;
|
foundHelper = helpers.method;
|
||||||
stack1 = foundHelper || depth0.httpMethod;
|
stack1 = foundHelper || depth0.method;
|
||||||
if(typeof stack1 === functionType) { stack1 = stack1.call(depth0, { hash: {} }); }
|
if(typeof stack1 === functionType) { stack1 = stack1.call(depth0, { hash: {} }); }
|
||||||
else if(stack1=== undef) { stack1 = helperMissing.call(depth0, "httpMethod", { hash: {} }); }
|
else if(stack1=== undef) { stack1 = helperMissing.call(depth0, "method", { hash: {} }); }
|
||||||
buffer += escapeExpression(stack1) + "_";
|
buffer += escapeExpression(stack1) + "_";
|
||||||
foundHelper = helpers.number;
|
foundHelper = helpers.number;
|
||||||
stack1 = foundHelper || depth0.number;
|
stack1 = foundHelper || depth0.number;
|
||||||
@@ -353,20 +353,20 @@ function program11(depth0,data) {
|
|||||||
if(typeof stack1 === functionType) { stack1 = stack1.call(depth0, { hash: {} }); }
|
if(typeof stack1 === functionType) { stack1 = stack1.call(depth0, { hash: {} }); }
|
||||||
else if(stack1=== undef) { stack1 = helperMissing.call(depth0, "nickname", { hash: {} }); }
|
else if(stack1=== undef) { stack1 = helperMissing.call(depth0, "nickname", { hash: {} }); }
|
||||||
buffer += escapeExpression(stack1) + "_";
|
buffer += escapeExpression(stack1) + "_";
|
||||||
foundHelper = helpers.httpMethod;
|
foundHelper = helpers.method;
|
||||||
stack1 = foundHelper || depth0.httpMethod;
|
stack1 = foundHelper || depth0.method;
|
||||||
if(typeof stack1 === functionType) { stack1 = stack1.call(depth0, { hash: {} }); }
|
if(typeof stack1 === functionType) { stack1 = stack1.call(depth0, { hash: {} }); }
|
||||||
else if(stack1=== undef) { stack1 = helperMissing.call(depth0, "httpMethod", { hash: {} }); }
|
else if(stack1=== undef) { stack1 = helperMissing.call(depth0, "method", { hash: {} }); }
|
||||||
buffer += escapeExpression(stack1) + "_";
|
buffer += escapeExpression(stack1) + "_";
|
||||||
foundHelper = helpers.number;
|
foundHelper = helpers.number;
|
||||||
stack1 = foundHelper || depth0.number;
|
stack1 = foundHelper || depth0.number;
|
||||||
if(typeof stack1 === functionType) { stack1 = stack1.call(depth0, { hash: {} }); }
|
if(typeof stack1 === functionType) { stack1 = stack1.call(depth0, { hash: {} }); }
|
||||||
else if(stack1=== undef) { stack1 = helperMissing.call(depth0, "number", { hash: {} }); }
|
else if(stack1=== undef) { stack1 = helperMissing.call(depth0, "number", { hash: {} }); }
|
||||||
buffer += escapeExpression(stack1) + "' class=\"toggleOperation\">";
|
buffer += escapeExpression(stack1) + "' class=\"toggleOperation\">";
|
||||||
foundHelper = helpers.httpMethod;
|
foundHelper = helpers.method;
|
||||||
stack1 = foundHelper || depth0.httpMethod;
|
stack1 = foundHelper || depth0.method;
|
||||||
if(typeof stack1 === functionType) { stack1 = stack1.call(depth0, { hash: {} }); }
|
if(typeof stack1 === functionType) { stack1 = stack1.call(depth0, { hash: {} }); }
|
||||||
else if(stack1=== undef) { stack1 = helperMissing.call(depth0, "httpMethod", { hash: {} }); }
|
else if(stack1=== undef) { stack1 = helperMissing.call(depth0, "method", { hash: {} }); }
|
||||||
buffer += escapeExpression(stack1) + "</a>\n </span>\n <span class='path'>\n <a href='#!/";
|
buffer += escapeExpression(stack1) + "</a>\n </span>\n <span class='path'>\n <a href='#!/";
|
||||||
foundHelper = helpers.resourceName;
|
foundHelper = helpers.resourceName;
|
||||||
stack1 = foundHelper || depth0.resourceName;
|
stack1 = foundHelper || depth0.resourceName;
|
||||||
@@ -378,10 +378,10 @@ function program11(depth0,data) {
|
|||||||
if(typeof stack1 === functionType) { stack1 = stack1.call(depth0, { hash: {} }); }
|
if(typeof stack1 === functionType) { stack1 = stack1.call(depth0, { hash: {} }); }
|
||||||
else if(stack1=== undef) { stack1 = helperMissing.call(depth0, "nickname", { hash: {} }); }
|
else if(stack1=== undef) { stack1 = helperMissing.call(depth0, "nickname", { hash: {} }); }
|
||||||
buffer += escapeExpression(stack1) + "_";
|
buffer += escapeExpression(stack1) + "_";
|
||||||
foundHelper = helpers.httpMethod;
|
foundHelper = helpers.method;
|
||||||
stack1 = foundHelper || depth0.httpMethod;
|
stack1 = foundHelper || depth0.method;
|
||||||
if(typeof stack1 === functionType) { stack1 = stack1.call(depth0, { hash: {} }); }
|
if(typeof stack1 === functionType) { stack1 = stack1.call(depth0, { hash: {} }); }
|
||||||
else if(stack1=== undef) { stack1 = helperMissing.call(depth0, "httpMethod", { hash: {} }); }
|
else if(stack1=== undef) { stack1 = helperMissing.call(depth0, "method", { hash: {} }); }
|
||||||
buffer += escapeExpression(stack1) + "_";
|
buffer += escapeExpression(stack1) + "_";
|
||||||
foundHelper = helpers.number;
|
foundHelper = helpers.number;
|
||||||
stack1 = foundHelper || depth0.number;
|
stack1 = foundHelper || depth0.number;
|
||||||
@@ -403,10 +403,10 @@ function program11(depth0,data) {
|
|||||||
if(typeof stack1 === functionType) { stack1 = stack1.call(depth0, { hash: {} }); }
|
if(typeof stack1 === functionType) { stack1 = stack1.call(depth0, { hash: {} }); }
|
||||||
else if(stack1=== undef) { stack1 = helperMissing.call(depth0, "nickname", { hash: {} }); }
|
else if(stack1=== undef) { stack1 = helperMissing.call(depth0, "nickname", { hash: {} }); }
|
||||||
buffer += escapeExpression(stack1) + "_";
|
buffer += escapeExpression(stack1) + "_";
|
||||||
foundHelper = helpers.httpMethod;
|
foundHelper = helpers.method;
|
||||||
stack1 = foundHelper || depth0.httpMethod;
|
stack1 = foundHelper || depth0.method;
|
||||||
if(typeof stack1 === functionType) { stack1 = stack1.call(depth0, { hash: {} }); }
|
if(typeof stack1 === functionType) { stack1 = stack1.call(depth0, { hash: {} }); }
|
||||||
else if(stack1=== undef) { stack1 = helperMissing.call(depth0, "httpMethod", { hash: {} }); }
|
else if(stack1=== undef) { stack1 = helperMissing.call(depth0, "method", { hash: {} }); }
|
||||||
buffer += escapeExpression(stack1) + "_";
|
buffer += escapeExpression(stack1) + "_";
|
||||||
foundHelper = helpers.number;
|
foundHelper = helpers.number;
|
||||||
stack1 = foundHelper || depth0.number;
|
stack1 = foundHelper || depth0.number;
|
||||||
@@ -429,10 +429,10 @@ function program11(depth0,data) {
|
|||||||
if(typeof stack1 === functionType) { stack1 = stack1.call(depth0, { hash: {} }); }
|
if(typeof stack1 === functionType) { stack1 = stack1.call(depth0, { hash: {} }); }
|
||||||
else if(stack1=== undef) { stack1 = helperMissing.call(depth0, "nickname", { hash: {} }); }
|
else if(stack1=== undef) { stack1 = helperMissing.call(depth0, "nickname", { hash: {} }); }
|
||||||
buffer += escapeExpression(stack1) + "_";
|
buffer += escapeExpression(stack1) + "_";
|
||||||
foundHelper = helpers.httpMethod;
|
foundHelper = helpers.method;
|
||||||
stack1 = foundHelper || depth0.httpMethod;
|
stack1 = foundHelper || depth0.method;
|
||||||
if(typeof stack1 === functionType) { stack1 = stack1.call(depth0, { hash: {} }); }
|
if(typeof stack1 === functionType) { stack1 = stack1.call(depth0, { hash: {} }); }
|
||||||
else if(stack1=== undef) { stack1 = helperMissing.call(depth0, "httpMethod", { hash: {} }); }
|
else if(stack1=== undef) { stack1 = helperMissing.call(depth0, "method", { hash: {} }); }
|
||||||
buffer += escapeExpression(stack1) + "_";
|
buffer += escapeExpression(stack1) + "_";
|
||||||
foundHelper = helpers.number;
|
foundHelper = helpers.number;
|
||||||
stack1 = foundHelper || depth0.number;
|
stack1 = foundHelper || depth0.number;
|
||||||
@@ -563,7 +563,7 @@ function program7(depth0,data) {
|
|||||||
stack1 = foundHelper || depth0.name;
|
stack1 = foundHelper || depth0.name;
|
||||||
if(typeof stack1 === functionType) { stack1 = stack1.call(depth0, { hash: {} }); }
|
if(typeof stack1 === functionType) { stack1 = stack1.call(depth0, { hash: {} }); }
|
||||||
else if(stack1=== undef) { stack1 = helperMissing.call(depth0, "name", { hash: {} }); }
|
else if(stack1=== undef) { stack1 = helperMissing.call(depth0, "name", { hash: {} }); }
|
||||||
buffer += escapeExpression(stack1) + "'></textarea>\n <br />\n <div class=\"content-type\" />\n ";
|
buffer += escapeExpression(stack1) + "'></textarea>\n <br />\n <div class=\"parameter-content-type\" />\n ";
|
||||||
return buffer;}
|
return buffer;}
|
||||||
|
|
||||||
function program9(depth0,data) {
|
function program9(depth0,data) {
|
||||||
@@ -635,7 +635,7 @@ function program12(depth0,data) {
|
|||||||
if(typeof stack1 === functionType) { stack1 = stack1.call(depth0, { hash: {} }); }
|
if(typeof stack1 === functionType) { stack1 = stack1.call(depth0, { hash: {} }); }
|
||||||
else if(stack1=== undef) { stack1 = helperMissing.call(depth0, "paramType", { hash: {} }); }
|
else if(stack1=== undef) { stack1 = helperMissing.call(depth0, "paramType", { hash: {} }); }
|
||||||
if(stack1 || stack1 === 0) { buffer += stack1; }
|
if(stack1 || stack1 === 0) { buffer += stack1; }
|
||||||
buffer += "</td>\n<td>\n <span class=\"model-signature\"></span>\n</td>\n\n";
|
buffer += "</td>\n<td>\n <span class=\"model-signature\"></span>\n</td>\n";
|
||||||
return buffer;});
|
return buffer;});
|
||||||
})();
|
})();
|
||||||
|
|
||||||
@@ -1008,7 +1008,7 @@ function program7(depth0,data) {
|
|||||||
stack1 = foundHelper || depth0.name;
|
stack1 = foundHelper || depth0.name;
|
||||||
if(typeof stack1 === functionType) { stack1 = stack1.call(depth0, { hash: {} }); }
|
if(typeof stack1 === functionType) { stack1 = stack1.call(depth0, { hash: {} }); }
|
||||||
else if(stack1=== undef) { stack1 = helperMissing.call(depth0, "name", { hash: {} }); }
|
else if(stack1=== undef) { stack1 = helperMissing.call(depth0, "name", { hash: {} }); }
|
||||||
buffer += escapeExpression(stack1) + "'></textarea>\n <br />\n <div class=\"content-type\" />\n ";
|
buffer += escapeExpression(stack1) + "'></textarea>\n <br />\n <div class=\"parameter-content-type\" />\n ";
|
||||||
return buffer;}
|
return buffer;}
|
||||||
|
|
||||||
function program9(depth0,data) {
|
function program9(depth0,data) {
|
||||||
@@ -1110,6 +1110,62 @@ function program15(depth0,data) {
|
|||||||
return buffer;});
|
return buffer;});
|
||||||
})();
|
})();
|
||||||
|
|
||||||
|
(function() {
|
||||||
|
var template = Handlebars.template, templates = Handlebars.templates = Handlebars.templates || {};
|
||||||
|
templates['parameter_content_type'] = template(function (Handlebars,depth0,helpers,partials,data) {
|
||||||
|
helpers = helpers || Handlebars.helpers;
|
||||||
|
var buffer = "", stack1, stack2, foundHelper, tmp1, self=this, functionType="function", helperMissing=helpers.helperMissing, undef=void 0;
|
||||||
|
|
||||||
|
function program1(depth0,data) {
|
||||||
|
|
||||||
|
var buffer = "", stack1, stack2;
|
||||||
|
buffer += "\n ";
|
||||||
|
foundHelper = helpers.consumes;
|
||||||
|
stack1 = foundHelper || depth0.consumes;
|
||||||
|
stack2 = helpers.each;
|
||||||
|
tmp1 = self.program(2, program2, data);
|
||||||
|
tmp1.hash = {};
|
||||||
|
tmp1.fn = tmp1;
|
||||||
|
tmp1.inverse = self.noop;
|
||||||
|
stack1 = stack2.call(depth0, stack1, tmp1);
|
||||||
|
if(stack1 || stack1 === 0) { buffer += stack1; }
|
||||||
|
buffer += "\n";
|
||||||
|
return buffer;}
|
||||||
|
function program2(depth0,data) {
|
||||||
|
|
||||||
|
var buffer = "", stack1;
|
||||||
|
buffer += "\n <option value=\"";
|
||||||
|
stack1 = depth0;
|
||||||
|
if(typeof stack1 === functionType) { stack1 = stack1.call(depth0, { hash: {} }); }
|
||||||
|
else if(stack1=== undef) { stack1 = helperMissing.call(depth0, "this", { hash: {} }); }
|
||||||
|
if(stack1 || stack1 === 0) { buffer += stack1; }
|
||||||
|
buffer += "\">";
|
||||||
|
stack1 = depth0;
|
||||||
|
if(typeof stack1 === functionType) { stack1 = stack1.call(depth0, { hash: {} }); }
|
||||||
|
else if(stack1=== undef) { stack1 = helperMissing.call(depth0, "this", { hash: {} }); }
|
||||||
|
if(stack1 || stack1 === 0) { buffer += stack1; }
|
||||||
|
buffer += "</option>\n ";
|
||||||
|
return buffer;}
|
||||||
|
|
||||||
|
function program4(depth0,data) {
|
||||||
|
|
||||||
|
|
||||||
|
return "\n <option value=\"application/json\">application/json</option>\n";}
|
||||||
|
|
||||||
|
buffer += "<label for=\"parameterContentType\"></label>\n<select name=\"parameterContentType\">\n";
|
||||||
|
foundHelper = helpers.consumes;
|
||||||
|
stack1 = foundHelper || depth0.consumes;
|
||||||
|
stack2 = helpers['if'];
|
||||||
|
tmp1 = self.program(1, program1, data);
|
||||||
|
tmp1.hash = {};
|
||||||
|
tmp1.fn = tmp1;
|
||||||
|
tmp1.inverse = self.program(4, program4, data);
|
||||||
|
stack1 = stack2.call(depth0, stack1, tmp1);
|
||||||
|
if(stack1 || stack1 === 0) { buffer += stack1; }
|
||||||
|
buffer += "\n</select>\n";
|
||||||
|
return buffer;});
|
||||||
|
})();
|
||||||
|
|
||||||
(function() {
|
(function() {
|
||||||
var template = Handlebars.template, templates = Handlebars.templates = Handlebars.templates || {};
|
var template = Handlebars.template, templates = Handlebars.templates = Handlebars.templates || {};
|
||||||
templates['resource'] = template(function (Handlebars,depth0,helpers,partials,data) {
|
templates['resource'] = template(function (Handlebars,depth0,helpers,partials,data) {
|
||||||
@@ -1171,6 +1227,62 @@ templates['resource'] = template(function (Handlebars,depth0,helpers,partials,da
|
|||||||
return buffer;});
|
return buffer;});
|
||||||
})();
|
})();
|
||||||
|
|
||||||
|
(function() {
|
||||||
|
var template = Handlebars.template, templates = Handlebars.templates = Handlebars.templates || {};
|
||||||
|
templates['response_content_type'] = template(function (Handlebars,depth0,helpers,partials,data) {
|
||||||
|
helpers = helpers || Handlebars.helpers;
|
||||||
|
var buffer = "", stack1, stack2, foundHelper, tmp1, self=this, functionType="function", helperMissing=helpers.helperMissing, undef=void 0;
|
||||||
|
|
||||||
|
function program1(depth0,data) {
|
||||||
|
|
||||||
|
var buffer = "", stack1, stack2;
|
||||||
|
buffer += "\n ";
|
||||||
|
foundHelper = helpers.produces;
|
||||||
|
stack1 = foundHelper || depth0.produces;
|
||||||
|
stack2 = helpers.each;
|
||||||
|
tmp1 = self.program(2, program2, data);
|
||||||
|
tmp1.hash = {};
|
||||||
|
tmp1.fn = tmp1;
|
||||||
|
tmp1.inverse = self.noop;
|
||||||
|
stack1 = stack2.call(depth0, stack1, tmp1);
|
||||||
|
if(stack1 || stack1 === 0) { buffer += stack1; }
|
||||||
|
buffer += "\n";
|
||||||
|
return buffer;}
|
||||||
|
function program2(depth0,data) {
|
||||||
|
|
||||||
|
var buffer = "", stack1;
|
||||||
|
buffer += "\n <option value=\"";
|
||||||
|
stack1 = depth0;
|
||||||
|
if(typeof stack1 === functionType) { stack1 = stack1.call(depth0, { hash: {} }); }
|
||||||
|
else if(stack1=== undef) { stack1 = helperMissing.call(depth0, "this", { hash: {} }); }
|
||||||
|
if(stack1 || stack1 === 0) { buffer += stack1; }
|
||||||
|
buffer += "\">";
|
||||||
|
stack1 = depth0;
|
||||||
|
if(typeof stack1 === functionType) { stack1 = stack1.call(depth0, { hash: {} }); }
|
||||||
|
else if(stack1=== undef) { stack1 = helperMissing.call(depth0, "this", { hash: {} }); }
|
||||||
|
if(stack1 || stack1 === 0) { buffer += stack1; }
|
||||||
|
buffer += "</option>\n ";
|
||||||
|
return buffer;}
|
||||||
|
|
||||||
|
function program4(depth0,data) {
|
||||||
|
|
||||||
|
|
||||||
|
return "\n <option value=\"application/json\">application/json</option>\n";}
|
||||||
|
|
||||||
|
buffer += "<label for=\"responseContentType\"></label>\n<select name=\"responseContentType\">\n";
|
||||||
|
foundHelper = helpers.produces;
|
||||||
|
stack1 = foundHelper || depth0.produces;
|
||||||
|
stack2 = helpers['if'];
|
||||||
|
tmp1 = self.program(1, program1, data);
|
||||||
|
tmp1.hash = {};
|
||||||
|
tmp1.fn = tmp1;
|
||||||
|
tmp1.inverse = self.program(4, program4, data);
|
||||||
|
stack1 = stack2.call(depth0, stack1, tmp1);
|
||||||
|
if(stack1 || stack1 === 0) { buffer += stack1; }
|
||||||
|
buffer += "\n</select>\n";
|
||||||
|
return buffer;});
|
||||||
|
})();
|
||||||
|
|
||||||
(function() {
|
(function() {
|
||||||
var template = Handlebars.template, templates = Handlebars.templates = Handlebars.templates || {};
|
var template = Handlebars.template, templates = Handlebars.templates = Handlebars.templates || {};
|
||||||
templates['signature'] = template(function (Handlebars,depth0,helpers,partials,data) {
|
templates['signature'] = template(function (Handlebars,depth0,helpers,partials,data) {
|
||||||
@@ -1219,7 +1331,7 @@ templates['status_code'] = template(function (Handlebars,depth0,helpers,partials
|
|||||||
|
|
||||||
// Generated by CoffeeScript 1.4.0
|
// Generated by CoffeeScript 1.4.0
|
||||||
(function() {
|
(function() {
|
||||||
var ContentTypeView, HeaderView, MainView, OperationView, ParameterView, ResourceView, SignatureView, StatusCodeView, SwaggerUi,
|
var ContentTypeView, HeaderView, MainView, OperationView, ParameterContentTypeView, ParameterView, ResourceView, ResponseContentTypeView, SignatureView, StatusCodeView, SwaggerUi,
|
||||||
__hasProp = {}.hasOwnProperty,
|
__hasProp = {}.hasOwnProperty,
|
||||||
__extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
|
__extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
|
||||||
|
|
||||||
@@ -1500,8 +1612,8 @@ templates['status_code'] = template(function (Handlebars,depth0,helpers,partials
|
|||||||
OperationView.prototype.initialize = function() {};
|
OperationView.prototype.initialize = function() {};
|
||||||
|
|
||||||
OperationView.prototype.render = function() {
|
OperationView.prototype.render = function() {
|
||||||
var contentTypeModel, contentTypeView, isMethodSubmissionSupported, param, responseSignatureView, signatureModel, statusCode, _i, _j, _len, _len1, _ref, _ref1;
|
var contentTypeModel, isMethodSubmissionSupported, param, responseContentTypeView, responseSignatureView, signatureModel, statusCode, _i, _j, _len, _len1, _ref, _ref1;
|
||||||
isMethodSubmissionSupported = jQuery.inArray(this.model.httpMethod, this.model.supportedSubmitMethods()) >= 0;
|
isMethodSubmissionSupported = true;
|
||||||
if (!isMethodSubmissionSupported) {
|
if (!isMethodSubmissionSupported) {
|
||||||
this.model.isReadOnly = true;
|
this.model.isReadOnly = true;
|
||||||
}
|
}
|
||||||
@@ -1523,22 +1635,18 @@ templates['status_code'] = template(function (Handlebars,depth0,helpers,partials
|
|||||||
contentTypeModel = {
|
contentTypeModel = {
|
||||||
isParam: false
|
isParam: false
|
||||||
};
|
};
|
||||||
if (this.model.supportedContentTypes) {
|
contentTypeModel.consumes = this.model.consumes;
|
||||||
contentTypeModel.produces = this.model.supportedContentTypes;
|
|
||||||
}
|
|
||||||
if (this.model.produces) {
|
|
||||||
contentTypeModel.produces = this.model.produces;
|
contentTypeModel.produces = this.model.produces;
|
||||||
}
|
responseContentTypeView = new ResponseContentTypeView({
|
||||||
contentTypeView = new ContentTypeView({
|
|
||||||
model: contentTypeModel
|
model: contentTypeModel
|
||||||
});
|
});
|
||||||
$('.content-type', $(this.el)).append(contentTypeView.render().el);
|
$('.response-content-type', $(this.el)).append(responseContentTypeView.render().el);
|
||||||
_ref = this.model.parameters;
|
_ref = this.model.parameters;
|
||||||
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
||||||
param = _ref[_i];
|
param = _ref[_i];
|
||||||
this.addParameter(param);
|
this.addParameter(param, contentTypeModel.consumes);
|
||||||
}
|
}
|
||||||
_ref1 = this.model.errorResponses;
|
_ref1 = this.model.responseMessages;
|
||||||
for (_j = 0, _len1 = _ref1.length; _j < _len1; _j++) {
|
for (_j = 0, _len1 = _ref1.length; _j < _len1; _j++) {
|
||||||
statusCode = _ref1[_j];
|
statusCode = _ref1[_j];
|
||||||
this.addStatusCode(statusCode);
|
this.addStatusCode(statusCode);
|
||||||
@@ -1546,8 +1654,9 @@ templates['status_code'] = template(function (Handlebars,depth0,helpers,partials
|
|||||||
return this;
|
return this;
|
||||||
};
|
};
|
||||||
|
|
||||||
OperationView.prototype.addParameter = function(param) {
|
OperationView.prototype.addParameter = function(param, consumes) {
|
||||||
var paramView;
|
var paramView;
|
||||||
|
param.consumes = consumes;
|
||||||
paramView = new ParameterView({
|
paramView = new ParameterView({
|
||||||
model: param,
|
model: param,
|
||||||
tagName: 'tr',
|
tagName: 'tr',
|
||||||
@@ -1566,8 +1675,7 @@ templates['status_code'] = template(function (Handlebars,depth0,helpers,partials
|
|||||||
};
|
};
|
||||||
|
|
||||||
OperationView.prototype.submitOperation = function(e) {
|
OperationView.prototype.submitOperation = function(e) {
|
||||||
var bodyParam, consumes, error_free, form, headerParams, invocationUrl, isFileUpload, isFormPost, map, o, obj, param, paramContentTypeField, responseContentTypeField, _i, _j, _k, _l, _len, _len1, _len2, _len3, _len4, _m, _ref, _ref1, _ref2, _ref3, _ref4,
|
var error_free, form, map, o, _i, _len, _ref;
|
||||||
_this = this;
|
|
||||||
if (e != null) {
|
if (e != null) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
}
|
}
|
||||||
@@ -1587,7 +1695,9 @@ templates['status_code'] = template(function (Handlebars,depth0,helpers,partials
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
if (error_free) {
|
if (error_free) {
|
||||||
map = {};
|
map = {
|
||||||
|
parent: this
|
||||||
|
};
|
||||||
_ref = form.serializeArray();
|
_ref = form.serializeArray();
|
||||||
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
||||||
o = _ref[_i];
|
o = _ref[_i];
|
||||||
@@ -1595,99 +1705,15 @@ templates['status_code'] = template(function (Handlebars,depth0,helpers,partials
|
|||||||
map[o.name] = o.value;
|
map[o.name] = o.value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
isFileUpload = form.children().find('input[type~="file"]').size() !== 0;
|
console.log(map);
|
||||||
isFormPost = false;
|
map["responseContentType"] = $("div select[name=responseContentType]", $(this.el)).val();
|
||||||
consumes = "application/json";
|
map["requestContentType"] = $("div select[name=parameterContentType]", $(this.el)).val();
|
||||||
if (this.model.consumes && this.model.consumes.length > 0) {
|
return this.model["do"](map, this.showCompleteStatus, this.showErrorStatus, this);
|
||||||
consumes = this.model.consumes[0];
|
|
||||||
} else {
|
|
||||||
_ref1 = this.model.parameters;
|
|
||||||
for (_j = 0, _len1 = _ref1.length; _j < _len1; _j++) {
|
|
||||||
o = _ref1[_j];
|
|
||||||
if (o.paramType === 'form') {
|
|
||||||
isFormPost = true;
|
|
||||||
consumes = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (isFileUpload) {
|
|
||||||
consumes = false;
|
|
||||||
} else if (this.model.httpMethod.toLowerCase() === "post" && isFormPost === false) {
|
|
||||||
consumes = "application/json";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (isFileUpload) {
|
|
||||||
bodyParam = new FormData();
|
|
||||||
_ref2 = this.model.parameters;
|
|
||||||
for (_k = 0, _len2 = _ref2.length; _k < _len2; _k++) {
|
|
||||||
param = _ref2[_k];
|
|
||||||
if ((param.paramType === 'body' || 'form') && param.name !== 'file' && param.name !== 'File' && (map[param.name] != null)) {
|
|
||||||
bodyParam.append(param.name, map[param.name]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$.each(form.children().find('input[type~="file"]'), function(i, el) {
|
|
||||||
return bodyParam.append($(el).attr('name'), el.files[0]);
|
|
||||||
});
|
|
||||||
console.log(bodyParam);
|
|
||||||
} else if (isFormPost) {
|
|
||||||
bodyParam = new FormData();
|
|
||||||
_ref3 = this.model.parameters;
|
|
||||||
for (_l = 0, _len3 = _ref3.length; _l < _len3; _l++) {
|
|
||||||
param = _ref3[_l];
|
|
||||||
if (map[param.name] != null) {
|
|
||||||
bodyParam.append(param.name, map[param.name]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
bodyParam = null;
|
|
||||||
_ref4 = this.model.parameters;
|
|
||||||
for (_m = 0, _len4 = _ref4.length; _m < _len4; _m++) {
|
|
||||||
param = _ref4[_m];
|
|
||||||
if (param.paramType === 'body') {
|
|
||||||
bodyParam = map[param.name];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
log("bodyParam = " + bodyParam);
|
|
||||||
headerParams = null;
|
|
||||||
invocationUrl = this.model.supportHeaderParams() ? (headerParams = this.model.getHeaderParams(map), this.model.urlify(map, false)) : this.model.urlify(map, true);
|
|
||||||
log('submitting ' + invocationUrl);
|
|
||||||
$(".request_url", $(this.el)).html("<pre>" + invocationUrl + "</pre>");
|
|
||||||
$(".response_throbber", $(this.el)).show();
|
|
||||||
obj = {
|
|
||||||
type: this.model.httpMethod,
|
|
||||||
url: invocationUrl,
|
|
||||||
headers: headerParams,
|
|
||||||
data: bodyParam,
|
|
||||||
contentType: consumes,
|
|
||||||
dataType: 'json',
|
|
||||||
processData: false,
|
|
||||||
error: function(xhr, textStatus, error) {
|
|
||||||
return _this.showErrorStatus(xhr, textStatus, error);
|
|
||||||
},
|
|
||||||
success: function(data) {
|
|
||||||
return _this.showResponse(data);
|
|
||||||
},
|
|
||||||
complete: function(data) {
|
|
||||||
return _this.showCompleteStatus(data);
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
paramContentTypeField = $("td select[name=contentType]", $(this.el)).val();
|
|
||||||
if (paramContentTypeField) {
|
OperationView.prototype.success = function(response, parent) {
|
||||||
obj.contentType = paramContentTypeField;
|
return parent.showCompleteStatus(response);
|
||||||
}
|
|
||||||
log('content type = ' + obj.contentType);
|
|
||||||
if (!(obj.data || (obj.type === 'GET' || obj.type === 'DELETE')) && obj.contentType === !"application/x-www-form-urlencoded") {
|
|
||||||
obj.contentType = false;
|
|
||||||
}
|
|
||||||
log('content type is now = ' + obj.contentType);
|
|
||||||
responseContentTypeField = $('.content > .content-type > div > select[name=contentType]', $(this.el)).val();
|
|
||||||
if (responseContentTypeField) {
|
|
||||||
obj.headers = obj.headers != null ? obj.headers : {};
|
|
||||||
obj.headers.accept = responseContentTypeField;
|
|
||||||
}
|
|
||||||
jQuery.ajax(obj);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
OperationView.prototype.hideResponse = function(e) {
|
OperationView.prototype.hideResponse = function(e) {
|
||||||
@@ -1704,12 +1730,12 @@ templates['status_code'] = template(function (Handlebars,depth0,helpers,partials
|
|||||||
return $(".response_body", $(this.el)).html(escape(prettyJson));
|
return $(".response_body", $(this.el)).html(escape(prettyJson));
|
||||||
};
|
};
|
||||||
|
|
||||||
OperationView.prototype.showErrorStatus = function(data) {
|
OperationView.prototype.showErrorStatus = function(data, parent) {
|
||||||
return this.showStatus(data);
|
return parent.showStatus(data);
|
||||||
};
|
};
|
||||||
|
|
||||||
OperationView.prototype.showCompleteStatus = function(data) {
|
OperationView.prototype.showCompleteStatus = function(data, parent) {
|
||||||
return this.showStatus(data);
|
return parent.showStatus(data);
|
||||||
};
|
};
|
||||||
|
|
||||||
OperationView.prototype.formatXml = function(xml) {
|
OperationView.prototype.formatXml = function(xml) {
|
||||||
@@ -1786,18 +1812,31 @@ templates['status_code'] = template(function (Handlebars,depth0,helpers,partials
|
|||||||
};
|
};
|
||||||
|
|
||||||
OperationView.prototype.showStatus = function(data) {
|
OperationView.prototype.showStatus = function(data) {
|
||||||
var code, pre, response_body;
|
var code, content, contentType, headers, pre, response_body;
|
||||||
try {
|
content = data.content.data;
|
||||||
code = $('<code />').text(JSON.stringify(JSON.parse(data.responseText), null, 2));
|
headers = data.getHeaders();
|
||||||
|
contentType = headers["Content-Type"];
|
||||||
|
if (content === void 0) {
|
||||||
|
code = $('<code />').text("no content");
|
||||||
pre = $('<pre class="json" />').append(code);
|
pre = $('<pre class="json" />').append(code);
|
||||||
} catch (error) {
|
} else if (contentType.indexOf("application/json") === 0) {
|
||||||
code = $('<code />').text(this.formatXml(data.responseText));
|
code = $('<code />').text(JSON.stringify(JSON.parse(content), null, 2));
|
||||||
|
pre = $('<pre class="json" />').append(code);
|
||||||
|
} else if (contentType.indexOf("application/xml") === 0) {
|
||||||
|
code = $('<code />').text(this.formatXml(content));
|
||||||
pre = $('<pre class="xml" />').append(code);
|
pre = $('<pre class="xml" />').append(code);
|
||||||
|
} else if (contentType.indexOf("text/html") === 0) {
|
||||||
|
code = $('<code />').html(content);
|
||||||
|
pre = $('<pre class="xml" />').append(code);
|
||||||
|
} else {
|
||||||
|
code = $('<code />').text(content);
|
||||||
|
pre = $('<pre class="json" />').append(code);
|
||||||
}
|
}
|
||||||
response_body = pre;
|
response_body = pre;
|
||||||
|
$(".request_url").html("<pre>" + data.request.url + "</pre>");
|
||||||
$(".response_code", $(this.el)).html("<pre>" + data.status + "</pre>");
|
$(".response_code", $(this.el)).html("<pre>" + data.status + "</pre>");
|
||||||
$(".response_body", $(this.el)).html(response_body);
|
$(".response_body", $(this.el)).html(response_body);
|
||||||
$(".response_headers", $(this.el)).html("<pre>" + data.getAllResponseHeaders() + "</pre>");
|
$(".response_headers", $(this.el)).html("<pre>" + JSON.stringify(data.getHeaders()) + "</pre>");
|
||||||
$(".response", $(this.el)).slideDown();
|
$(".response", $(this.el)).slideDown();
|
||||||
$(".response_hider", $(this.el)).show();
|
$(".response_hider", $(this.el)).show();
|
||||||
$(".response_throbber", $(this.el)).hide();
|
$(".response_throbber", $(this.el)).hide();
|
||||||
@@ -1806,7 +1845,7 @@ templates['status_code'] = template(function (Handlebars,depth0,helpers,partials
|
|||||||
|
|
||||||
OperationView.prototype.toggleOperationContent = function() {
|
OperationView.prototype.toggleOperationContent = function() {
|
||||||
var elem;
|
var elem;
|
||||||
elem = $('#' + Docs.escapeResourceName(this.model.resourceName) + "_" + this.model.nickname + "_" + this.model.httpMethod + "_" + this.model.number + "_content");
|
elem = $('#' + Docs.escapeResourceName(this.model.resourceName) + "_" + this.model.nickname + "_" + this.model.method + "_" + this.model.number + "_content");
|
||||||
if (elem.is(':visible')) {
|
if (elem.is(':visible')) {
|
||||||
return Docs.collapseOperation(elem);
|
return Docs.collapseOperation(elem);
|
||||||
} else {
|
} else {
|
||||||
@@ -1854,7 +1893,7 @@ templates['status_code'] = template(function (Handlebars,depth0,helpers,partials
|
|||||||
ParameterView.prototype.initialize = function() {};
|
ParameterView.prototype.initialize = function() {};
|
||||||
|
|
||||||
ParameterView.prototype.render = function() {
|
ParameterView.prototype.render = function() {
|
||||||
var contentTypeModel, contentTypeView, signatureModel, signatureView, template;
|
var contentTypeModel, isParam, parameterContentTypeView, responseContentTypeView, signatureModel, signatureView, template;
|
||||||
if (this.model.paramType === 'body') {
|
if (this.model.paramType === 'body') {
|
||||||
this.model.isBody = true;
|
this.model.isBody = true;
|
||||||
}
|
}
|
||||||
@@ -1877,19 +1916,25 @@ templates['status_code'] = template(function (Handlebars,depth0,helpers,partials
|
|||||||
} else {
|
} else {
|
||||||
$('.model-signature', $(this.el)).html(this.model.signature);
|
$('.model-signature', $(this.el)).html(this.model.signature);
|
||||||
}
|
}
|
||||||
|
isParam = false;
|
||||||
|
if (this.model.isBody) {
|
||||||
|
isParam = true;
|
||||||
|
}
|
||||||
contentTypeModel = {
|
contentTypeModel = {
|
||||||
isParam: false
|
isParam: isParam
|
||||||
};
|
};
|
||||||
if (this.model.supportedContentTypes) {
|
contentTypeModel.consumes = this.model.consumes;
|
||||||
contentTypeModel.produces = this.model.supportedContentTypes;
|
if (isParam) {
|
||||||
}
|
parameterContentTypeView = new ParameterContentTypeView({
|
||||||
if (this.model.produces) {
|
|
||||||
contentTypeModel.produces = this.model.produces;
|
|
||||||
}
|
|
||||||
contentTypeView = new ContentTypeView({
|
|
||||||
model: contentTypeModel
|
model: contentTypeModel
|
||||||
});
|
});
|
||||||
$('.content-type', $(this.el)).append(contentTypeView.render().el);
|
$('.parameter-content-type', $(this.el)).append(parameterContentTypeView.render().el);
|
||||||
|
} else {
|
||||||
|
responseContentTypeView = new ResponseContentTypeView({
|
||||||
|
model: contentTypeModel
|
||||||
|
});
|
||||||
|
$('.response-content-type', $(this.el)).append(responseContentTypeView.render().el);
|
||||||
|
}
|
||||||
return this;
|
return this;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -2000,12 +2045,7 @@ templates['status_code'] = template(function (Handlebars,depth0,helpers,partials
|
|||||||
var template;
|
var template;
|
||||||
template = this.template();
|
template = this.template();
|
||||||
$(this.el).html(template(this.model));
|
$(this.el).html(template(this.model));
|
||||||
this.isParam = this.model.isParam;
|
|
||||||
if (this.isParam) {
|
|
||||||
$('label[for=contentType]', $(this.el)).text('Parameter content type:');
|
|
||||||
} else {
|
|
||||||
$('label[for=contentType]', $(this.el)).text('Response Content Type');
|
$('label[for=contentType]', $(this.el)).text('Response Content Type');
|
||||||
}
|
|
||||||
return this;
|
return this;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -2017,4 +2057,56 @@ templates['status_code'] = template(function (Handlebars,depth0,helpers,partials
|
|||||||
|
|
||||||
})(Backbone.View);
|
})(Backbone.View);
|
||||||
|
|
||||||
|
ResponseContentTypeView = (function(_super) {
|
||||||
|
|
||||||
|
__extends(ResponseContentTypeView, _super);
|
||||||
|
|
||||||
|
function ResponseContentTypeView() {
|
||||||
|
return ResponseContentTypeView.__super__.constructor.apply(this, arguments);
|
||||||
|
}
|
||||||
|
|
||||||
|
ResponseContentTypeView.prototype.initialize = function() {};
|
||||||
|
|
||||||
|
ResponseContentTypeView.prototype.render = function() {
|
||||||
|
var template;
|
||||||
|
template = this.template();
|
||||||
|
$(this.el).html(template(this.model));
|
||||||
|
$('label[for=responseContentType]', $(this.el)).text('Response Content Type');
|
||||||
|
return this;
|
||||||
|
};
|
||||||
|
|
||||||
|
ResponseContentTypeView.prototype.template = function() {
|
||||||
|
return Handlebars.templates.response_content_type;
|
||||||
|
};
|
||||||
|
|
||||||
|
return ResponseContentTypeView;
|
||||||
|
|
||||||
|
})(Backbone.View);
|
||||||
|
|
||||||
|
ParameterContentTypeView = (function(_super) {
|
||||||
|
|
||||||
|
__extends(ParameterContentTypeView, _super);
|
||||||
|
|
||||||
|
function ParameterContentTypeView() {
|
||||||
|
return ParameterContentTypeView.__super__.constructor.apply(this, arguments);
|
||||||
|
}
|
||||||
|
|
||||||
|
ParameterContentTypeView.prototype.initialize = function() {};
|
||||||
|
|
||||||
|
ParameterContentTypeView.prototype.render = function() {
|
||||||
|
var template;
|
||||||
|
template = this.template();
|
||||||
|
$(this.el).html(template(this.model));
|
||||||
|
$('label[for=parameterContentType]', $(this.el)).text('Parameter content type:');
|
||||||
|
return this;
|
||||||
|
};
|
||||||
|
|
||||||
|
ParameterContentTypeView.prototype.template = function() {
|
||||||
|
return Handlebars.templates.parameter_content_type;
|
||||||
|
};
|
||||||
|
|
||||||
|
return ParameterContentTypeView;
|
||||||
|
|
||||||
|
})(Backbone.View);
|
||||||
|
|
||||||
}).call(this);
|
}).call(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
@@ -5,11 +5,6 @@ class ContentTypeView extends Backbone.View
|
|||||||
template = @template()
|
template = @template()
|
||||||
$(@el).html(template(@model))
|
$(@el).html(template(@model))
|
||||||
|
|
||||||
@isParam = @model.isParam
|
|
||||||
|
|
||||||
if @isParam
|
|
||||||
$('label[for=contentType]', $(@el)).text('Parameter content type:')
|
|
||||||
else
|
|
||||||
$('label[for=contentType]', $(@el)).text('Response Content Type')
|
$('label[for=contentType]', $(@el)).text('Response Content Type')
|
||||||
|
|
||||||
@
|
@
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ class OperationView extends Backbone.View
|
|||||||
initialize: ->
|
initialize: ->
|
||||||
|
|
||||||
render: ->
|
render: ->
|
||||||
isMethodSubmissionSupported = jQuery.inArray(@model.httpMethod, @model.supportedSubmitMethods()) >= 0
|
isMethodSubmissionSupported = true #jQuery.inArray(@model.method, @model.supportedSubmitMethods) >= 0
|
||||||
@model.isReadOnly = true unless isMethodSubmissionSupported
|
@model.isReadOnly = true unless isMethodSubmissionSupported
|
||||||
|
|
||||||
$(@el).html(Handlebars.templates.operation(@model))
|
$(@el).html(Handlebars.templates.operation(@model))
|
||||||
@@ -28,26 +28,23 @@ class OperationView extends Backbone.View
|
|||||||
contentTypeModel =
|
contentTypeModel =
|
||||||
isParam: false
|
isParam: false
|
||||||
|
|
||||||
# support old syntax
|
contentTypeModel.consumes = @model.consumes
|
||||||
if @model.supportedContentTypes
|
|
||||||
contentTypeModel.produces = @model.supportedContentTypes
|
|
||||||
|
|
||||||
if @model.produces
|
|
||||||
contentTypeModel.produces = @model.produces
|
contentTypeModel.produces = @model.produces
|
||||||
|
|
||||||
contentTypeView = new ContentTypeView({model: contentTypeModel})
|
responseContentTypeView = new ResponseContentTypeView({model: contentTypeModel})
|
||||||
$('.content-type', $(@el)).append contentTypeView.render().el
|
$('.response-content-type', $(@el)).append responseContentTypeView.render().el
|
||||||
|
|
||||||
# Render each parameter
|
# Render each parameter
|
||||||
@addParameter param for param in @model.parameters
|
@addParameter param, contentTypeModel.consumes for param in @model.parameters
|
||||||
|
|
||||||
# Render each response code
|
# Render each response code
|
||||||
@addStatusCode statusCode for statusCode in @model.errorResponses
|
@addStatusCode statusCode for statusCode in @model.responseMessages
|
||||||
|
|
||||||
@
|
@
|
||||||
|
|
||||||
addParameter: (param) ->
|
addParameter: (param, consumes) ->
|
||||||
# Render a parameter
|
# Render a parameter
|
||||||
|
param.consumes = consumes
|
||||||
paramView = new ParameterView({model: param, tagName: 'tr', readOnly: @model.isReadOnly})
|
paramView = new ParameterView({model: param, tagName: 'tr', readOnly: @model.isReadOnly})
|
||||||
$('.operation-params', $(@el)).append paramView.render().el
|
$('.operation-params', $(@el)).append paramView.render().el
|
||||||
|
|
||||||
@@ -71,104 +68,21 @@ class OperationView extends Backbone.View
|
|||||||
|
|
||||||
# if error free submit it
|
# if error free submit it
|
||||||
if error_free
|
if error_free
|
||||||
map = {}
|
map = {parent: @}
|
||||||
for o in form.serializeArray()
|
for o in form.serializeArray()
|
||||||
if(o.value? && jQuery.trim(o.value).length > 0)
|
if(o.value? && jQuery.trim(o.value).length > 0)
|
||||||
map[o.name] = o.value
|
map[o.name] = o.value
|
||||||
|
|
||||||
isFileUpload = form.children().find('input[type~="file"]').size() != 0
|
console.log map
|
||||||
|
|
||||||
isFormPost = false
|
map["responseContentType"] = $("div select[name=responseContentType]", $(@el)).val()
|
||||||
consumes = "application/json"
|
map["requestContentType"] = $("div select[name=parameterContentType]", $(@el)).val()
|
||||||
if @model.consumes and @model.consumes.length > 0
|
|
||||||
# honor the consumes setting above everything else
|
|
||||||
consumes = @model.consumes[0]
|
|
||||||
else
|
|
||||||
for o in @model.parameters
|
|
||||||
if o.paramType == 'form'
|
|
||||||
isFormPost = true
|
|
||||||
consumes = false
|
|
||||||
|
|
||||||
if isFileUpload
|
@model.do(map, @showCompleteStatus, @showErrorStatus, @)
|
||||||
consumes = false
|
|
||||||
else if @model.httpMethod.toLowerCase() == "post" and isFormPost is false
|
|
||||||
consumes = "application/json"
|
|
||||||
|
|
||||||
if isFileUpload
|
success: (response, parent) ->
|
||||||
# requires HTML5 compatible browser
|
parent.showCompleteStatus response
|
||||||
bodyParam = new FormData()
|
|
||||||
|
|
||||||
# add params except file
|
|
||||||
for param in @model.parameters
|
|
||||||
if (param.paramType is 'body' or 'form') and param.name isnt 'file' and param.name isnt 'File' and map[param.name]?
|
|
||||||
bodyParam.append(param.name, map[param.name])
|
|
||||||
|
|
||||||
# add files
|
|
||||||
$.each form.children().find('input[type~="file"]'), (i, el) ->
|
|
||||||
bodyParam.append($(el).attr('name'), el.files[0])
|
|
||||||
|
|
||||||
console.log(bodyParam)
|
|
||||||
else if isFormPost
|
|
||||||
bodyParam = new FormData()
|
|
||||||
for param in @model.parameters
|
|
||||||
if map[param.name]?
|
|
||||||
bodyParam.append(param.name, map[param.name])
|
|
||||||
else
|
|
||||||
bodyParam = null
|
|
||||||
for param in @model.parameters
|
|
||||||
if param.paramType is 'body'
|
|
||||||
bodyParam = map[param.name]
|
|
||||||
|
|
||||||
log "bodyParam = " + bodyParam
|
|
||||||
|
|
||||||
headerParams = null
|
|
||||||
invocationUrl =
|
|
||||||
if @model.supportHeaderParams()
|
|
||||||
headerParams = @model.getHeaderParams(map)
|
|
||||||
@model.urlify(map, false)
|
|
||||||
else
|
|
||||||
@model.urlify(map, true)
|
|
||||||
|
|
||||||
log 'submitting ' + invocationUrl
|
|
||||||
|
|
||||||
|
|
||||||
$(".request_url", $(@el)).html "<pre>" + invocationUrl + "</pre>"
|
|
||||||
$(".response_throbber", $(@el)).show()
|
|
||||||
|
|
||||||
obj =
|
|
||||||
type: @model.httpMethod
|
|
||||||
url: invocationUrl
|
|
||||||
headers: headerParams
|
|
||||||
data: bodyParam
|
|
||||||
contentType: consumes
|
|
||||||
dataType: 'json'
|
|
||||||
processData: false
|
|
||||||
error: (xhr, textStatus, error) =>
|
|
||||||
@showErrorStatus(xhr, textStatus, error)
|
|
||||||
success: (data) =>
|
|
||||||
@showResponse(data)
|
|
||||||
complete: (data) =>
|
|
||||||
@showCompleteStatus(data)
|
|
||||||
|
|
||||||
paramContentTypeField = $("td select[name=contentType]", $(@el)).val()
|
|
||||||
if paramContentTypeField
|
|
||||||
obj.contentType = paramContentTypeField
|
|
||||||
|
|
||||||
log 'content type = ' + obj.contentType
|
|
||||||
|
|
||||||
if not (obj.data or (obj.type is 'GET' or obj.type is 'DELETE')) and obj.contentType is not "application/x-www-form-urlencoded"
|
|
||||||
obj.contentType = false
|
|
||||||
|
|
||||||
log 'content type is now = ' + obj.contentType
|
|
||||||
|
|
||||||
responseContentTypeField = $('.content > .content-type > div > select[name=contentType]', $(@el)).val()
|
|
||||||
if responseContentTypeField
|
|
||||||
obj.headers = if obj.headers? then obj.headers else {}
|
|
||||||
obj.headers.accept = responseContentTypeField
|
|
||||||
|
|
||||||
jQuery.ajax(obj)
|
|
||||||
false
|
|
||||||
# $.getJSON(invocationUrl, (r) => @showResponse(r)).complete((r) => @showCompleteStatus(r)).error (r) => @showErrorStatus(r)
|
|
||||||
|
|
||||||
# handler for hide response link
|
# handler for hide response link
|
||||||
hideResponse: (e) ->
|
hideResponse: (e) ->
|
||||||
@@ -182,14 +96,13 @@ class OperationView extends Backbone.View
|
|||||||
prettyJson = JSON.stringify(response, null, "\t").replace(/\n/g, "<br>")
|
prettyJson = JSON.stringify(response, null, "\t").replace(/\n/g, "<br>")
|
||||||
$(".response_body", $(@el)).html escape(prettyJson)
|
$(".response_body", $(@el)).html escape(prettyJson)
|
||||||
|
|
||||||
|
|
||||||
# Show error from server
|
# Show error from server
|
||||||
showErrorStatus: (data) ->
|
showErrorStatus: (data, parent) ->
|
||||||
@showStatus data
|
parent.showStatus data
|
||||||
|
|
||||||
# show the status codes
|
# show the status codes
|
||||||
showCompleteStatus: (data) ->
|
showCompleteStatus: (data, parent) ->
|
||||||
@showStatus data
|
parent.showStatus data
|
||||||
|
|
||||||
# Adapted from http://stackoverflow.com/a/2893259/454004
|
# Adapted from http://stackoverflow.com/a/2893259/454004
|
||||||
formatXml: (xml) ->
|
formatXml: (xml) ->
|
||||||
@@ -252,21 +165,39 @@ class OperationView extends Backbone.View
|
|||||||
|
|
||||||
# puts the response data in UI
|
# puts the response data in UI
|
||||||
showStatus: (data) ->
|
showStatus: (data) ->
|
||||||
try
|
content = data.content.data
|
||||||
code = $('<code />').text(JSON.stringify(JSON.parse(data.responseText), null, 2))
|
headers = data.getHeaders()
|
||||||
|
|
||||||
|
# if server is nice, and sends content-type back, we can use it
|
||||||
|
contentType = headers["Content-Type"]
|
||||||
|
|
||||||
|
if content == undefined
|
||||||
|
code = $('<code />').text("no content")
|
||||||
pre = $('<pre class="json" />').append(code)
|
pre = $('<pre class="json" />').append(code)
|
||||||
catch error
|
else if contentType.indexOf("application/json") == 0
|
||||||
code = $('<code />').text(@formatXml(data.responseText))
|
code = $('<code />').text(JSON.stringify(JSON.parse(content), null, 2))
|
||||||
|
pre = $('<pre class="json" />').append(code)
|
||||||
|
else if contentType.indexOf("application/xml") == 0
|
||||||
|
code = $('<code />').text(@formatXml(content))
|
||||||
pre = $('<pre class="xml" />').append(code)
|
pre = $('<pre class="xml" />').append(code)
|
||||||
|
else if contentType.indexOf("text/html") == 0
|
||||||
|
code = $('<code />').html(content)
|
||||||
|
pre = $('<pre class="xml" />').append(code)
|
||||||
|
else
|
||||||
|
# don't know what to render!
|
||||||
|
code = $('<code />').text(content)
|
||||||
|
pre = $('<pre class="json" />').append(code)
|
||||||
|
|
||||||
response_body = pre
|
response_body = pre
|
||||||
|
$(".request_url").html "<pre>" + data.request.url + "</pre>"
|
||||||
$(".response_code", $(@el)).html "<pre>" + data.status + "</pre>"
|
$(".response_code", $(@el)).html "<pre>" + data.status + "</pre>"
|
||||||
$(".response_body", $(@el)).html response_body
|
$(".response_body", $(@el)).html response_body
|
||||||
$(".response_headers", $(@el)).html "<pre>" + data.getAllResponseHeaders() + "</pre>"
|
$(".response_headers", $(@el)).html "<pre>" + JSON.stringify(data.getHeaders()) + "</pre>"
|
||||||
$(".response", $(@el)).slideDown()
|
$(".response", $(@el)).slideDown()
|
||||||
$(".response_hider", $(@el)).show()
|
$(".response_hider", $(@el)).show()
|
||||||
$(".response_throbber", $(@el)).hide()
|
$(".response_throbber", $(@el)).hide()
|
||||||
hljs.highlightBlock($('.response_body', $(@el))[0])
|
hljs.highlightBlock($('.response_body', $(@el))[0])
|
||||||
|
|
||||||
toggleOperationContent: ->
|
toggleOperationContent: ->
|
||||||
elem = $('#' + Docs.escapeResourceName(@model.resourceName) + "_" + @model.nickname + "_" + @model.httpMethod + "_" + @model.number + "_content")
|
elem = $('#' + Docs.escapeResourceName(@model.resourceName) + "_" + @model.nickname + "_" + @model.method + "_" + @model.number + "_content")
|
||||||
if elem.is(':visible') then Docs.collapseOperation(elem) else Docs.expandOperation(elem)
|
if elem.is(':visible') then Docs.collapseOperation(elem) else Docs.expandOperation(elem)
|
||||||
|
|||||||
@@ -19,18 +19,23 @@ class ParameterView extends Backbone.View
|
|||||||
else
|
else
|
||||||
$('.model-signature', $(@el)).html(@model.signature)
|
$('.model-signature', $(@el)).html(@model.signature)
|
||||||
|
|
||||||
|
isParam = false
|
||||||
|
|
||||||
|
if @model.isBody
|
||||||
|
isParam = true
|
||||||
|
|
||||||
contentTypeModel =
|
contentTypeModel =
|
||||||
isParam: false
|
isParam: isParam
|
||||||
|
|
||||||
# support old syntax
|
contentTypeModel.consumes = @model.consumes
|
||||||
if @model.supportedContentTypes
|
|
||||||
contentTypeModel.produces = @model.supportedContentTypes
|
|
||||||
|
|
||||||
if @model.produces
|
if isParam
|
||||||
contentTypeModel.produces = @model.produces
|
parameterContentTypeView = new ParameterContentTypeView({model: contentTypeModel})
|
||||||
|
$('.parameter-content-type', $(@el)).append parameterContentTypeView.render().el
|
||||||
|
|
||||||
contentTypeView = new ContentTypeView({model: contentTypeModel})
|
else
|
||||||
$('.content-type', $(@el)).append contentTypeView.render().el
|
responseContentTypeView = new ResponseContentTypeView({model: contentTypeModel})
|
||||||
|
$('.response-content-type', $(@el)).append responseContentTypeView.render().el
|
||||||
|
|
||||||
@
|
@
|
||||||
|
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
<link href='//fonts.googleapis.com/css?family=Droid+Sans:400,700' rel='stylesheet' type='text/css'/>
|
<link href='//fonts.googleapis.com/css?family=Droid+Sans:400,700' rel='stylesheet' type='text/css'/>
|
||||||
<link href='css/hightlight.default.css' media='screen' rel='stylesheet' type='text/css'/>
|
<link href='css/hightlight.default.css' media='screen' rel='stylesheet' type='text/css'/>
|
||||||
<link href='css/screen.css' media='screen' rel='stylesheet' type='text/css'/>
|
<link href='css/screen.css' media='screen' rel='stylesheet' type='text/css'/>
|
||||||
|
<script type="text/javascript" src="lib/shred.bundle.js" /></script>
|
||||||
<script src='lib/jquery-1.8.0.min.js' type='text/javascript'></script>
|
<script src='lib/jquery-1.8.0.min.js' type='text/javascript'></script>
|
||||||
<script src='lib/jquery.slideto.min.js' type='text/javascript'></script>
|
<script src='lib/jquery.slideto.min.js' type='text/javascript'></script>
|
||||||
<script src='lib/jquery.wiggle.min.js' type='text/javascript'></script>
|
<script src='lib/jquery.wiggle.min.js' type='text/javascript'></script>
|
||||||
@@ -15,15 +16,14 @@
|
|||||||
<script src='lib/swagger.js' type='text/javascript'></script>
|
<script src='lib/swagger.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>
|
||||||
|
<script src='lib/highlight.7.3.pack.js' type='text/javascript'></script>
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
$(function () {
|
$(function () {
|
||||||
window.swaggerUi = new SwaggerUi({
|
window.swaggerUi = new SwaggerUi({
|
||||||
discoveryUrl:"http://petstore.swagger.wordnik.com/api/api-docs.json",
|
discoveryUrl:"http://localhost:8002/api/api-docs",
|
||||||
apiKey:"special-key",
|
|
||||||
dom_id:"swagger-ui-container",
|
dom_id:"swagger-ui-container",
|
||||||
supportHeaderParams: false,
|
supportHeaderParams: false,
|
||||||
supportedSubmitMethods: ['get', 'post', 'put'],
|
supportedSubmitMethods: ['get', 'post', 'put', 'delete'],
|
||||||
onComplete: function(swaggerApi, swaggerUi){
|
onComplete: function(swaggerApi, swaggerUi){
|
||||||
if(console) {
|
if(console) {
|
||||||
console.log("Loaded SwaggerUI")
|
console.log("Loaded SwaggerUI")
|
||||||
@@ -41,6 +41,13 @@
|
|||||||
docExpansion: "none"
|
docExpansion: "none"
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$('#input_apiKey').change(function() {
|
||||||
|
var key = $('#input_apiKey')[0].value;
|
||||||
|
console.log("key: " + key);
|
||||||
|
if(key && key.trim() != "") {
|
||||||
|
window.authorizations.add("key", new ApiKeyAuthorization("api_key", key, "query"));
|
||||||
|
}
|
||||||
|
})
|
||||||
window.swaggerUi.load();
|
window.swaggerUi.load();
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -59,8 +66,7 @@
|
|||||||
<div class='input icon-btn'>
|
<div class='input icon-btn'>
|
||||||
<img id="show-wordnik-dev-icon" src="images/wordnik_api.png" title="Show Wordnik Developer Apis">
|
<img id="show-wordnik-dev-icon" src="images/wordnik_api.png" title="Show Wordnik Developer Apis">
|
||||||
</div>
|
</div>
|
||||||
<div class='input'><input placeholder="http://example.com/api" id="input_baseUrl" name="baseUrl"
|
<div class='input'><input placeholder="http://example.com/api" id="input_baseUrl" name="baseUrl" type="text"/></div>
|
||||||
type="text"/></div>
|
|
||||||
<div class='input'><input placeholder="api_key" id="input_apiKey" name="apiKey" type="text"/></div>
|
<div class='input'><input placeholder="api_key" id="input_apiKey" name="apiKey" type="text"/></div>
|
||||||
<div class='input'><a id="explore" href="#">Explore</a></div>
|
<div class='input'><a id="explore" href="#">Explore</a></div>
|
||||||
</form>
|
</form>
|
||||||
|
|||||||
@@ -1,22 +1,22 @@
|
|||||||
|
|
||||||
<ul class='operations' >
|
<ul class='operations' >
|
||||||
<li class='{{httpMethod}} operation' id='{{resourceName}}_{{nickname}}_{{httpMethod}}_{{number}}'>
|
<li class='{{method}} operation' id='{{resourceName}}_{{nickname}}_{{method}}_{{number}}'>
|
||||||
<div class='heading'>
|
<div class='heading'>
|
||||||
<h3>
|
<h3>
|
||||||
<span class='http_method'>
|
<span class='http_method'>
|
||||||
<a href='#!/{{resourceName}}/{{nickname}}_{{httpMethod}}_{{number}}' class="toggleOperation">{{httpMethod}}</a>
|
<a href='#!/{{resourceName}}/{{nickname}}_{{method}}_{{number}}' class="toggleOperation">{{method}}</a>
|
||||||
</span>
|
</span>
|
||||||
<span class='path'>
|
<span class='path'>
|
||||||
<a href='#!/{{resourceName}}/{{nickname}}_{{httpMethod}}_{{number}}' class="toggleOperation">{{path}}</a>
|
<a href='#!/{{resourceName}}/{{nickname}}_{{method}}_{{number}}' class="toggleOperation">{{path}}</a>
|
||||||
</span>
|
</span>
|
||||||
</h3>
|
</h3>
|
||||||
<ul class='options'>
|
<ul class='options'>
|
||||||
<li>
|
<li>
|
||||||
<a href='#!/{{resourceName}}/{{nickname}}_{{httpMethod}}_{{number}}' class="toggleOperation">{{{summary}}}</a>
|
<a href='#!/{{resourceName}}/{{nickname}}_{{method}}_{{number}}' class="toggleOperation">{{{summary}}}</a>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
<div class='content' id='{{resourceName}}_{{nickname}}_{{httpMethod}}_{{number}}_content' style='display:none'>
|
<div class='content' id='{{resourceName}}_{{nickname}}_{{method}}_{{number}}_content' style='display:none'>
|
||||||
{{#if notes}}
|
{{#if notes}}
|
||||||
<h4>Implementation Notes</h4>
|
<h4>Implementation Notes</h4>
|
||||||
<p>{{{notes}}}</p>
|
<p>{{{notes}}}</p>
|
||||||
@@ -25,7 +25,7 @@
|
|||||||
<h4>Response Class</h4>
|
<h4>Response Class</h4>
|
||||||
<p><span class="model-signature" /></p>
|
<p><span class="model-signature" /></p>
|
||||||
<br/>
|
<br/>
|
||||||
<div class="content-type" />
|
<div class="response-content-type" />
|
||||||
{{/if}}
|
{{/if}}
|
||||||
<form accept-charset='UTF-8' class='sandbox'>
|
<form accept-charset='UTF-8' class='sandbox'>
|
||||||
<div style='margin:0;padding:0;display:inline'></div>
|
<div style='margin:0;padding:0;display:inline'></div>
|
||||||
|
|||||||
@@ -10,7 +10,7 @@
|
|||||||
{{else}}
|
{{else}}
|
||||||
<textarea class='body-textarea' name='{{name}}'></textarea>
|
<textarea class='body-textarea' name='{{name}}'></textarea>
|
||||||
<br />
|
<br />
|
||||||
<div class="content-type" />
|
<div class="parameter-content-type" />
|
||||||
{{/if}}
|
{{/if}}
|
||||||
{{/if}}
|
{{/if}}
|
||||||
{{else}}
|
{{else}}
|
||||||
@@ -27,4 +27,3 @@
|
|||||||
<td>
|
<td>
|
||||||
<span class="model-signature"></span>
|
<span class="model-signature"></span>
|
||||||
</td>
|
</td>
|
||||||
|
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
{{else}}
|
{{else}}
|
||||||
<textarea class='body-textarea' placeholder='(required)' name='{{name}}'></textarea>
|
<textarea class='body-textarea' placeholder='(required)' name='{{name}}'></textarea>
|
||||||
<br />
|
<br />
|
||||||
<div class="content-type" />
|
<div class="parameter-content-type" />
|
||||||
{{/if}}
|
{{/if}}
|
||||||
{{/if}}
|
{{/if}}
|
||||||
{{else}}
|
{{else}}
|
||||||
|
|||||||
Reference in New Issue
Block a user