Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
348f1e109b | ||
|
|
abc3600994 | ||
|
|
77882a0e3e | ||
|
|
0e98639f45 | ||
|
|
3347d7e9fd | ||
|
|
929f8b61f2 | ||
|
|
8158e9b25f | ||
|
|
a0db8582a1 | ||
|
|
1b662db2d2 | ||
|
|
cd4fa99cc4 | ||
|
|
bc93240199 | ||
|
|
999367589d | ||
|
|
8a9eedfdf3 | ||
|
|
046e534d03 | ||
|
|
73c89ba3f6 | ||
|
|
ff05f9113b | ||
|
|
6c1de0b560 | ||
|
|
4fb5b86db1 | ||
|
|
5f4eec1b8a | ||
|
|
f22efb66de |
@@ -16,9 +16,10 @@ You can use the swagger-ui code AS-IS! No need to build or recompile--just clon
|
||||
You can rebuild swagger-ui on your own to tweak it or just so you can say you did. To do so, follow these steps:
|
||||
|
||||
1. install [handlebars](http://handlebarsjs.com/)
|
||||
2. npm install
|
||||
3. npm run-script build
|
||||
4. You should see the distribution under the dist folder. Open ./dist/index.html to launch Swagger UI in a browser
|
||||
2. install java
|
||||
3. npm install
|
||||
4. npm run-script build
|
||||
5. You should see the distribution under the dist folder. Open ./dist/index.html to launch Swagger UI in a browser
|
||||
|
||||
### Use
|
||||
Once you open the Swagger UI, it will load the [Swagger Petstore](http://petstore.swagger.wordnik.com/api/api-docs) service and show its APIs. You can enter your own server url and click explore to view the API.
|
||||
@@ -41,13 +42,13 @@ To use swagger-ui you should take a look at the [source of swagger-ui html page]
|
||||
|
||||
```javascript
|
||||
window.swaggerUi = new SwaggerUi({
|
||||
discoveryUrl:"http://petstore.swagger.wordnik.com/api/api-docs",
|
||||
url:"http://petstore.swagger.wordnik.com/api/api-docs",
|
||||
dom_id:"swagger-ui-container"
|
||||
});
|
||||
|
||||
window.swaggerUi.load();
|
||||
```
|
||||
* *discoveryUrl* parameter should point to a resource listing url as per [Swagger Spec](https://github.com/wordnik/swagger-core/wiki)
|
||||
* *url* parameter should point to a resource listing url as per [Swagger Spec](https://github.com/wordnik/swagger-core/wiki)
|
||||
* *dom_id parameter* is the the id of a dom element inside which SwaggerUi will put the user interface for swagger
|
||||
* *booleanValues* SwaggerUI renders boolean data types as a dropdown. By default it provides a 'true' and 'false' string as the possible choices. You can use this parameter to change the values in dropdown to be something else, for example 0 and 1 by setting booleanValues to new Array(0, 1)
|
||||
* *docExpansion* controls how the API listing is displayed. It can be set to 'none' (default), 'list' (shows operations for each resource), or 'full' (fully expanded: shows operations and their details)
|
||||
|
||||
Vendored
+1
-2
@@ -3,7 +3,7 @@
|
||||
<head>
|
||||
<title>Swagger UI</title>
|
||||
<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/highlight.default.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>
|
||||
@@ -16,7 +16,6 @@
|
||||
<script src='lib/swagger.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 type="text/javascript">
|
||||
$(function () {
|
||||
window.swaggerUi = new SwaggerUi({
|
||||
|
||||
Vendored
+156
-75
@@ -1,10 +1,9 @@
|
||||
// Generated by CoffeeScript 1.4.0
|
||||
// Generated by CoffeeScript 1.6.3
|
||||
(function() {
|
||||
var ApiKeyAuthorization, SwaggerApi, SwaggerAuthorizations, SwaggerHttp, SwaggerModel, SwaggerModelProperty, SwaggerOperation, SwaggerRequest, SwaggerResource,
|
||||
var ApiKeyAuthorization, PasswordAuthorization, SwaggerApi, SwaggerAuthorizations, SwaggerHttp, SwaggerModel, SwaggerModelProperty, SwaggerOperation, SwaggerRequest, SwaggerResource,
|
||||
__bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };
|
||||
|
||||
SwaggerApi = (function() {
|
||||
|
||||
SwaggerApi.prototype.url = "http://api.wordnik.com/v4/resources.json";
|
||||
|
||||
SwaggerApi.prototype.debug = false;
|
||||
@@ -33,13 +32,11 @@
|
||||
if (options.url != null) {
|
||||
this.url = options.url;
|
||||
}
|
||||
this.supportedSubmitMethods = options.supportedSubmitMethods != null ? options.supportedSubmitMethods : ['get'];
|
||||
if (options.success != null) {
|
||||
this.success = options.success;
|
||||
}
|
||||
this.failure = options.failure != null ? options.failure : function() {};
|
||||
this.progress = options.progress != null ? options.progress : function() {};
|
||||
this.defaultHeaders = options.headers != null ? options.headers : {};
|
||||
if (options.success != null) {
|
||||
this.build();
|
||||
}
|
||||
@@ -57,64 +54,23 @@
|
||||
error: function(response) {
|
||||
if (_this.url.substring(0, 4) !== 'http') {
|
||||
return _this.fail('Please specify the protocol for ' + _this.url);
|
||||
} else if (error.status === 0) {
|
||||
} else if (response.status === 0) {
|
||||
return _this.fail('Can\'t read from server. It may not have the appropriate access-control-origin settings.');
|
||||
} else if (error.status === 404) {
|
||||
} else if (response.status === 404) {
|
||||
return _this.fail('Can\'t read swagger JSON from ' + _this.url);
|
||||
} else {
|
||||
return _this.fail(error.status + ' : ' + error.statusText + ' ' + _this.url);
|
||||
return _this.fail(response.status + ' : ' + response.statusText + ' ' + _this.url);
|
||||
}
|
||||
},
|
||||
response: function(rawResponse) {
|
||||
var api, isApi, newName, operation, res, resource, response, _i, _j, _k, _len, _len1, _len2, _ref, _ref1, _ref2;
|
||||
var response;
|
||||
response = JSON.parse(rawResponse.content.data);
|
||||
if (response.apiVersion != null) {
|
||||
_this.apiVersion = response.apiVersion;
|
||||
}
|
||||
_this.apis = {};
|
||||
_this.apisArray = [];
|
||||
_this.produces = response.produces;
|
||||
if (response.info != null) {
|
||||
_this.info = response.info;
|
||||
}
|
||||
isApi = false;
|
||||
_ref = response.apis;
|
||||
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
||||
api = _ref[_i];
|
||||
if (api.operations) {
|
||||
_ref1 = api.operations;
|
||||
for (_j = 0, _len1 = _ref1.length; _j < _len1; _j++) {
|
||||
operation = _ref1[_j];
|
||||
isApi = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (isApi) {
|
||||
newName = response.resourcePath.replace(/\//g, '');
|
||||
_this.resourcePath = response.resourcePath;
|
||||
res = new SwaggerResource(response, _this);
|
||||
_this.apis[newName] = res;
|
||||
_this.apisArray.push(res);
|
||||
_this.swaggerVersion = response.swaggerVersion;
|
||||
if (_this.swaggerVersion === "1.2") {
|
||||
return _this.buildFromSpec(response);
|
||||
} else {
|
||||
if (response.basePath) {
|
||||
_this.basePath = response.basePath;
|
||||
} else if (_this.url.indexOf('?') > 0) {
|
||||
_this.basePath = _this.url.substring(0, _this.url.lastIndexOf('?'));
|
||||
} else {
|
||||
_this.basePath = _this.url;
|
||||
}
|
||||
_ref2 = response.apis;
|
||||
for (_k = 0, _len2 = _ref2.length; _k < _len2; _k++) {
|
||||
resource = _ref2[_k];
|
||||
res = new SwaggerResource(resource, _this);
|
||||
_this.apis[res.name] = res;
|
||||
_this.apisArray.push(res);
|
||||
}
|
||||
return _this.buildFrom1_1Spec(response);
|
||||
}
|
||||
if (_this.success) {
|
||||
_this.success();
|
||||
}
|
||||
return _this;
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -129,6 +85,110 @@
|
||||
return this;
|
||||
};
|
||||
|
||||
SwaggerApi.prototype.buildFromSpec = function(response) {
|
||||
var api, isApi, newName, operation, res, resource, _i, _j, _k, _len, _len1, _len2, _ref, _ref1, _ref2;
|
||||
if (response.apiVersion != null) {
|
||||
this.apiVersion = response.apiVersion;
|
||||
}
|
||||
this.apis = {};
|
||||
this.apisArray = [];
|
||||
this.produces = response.produces;
|
||||
this.authSchemes = response.authorizations;
|
||||
if (response.info != null) {
|
||||
this.info = response.info;
|
||||
}
|
||||
isApi = false;
|
||||
_ref = response.apis;
|
||||
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
||||
api = _ref[_i];
|
||||
if (api.operations) {
|
||||
_ref1 = api.operations;
|
||||
for (_j = 0, _len1 = _ref1.length; _j < _len1; _j++) {
|
||||
operation = _ref1[_j];
|
||||
isApi = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (response.basePath) {
|
||||
this.basePath = response.basePath;
|
||||
} else if (this.url.indexOf('?') > 0) {
|
||||
this.basePath = this.url.substring(0, this.url.lastIndexOf('?'));
|
||||
} else {
|
||||
this.basePath = this.url;
|
||||
}
|
||||
if (isApi) {
|
||||
newName = response.resourcePath.replace(/\//g, '');
|
||||
this.resourcePath = response.resourcePath;
|
||||
res = new SwaggerResource(response, this);
|
||||
this.apis[newName] = res;
|
||||
this.apisArray.push(res);
|
||||
} else {
|
||||
_ref2 = response.apis;
|
||||
for (_k = 0, _len2 = _ref2.length; _k < _len2; _k++) {
|
||||
resource = _ref2[_k];
|
||||
res = new SwaggerResource(resource, this);
|
||||
this.apis[res.name] = res;
|
||||
this.apisArray.push(res);
|
||||
}
|
||||
}
|
||||
if (this.success) {
|
||||
this.success();
|
||||
}
|
||||
return this;
|
||||
};
|
||||
|
||||
SwaggerApi.prototype.buildFrom1_1Spec = function(response) {
|
||||
var api, isApi, newName, operation, res, resource, _i, _j, _k, _len, _len1, _len2, _ref, _ref1, _ref2;
|
||||
console.log("This API is using a deprecated version of Swagger! Please see http://github.com/wordnik/swagger-core/wiki for more info");
|
||||
if (response.apiVersion != null) {
|
||||
this.apiVersion = response.apiVersion;
|
||||
}
|
||||
this.apis = {};
|
||||
this.apisArray = [];
|
||||
this.produces = response.produces;
|
||||
if (response.info != null) {
|
||||
this.info = response.info;
|
||||
}
|
||||
isApi = false;
|
||||
_ref = response.apis;
|
||||
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
||||
api = _ref[_i];
|
||||
if (api.operations) {
|
||||
_ref1 = api.operations;
|
||||
for (_j = 0, _len1 = _ref1.length; _j < _len1; _j++) {
|
||||
operation = _ref1[_j];
|
||||
isApi = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (response.basePath) {
|
||||
this.basePath = response.basePath;
|
||||
} else if (this.url.indexOf('?') > 0) {
|
||||
this.basePath = this.url.substring(0, this.url.lastIndexOf('?'));
|
||||
} else {
|
||||
this.basePath = this.url;
|
||||
}
|
||||
if (isApi) {
|
||||
newName = response.resourcePath.replace(/\//g, '');
|
||||
this.resourcePath = response.resourcePath;
|
||||
res = new SwaggerResource(response, this);
|
||||
this.apis[newName] = res;
|
||||
this.apisArray.push(res);
|
||||
} else {
|
||||
_ref2 = response.apis;
|
||||
for (_k = 0, _len2 = _ref2.length; _k < _len2; _k++) {
|
||||
resource = _ref2[_k];
|
||||
res = new SwaggerResource(resource, this);
|
||||
this.apis[res.name] = res;
|
||||
this.apisArray.push(res);
|
||||
}
|
||||
}
|
||||
if (this.success) {
|
||||
this.success();
|
||||
}
|
||||
return this;
|
||||
};
|
||||
|
||||
SwaggerApi.prototype.selfReflect = function() {
|
||||
var resource, resource_name, _ref;
|
||||
if (this.apis == null) {
|
||||
@@ -161,7 +221,7 @@
|
||||
for (resource_name in _ref) {
|
||||
resource = _ref[resource_name];
|
||||
for (modelName in resource.models) {
|
||||
if (!(this.models[modelName] != null)) {
|
||||
if (this.models[modelName] == null) {
|
||||
this.models[modelName] = resource.models[modelName];
|
||||
this.modelsArray.push(resource.models[modelName]);
|
||||
}
|
||||
@@ -201,7 +261,6 @@
|
||||
})();
|
||||
|
||||
SwaggerResource = (function() {
|
||||
|
||||
SwaggerResource.prototype.api = null;
|
||||
|
||||
SwaggerResource.prototype.produces = null;
|
||||
@@ -242,7 +301,7 @@
|
||||
headers: {},
|
||||
on: {
|
||||
error: function(response) {
|
||||
return _this.api.fail("Unable to read api '" + _this.name + "' from path " + _this.url + " (server returned " + error.statusText + ")");
|
||||
return _this.api.fail("Unable to read api '" + _this.name + "' from path " + _this.url + " (server returned " + response.statusText + ")");
|
||||
},
|
||||
response: function(rawResponse) {
|
||||
var response;
|
||||
@@ -290,7 +349,7 @@
|
||||
var model, modelName, swaggerModel, _i, _len, _ref, _results;
|
||||
if (models != null) {
|
||||
for (modelName in models) {
|
||||
if (!(this.models[modelName] != null)) {
|
||||
if (this.models[modelName] == null) {
|
||||
swaggerModel = new SwaggerModel(modelName, models[modelName]);
|
||||
this.modelsArray.push(swaggerModel);
|
||||
this.models[modelName] = swaggerModel;
|
||||
@@ -383,20 +442,20 @@
|
||||
})();
|
||||
|
||||
SwaggerModel = (function() {
|
||||
|
||||
function SwaggerModel(modelName, obj) {
|
||||
var propertyName, value;
|
||||
var prop, propertyName, value;
|
||||
this.name = obj.id != null ? obj.id : modelName;
|
||||
this.properties = [];
|
||||
for (propertyName in obj.properties) {
|
||||
if (obj["enum"] != null) {
|
||||
for (value in obj["enum"]) {
|
||||
if (propertyName === value) {
|
||||
if (obj.required != null) {
|
||||
for (value in obj.required) {
|
||||
if (propertyName === obj.required[value]) {
|
||||
obj.properties[propertyName].required = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
this.properties.push(new SwaggerModelProperty(propertyName, obj.properties[propertyName]));
|
||||
prop = new SwaggerModelProperty(propertyName, obj.properties[propertyName]);
|
||||
this.properties.push(prop);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -456,6 +515,7 @@
|
||||
prop = _ref[_i];
|
||||
result[prop.name] = prop.getSampleValue(modelsToIgnore);
|
||||
}
|
||||
modelsToIgnore.pop(this.name);
|
||||
return result;
|
||||
};
|
||||
|
||||
@@ -464,14 +524,12 @@
|
||||
})();
|
||||
|
||||
SwaggerModelProperty = (function() {
|
||||
|
||||
function SwaggerModelProperty(name, obj) {
|
||||
this.name = name;
|
||||
this.dataType = obj.type;
|
||||
this.dataType = obj.type || obj.dataType || obj["$ref"];
|
||||
this.isCollection = this.dataType && (this.dataType.toLowerCase() === 'array' || this.dataType.toLowerCase() === 'list' || this.dataType.toLowerCase() === 'set');
|
||||
this.descr = obj.description;
|
||||
this.required = obj.required;
|
||||
console.log(this);
|
||||
if (obj.items != null) {
|
||||
if (obj.items.type != null) {
|
||||
this.refDataType = obj.items.type;
|
||||
@@ -488,6 +546,13 @@
|
||||
this.valuesString = "'" + this.values.join("' or '") + "'";
|
||||
}
|
||||
}
|
||||
if (obj["enum"] != null) {
|
||||
this.valueType = "string";
|
||||
this.values = obj["enum"];
|
||||
if (this.values != null) {
|
||||
this.valueString = "'" + this.values.join("' or '") + "'";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
SwaggerModelProperty.prototype.getSampleValue = function(modelsToIgnore) {
|
||||
@@ -530,7 +595,6 @@
|
||||
})();
|
||||
|
||||
SwaggerOperation = (function() {
|
||||
|
||||
function SwaggerOperation(nickname, path, method, parameters, summary, notes, type, responseMessages, resource, consumes, produces) {
|
||||
var parameter, v, _i, _j, _k, _len, _len1, _len2, _ref, _ref1, _ref2, _ref3,
|
||||
_this = this;
|
||||
@@ -546,7 +610,6 @@
|
||||
this.consumes = consumes;
|
||||
this.produces = produces;
|
||||
this["do"] = __bind(this["do"], this);
|
||||
|
||||
if (this.nickname == null) {
|
||||
this.resource.api.fail("SwaggerOperations must have a nickname.");
|
||||
}
|
||||
@@ -560,7 +623,6 @@
|
||||
this.method = this.method.toLowerCase();
|
||||
this.isGetMethod = this.method === "get";
|
||||
this.resourceName = this.resource.name;
|
||||
console.log("model type: " + type);
|
||||
if (((_ref = this.type) != null ? _ref.toLowerCase() : void 0) === 'void') {
|
||||
this.type = void 0;
|
||||
}
|
||||
@@ -576,7 +638,7 @@
|
||||
type = parameter.type || parameter.dataType;
|
||||
if (type.toLowerCase() === 'boolean') {
|
||||
parameter.allowableValues = {};
|
||||
parameter.allowableValues.values = this.resource.api.booleanValues;
|
||||
parameter.allowableValues.values = ["true", "false"];
|
||||
}
|
||||
parameter.signature = this.getSignature(type, this.resource.models);
|
||||
parameter.sampleJSON = this.getSampleJSON(type, this.resource.models);
|
||||
@@ -847,7 +909,6 @@
|
||||
})();
|
||||
|
||||
SwaggerRequest = (function() {
|
||||
|
||||
function SwaggerRequest(type, url, params, opts, successCallback, errorCallback, operation, execution) {
|
||||
var body, e, fields, headers, key, myHeaders, name, obj, param, parent, possibleParams, requestContentType, responseContentType, urlEncoded, value, values,
|
||||
_this = this;
|
||||
@@ -1038,7 +1099,6 @@
|
||||
})();
|
||||
|
||||
SwaggerHttp = (function() {
|
||||
|
||||
SwaggerHttp.prototype.Shred = null;
|
||||
|
||||
SwaggerHttp.prototype.shred = null;
|
||||
@@ -1083,7 +1143,6 @@
|
||||
})();
|
||||
|
||||
SwaggerAuthorizations = (function() {
|
||||
|
||||
SwaggerAuthorizations.prototype.authz = null;
|
||||
|
||||
function SwaggerAuthorizations() {
|
||||
@@ -1111,7 +1170,6 @@
|
||||
})();
|
||||
|
||||
ApiKeyAuthorization = (function() {
|
||||
|
||||
ApiKeyAuthorization.prototype.type = null;
|
||||
|
||||
ApiKeyAuthorization.prototype.name = null;
|
||||
@@ -1141,6 +1199,27 @@
|
||||
|
||||
})();
|
||||
|
||||
PasswordAuthorization = (function() {
|
||||
PasswordAuthorization.prototype.name = null;
|
||||
|
||||
PasswordAuthorization.prototype.username = null;
|
||||
|
||||
PasswordAuthorization.prototype.password = null;
|
||||
|
||||
function PasswordAuthorization(name, username, password) {
|
||||
this.name = name;
|
||||
this.username = username;
|
||||
this.password = password;
|
||||
}
|
||||
|
||||
PasswordAuthorization.prototype.apply = function(obj) {
|
||||
return obj.headers["Authorization"] = "Basic " + btoa(this.username + ":" + this.password);
|
||||
};
|
||||
|
||||
return PasswordAuthorization;
|
||||
|
||||
})();
|
||||
|
||||
this.SwaggerApi = SwaggerApi;
|
||||
|
||||
this.SwaggerResource = SwaggerResource;
|
||||
@@ -1153,6 +1232,8 @@
|
||||
|
||||
this.ApiKeyAuthorization = ApiKeyAuthorization;
|
||||
|
||||
this.PasswordAuthorization = PasswordAuthorization;
|
||||
|
||||
this.authorizations = new SwaggerAuthorizations();
|
||||
|
||||
}).call(this);
|
||||
|
||||
Vendored
+149
-87
@@ -598,43 +598,64 @@ helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
|
||||
function program1(depth0,data) {
|
||||
|
||||
|
||||
return "\n ";
|
||||
return " multiple='multiple'";
|
||||
}
|
||||
|
||||
function program3(depth0,data) {
|
||||
|
||||
|
||||
return "\n ";
|
||||
}
|
||||
|
||||
function program5(depth0,data) {
|
||||
|
||||
var buffer = "", stack1;
|
||||
buffer += "\n ";
|
||||
stack1 = helpers['if'].call(depth0, depth0.defaultValue, {hash:{},inverse:self.program(6, program6, data),fn:self.program(4, program4, data),data:data});
|
||||
stack1 = helpers['if'].call(depth0, depth0.defaultValue, {hash:{},inverse:self.program(8, program8, data),fn:self.program(6, program6, data),data:data});
|
||||
if(stack1 || stack1 === 0) { buffer += stack1; }
|
||||
buffer += "\n ";
|
||||
return buffer;
|
||||
}
|
||||
function program4(depth0,data) {
|
||||
function program6(depth0,data) {
|
||||
|
||||
|
||||
return "\n ";
|
||||
}
|
||||
|
||||
function program6(depth0,data) {
|
||||
|
||||
|
||||
return "\n <option selected=\"\" value=''></option>\n ";
|
||||
}
|
||||
|
||||
function program8(depth0,data) {
|
||||
|
||||
var buffer = "", stack1;
|
||||
buffer += "\n ";
|
||||
stack1 = helpers['if'].call(depth0, depth0.isDefault, {hash:{},inverse:self.program(11, program11, data),fn:self.program(9, program9, data),data:data});
|
||||
buffer += "\n ";
|
||||
stack1 = helpers['if'].call(depth0, depth0.allowMultiple, {hash:{},inverse:self.program(11, program11, data),fn:self.program(9, program9, data),data:data});
|
||||
if(stack1 || stack1 === 0) { buffer += stack1; }
|
||||
buffer += "\n ";
|
||||
buffer += "\n ";
|
||||
return buffer;
|
||||
}
|
||||
function program9(depth0,data) {
|
||||
|
||||
|
||||
return "\n ";
|
||||
}
|
||||
|
||||
function program11(depth0,data) {
|
||||
|
||||
|
||||
return "\n <option selected=\"\" value=''></option>\n ";
|
||||
}
|
||||
|
||||
function program13(depth0,data) {
|
||||
|
||||
var buffer = "", stack1;
|
||||
buffer += "\n <option value='";
|
||||
buffer += "\n ";
|
||||
stack1 = helpers['if'].call(depth0, depth0.isDefault, {hash:{},inverse:self.program(16, program16, data),fn:self.program(14, program14, data),data:data});
|
||||
if(stack1 || stack1 === 0) { buffer += stack1; }
|
||||
buffer += "\n ";
|
||||
return buffer;
|
||||
}
|
||||
function program14(depth0,data) {
|
||||
|
||||
var buffer = "", stack1;
|
||||
buffer += "\n <option selected=\"\" value='";
|
||||
if (stack1 = helpers.value) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
|
||||
else { stack1 = depth0.value; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
|
||||
buffer += escapeExpression(stack1)
|
||||
@@ -646,7 +667,7 @@ function program9(depth0,data) {
|
||||
return buffer;
|
||||
}
|
||||
|
||||
function program11(depth0,data) {
|
||||
function program16(depth0,data) {
|
||||
|
||||
var buffer = "", stack1;
|
||||
buffer += "\n <option value='";
|
||||
@@ -665,15 +686,18 @@ function program11(depth0,data) {
|
||||
if (stack1 = helpers.name) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
|
||||
else { stack1 = depth0.name; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
|
||||
buffer += escapeExpression(stack1)
|
||||
+ "</td>\n<td>\n <select class='parameter' name='";
|
||||
+ "</td>\n<td>\n <select ";
|
||||
stack1 = helpers['if'].call(depth0, depth0.allowMultiple, {hash:{},inverse:self.noop,fn:self.program(1, program1, data),data:data});
|
||||
if(stack1 || stack1 === 0) { buffer += stack1; }
|
||||
buffer += " class='parameter' name='";
|
||||
if (stack1 = helpers.name) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
|
||||
else { stack1 = depth0.name; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
|
||||
buffer += escapeExpression(stack1)
|
||||
+ "'>\n ";
|
||||
stack1 = helpers['if'].call(depth0, depth0.required, {hash:{},inverse:self.program(3, program3, data),fn:self.program(1, program1, data),data:data});
|
||||
stack1 = helpers['if'].call(depth0, depth0.required, {hash:{},inverse:self.program(5, program5, data),fn:self.program(3, program3, data),data:data});
|
||||
if(stack1 || stack1 === 0) { buffer += stack1; }
|
||||
buffer += "\n ";
|
||||
stack2 = helpers.each.call(depth0, ((stack1 = depth0.allowableValues),stack1 == null || stack1 === false ? stack1 : stack1.descriptiveValues), {hash:{},inverse:self.noop,fn:self.program(8, program8, data),data:data});
|
||||
stack2 = helpers.each.call(depth0, ((stack1 = depth0.allowableValues),stack1 == null || stack1 === false ? stack1 : stack1.descriptiveValues), {hash:{},inverse:self.noop,fn:self.program(13, program13, data),data:data});
|
||||
if(stack2 || stack2 === 0) { buffer += stack2; }
|
||||
buffer += "\n </select>\n</td>\n<td>";
|
||||
if (stack2 = helpers.description) { stack2 = stack2.call(depth0, {hash:{},data:data}); }
|
||||
@@ -683,7 +707,7 @@ function program11(depth0,data) {
|
||||
if (stack2 = helpers.paramType) { stack2 = stack2.call(depth0, {hash:{},data:data}); }
|
||||
else { stack2 = depth0.paramType; stack2 = typeof stack2 === functionType ? stack2.apply(depth0) : stack2; }
|
||||
if(stack2 || stack2 === 0) { buffer += stack2; }
|
||||
buffer += "</td>\n<td><span class=\"model-signature\"></span></td>\n";
|
||||
buffer += "</td>\n<td><span class=\"model-signature\"></span></td>";
|
||||
return buffer;
|
||||
});
|
||||
})();
|
||||
@@ -1009,8 +1033,13 @@ function program4(depth0,data) {
|
||||
templates['resource'] = template(function (Handlebars,depth0,helpers,partials,data) {
|
||||
this.compilerInfo = [4,'>= 1.0.0'];
|
||||
helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
|
||||
var buffer = "", stack1, functionType="function", escapeExpression=this.escapeExpression;
|
||||
var buffer = "", stack1, options, functionType="function", escapeExpression=this.escapeExpression, self=this, blockHelperMissing=helpers.blockHelperMissing;
|
||||
|
||||
function program1(depth0,data) {
|
||||
|
||||
|
||||
return " : ";
|
||||
}
|
||||
|
||||
buffer += "<div class='heading'>\n <h2>\n <a href='#!/";
|
||||
if (stack1 = helpers.name) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
|
||||
@@ -1024,7 +1053,16 @@ helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
|
||||
if (stack1 = helpers.name) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
|
||||
else { stack1 = depth0.name; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
|
||||
buffer += escapeExpression(stack1)
|
||||
+ "</a>\n </h2>\n <ul class='options'>\n <li>\n <a href='#!/";
|
||||
+ "</a> ";
|
||||
options = {hash:{},inverse:self.noop,fn:self.program(1, program1, data),data:data};
|
||||
if (stack1 = helpers.description) { stack1 = stack1.call(depth0, options); }
|
||||
else { stack1 = depth0.description; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
|
||||
if (!helpers.description) { stack1 = blockHelperMissing.call(depth0, stack1, options); }
|
||||
if(stack1 || stack1 === 0) { buffer += stack1; }
|
||||
if (stack1 = helpers.description) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
|
||||
else { stack1 = depth0.description; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
|
||||
if(stack1 || stack1 === 0) { buffer += stack1; }
|
||||
buffer += "\n </h2>\n <ul class='options'>\n <li>\n <a href='#!/";
|
||||
if (stack1 = helpers.name) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
|
||||
else { stack1 = depth0.name; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
|
||||
buffer += escapeExpression(stack1)
|
||||
@@ -1144,18 +1182,18 @@ helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
|
||||
|
||||
|
||||
|
||||
// Generated by CoffeeScript 1.4.0
|
||||
// Generated by CoffeeScript 1.6.3
|
||||
(function() {
|
||||
var ContentTypeView, HeaderView, MainView, OperationView, ParameterContentTypeView, ParameterView, ResourceView, ResponseContentTypeView, SignatureView, StatusCodeView, SwaggerUi,
|
||||
var ContentTypeView, HeaderView, MainView, OperationView, ParameterContentTypeView, ParameterView, ResourceView, ResponseContentTypeView, SignatureView, StatusCodeView, SwaggerUi, _ref, _ref1, _ref10, _ref2, _ref3, _ref4, _ref5, _ref6, _ref7, _ref8, _ref9,
|
||||
__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; };
|
||||
|
||||
SwaggerUi = (function(_super) {
|
||||
|
||||
__extends(SwaggerUi, _super);
|
||||
|
||||
function SwaggerUi() {
|
||||
return SwaggerUi.__super__.constructor.apply(this, arguments);
|
||||
_ref = SwaggerUi.__super__.constructor.apply(this, arguments);
|
||||
return _ref;
|
||||
}
|
||||
|
||||
SwaggerUi.prototype.dom_id = "swagger_ui";
|
||||
@@ -1177,7 +1215,7 @@ helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
|
||||
this.dom_id = options.dom_id;
|
||||
delete options.dom_id;
|
||||
}
|
||||
if (!($('#' + this.dom_id) != null)) {
|
||||
if ($('#' + this.dom_id) == null) {
|
||||
$('body').append('<div id="' + this.dom_id + '"></div>');
|
||||
}
|
||||
this.options = options;
|
||||
@@ -1204,9 +1242,9 @@ helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
|
||||
};
|
||||
|
||||
SwaggerUi.prototype.load = function() {
|
||||
var url, _ref;
|
||||
if ((_ref = this.mainView) != null) {
|
||||
_ref.clear();
|
||||
var url, _ref1;
|
||||
if ((_ref1 = this.mainView) != null) {
|
||||
_ref1.clear();
|
||||
}
|
||||
url = this.options.url;
|
||||
if (url.indexOf("http") !== 0) {
|
||||
@@ -1284,11 +1322,11 @@ helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
|
||||
window.SwaggerUi = SwaggerUi;
|
||||
|
||||
HeaderView = (function(_super) {
|
||||
|
||||
__extends(HeaderView, _super);
|
||||
|
||||
function HeaderView() {
|
||||
return HeaderView.__super__.constructor.apply(this, arguments);
|
||||
_ref1 = HeaderView.__super__.constructor.apply(this, arguments);
|
||||
return _ref1;
|
||||
}
|
||||
|
||||
HeaderView.prototype.events = {
|
||||
@@ -1346,21 +1384,21 @@ helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
|
||||
})(Backbone.View);
|
||||
|
||||
MainView = (function(_super) {
|
||||
|
||||
__extends(MainView, _super);
|
||||
|
||||
function MainView() {
|
||||
return MainView.__super__.constructor.apply(this, arguments);
|
||||
_ref2 = MainView.__super__.constructor.apply(this, arguments);
|
||||
return _ref2;
|
||||
}
|
||||
|
||||
MainView.prototype.initialize = function() {};
|
||||
|
||||
MainView.prototype.render = function() {
|
||||
var resource, _i, _len, _ref;
|
||||
var resource, _i, _len, _ref3;
|
||||
$(this.el).html(Handlebars.templates.main(this.model));
|
||||
_ref = this.model.apisArray;
|
||||
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
||||
resource = _ref[_i];
|
||||
_ref3 = this.model.apisArray;
|
||||
for (_i = 0, _len = _ref3.length; _i < _len; _i++) {
|
||||
resource = _ref3[_i];
|
||||
this.addResource(resource);
|
||||
}
|
||||
return this;
|
||||
@@ -1386,22 +1424,23 @@ helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
|
||||
})(Backbone.View);
|
||||
|
||||
ResourceView = (function(_super) {
|
||||
|
||||
__extends(ResourceView, _super);
|
||||
|
||||
function ResourceView() {
|
||||
return ResourceView.__super__.constructor.apply(this, arguments);
|
||||
_ref3 = ResourceView.__super__.constructor.apply(this, arguments);
|
||||
return _ref3;
|
||||
}
|
||||
|
||||
ResourceView.prototype.initialize = function() {};
|
||||
|
||||
ResourceView.prototype.render = function() {
|
||||
var operation, _i, _len, _ref;
|
||||
var operation, _i, _len, _ref4;
|
||||
console.log(this.model.description);
|
||||
$(this.el).html(Handlebars.templates.resource(this.model));
|
||||
this.number = 0;
|
||||
_ref = this.model.operationsArray;
|
||||
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
||||
operation = _ref[_i];
|
||||
_ref4 = this.model.operationsArray;
|
||||
for (_i = 0, _len = _ref4.length; _i < _len; _i++) {
|
||||
operation = _ref4[_i];
|
||||
this.addOperation(operation);
|
||||
}
|
||||
return this;
|
||||
@@ -1424,11 +1463,11 @@ helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
|
||||
})(Backbone.View);
|
||||
|
||||
OperationView = (function(_super) {
|
||||
|
||||
__extends(OperationView, _super);
|
||||
|
||||
function OperationView() {
|
||||
return OperationView.__super__.constructor.apply(this, arguments);
|
||||
_ref4 = OperationView.__super__.constructor.apply(this, arguments);
|
||||
return _ref4;
|
||||
}
|
||||
|
||||
OperationView.prototype.events = {
|
||||
@@ -1441,7 +1480,7 @@ helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
|
||||
OperationView.prototype.initialize = function() {};
|
||||
|
||||
OperationView.prototype.render = function() {
|
||||
var contentTypeModel, isMethodSubmissionSupported, param, responseContentTypeView, responseSignatureView, signatureModel, statusCode, type, _i, _j, _k, _len, _len1, _len2, _ref, _ref1, _ref2;
|
||||
var contentTypeModel, isMethodSubmissionSupported, param, responseContentTypeView, responseSignatureView, signatureModel, statusCode, type, _i, _j, _k, _len, _len1, _len2, _ref5, _ref6, _ref7;
|
||||
isMethodSubmissionSupported = true;
|
||||
if (!isMethodSubmissionSupported) {
|
||||
this.model.isReadOnly = true;
|
||||
@@ -1466,9 +1505,9 @@ helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
|
||||
};
|
||||
contentTypeModel.consumes = this.model.consumes;
|
||||
contentTypeModel.produces = this.model.produces;
|
||||
_ref = this.model.parameters;
|
||||
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
||||
param = _ref[_i];
|
||||
_ref5 = this.model.parameters;
|
||||
for (_i = 0, _len = _ref5.length; _i < _len; _i++) {
|
||||
param = _ref5[_i];
|
||||
type = param.type || param.dataType;
|
||||
if (type.toLowerCase() === 'file') {
|
||||
if (!contentTypeModel.consumes) {
|
||||
@@ -1481,14 +1520,14 @@ helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
|
||||
model: contentTypeModel
|
||||
});
|
||||
$('.response-content-type', $(this.el)).append(responseContentTypeView.render().el);
|
||||
_ref1 = this.model.parameters;
|
||||
for (_j = 0, _len1 = _ref1.length; _j < _len1; _j++) {
|
||||
param = _ref1[_j];
|
||||
_ref6 = this.model.parameters;
|
||||
for (_j = 0, _len1 = _ref6.length; _j < _len1; _j++) {
|
||||
param = _ref6[_j];
|
||||
this.addParameter(param, contentTypeModel.consumes);
|
||||
}
|
||||
_ref2 = this.model.responseMessages;
|
||||
for (_k = 0, _len2 = _ref2.length; _k < _len2; _k++) {
|
||||
statusCode = _ref2[_k];
|
||||
_ref7 = this.model.responseMessages;
|
||||
for (_k = 0, _len2 = _ref7.length; _k < _len2; _k++) {
|
||||
statusCode = _ref7[_k];
|
||||
this.addStatusCode(statusCode);
|
||||
}
|
||||
return this;
|
||||
@@ -1515,7 +1554,7 @@ helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
|
||||
};
|
||||
|
||||
OperationView.prototype.submitOperation = function(e) {
|
||||
var error_free, form, map, o, opts, _i, _j, _k, _len, _len1, _len2, _ref, _ref1, _ref2;
|
||||
var error_free, form, map, o, opts, val, _i, _j, _k, _len, _len1, _len2, _ref5, _ref6, _ref7;
|
||||
if (e != null) {
|
||||
e.preventDefault();
|
||||
}
|
||||
@@ -1539,29 +1578,31 @@ helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
|
||||
opts = {
|
||||
parent: this
|
||||
};
|
||||
_ref = form.find("input");
|
||||
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
||||
o = _ref[_i];
|
||||
if ((o.value != null) && jQuery.trim(o.value).length > 0) {
|
||||
map[o.name] = encodeURI(o.value);
|
||||
}
|
||||
}
|
||||
_ref1 = form.find("textarea");
|
||||
for (_j = 0, _len1 = _ref1.length; _j < _len1; _j++) {
|
||||
o = _ref1[_j];
|
||||
if ((o.value != null) && jQuery.trim(o.value).length > 0) {
|
||||
map["body"] = o.value;
|
||||
}
|
||||
}
|
||||
_ref2 = form.find("select");
|
||||
for (_k = 0, _len2 = _ref2.length; _k < _len2; _k++) {
|
||||
o = _ref2[_k];
|
||||
_ref5 = form.find("input");
|
||||
for (_i = 0, _len = _ref5.length; _i < _len; _i++) {
|
||||
o = _ref5[_i];
|
||||
if ((o.value != null) && jQuery.trim(o.value).length > 0) {
|
||||
map[o.name] = o.value;
|
||||
}
|
||||
}
|
||||
_ref6 = form.find("textarea");
|
||||
for (_j = 0, _len1 = _ref6.length; _j < _len1; _j++) {
|
||||
o = _ref6[_j];
|
||||
if ((o.value != null) && jQuery.trim(o.value).length > 0) {
|
||||
map["body"] = o.value;
|
||||
}
|
||||
}
|
||||
_ref7 = form.find("select");
|
||||
for (_k = 0, _len2 = _ref7.length; _k < _len2; _k++) {
|
||||
o = _ref7[_k];
|
||||
val = this.getSelectedValue(o);
|
||||
if ((val != null) && jQuery.trim(val).length > 0) {
|
||||
map[o.name] = val;
|
||||
}
|
||||
}
|
||||
opts.responseContentType = $("div select[name=responseContentType]", $(this.el)).val();
|
||||
opts.requestContentType = $("div select[name=parameterContentType]", $(this.el)).val();
|
||||
$(".response_throbber", $(this.el)).show();
|
||||
return this.model["do"](map, opts, this.showCompleteStatus, this.showErrorStatus, this);
|
||||
}
|
||||
};
|
||||
@@ -1570,6 +1611,27 @@ helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
|
||||
return parent.showCompleteStatus(response);
|
||||
};
|
||||
|
||||
OperationView.prototype.getSelectedValue = function(select) {
|
||||
var opt, options, _i, _len, _ref5;
|
||||
if (!select.multiple) {
|
||||
return select.value;
|
||||
} else {
|
||||
options = [];
|
||||
_ref5 = select.options;
|
||||
for (_i = 0, _len = _ref5.length; _i < _len; _i++) {
|
||||
opt = _ref5[_i];
|
||||
if (opt.selected) {
|
||||
options.push(opt.value);
|
||||
}
|
||||
}
|
||||
if (options.length > 0) {
|
||||
return options.join(",");
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
OperationView.prototype.hideResponse = function(e) {
|
||||
if (e != null) {
|
||||
e.preventDefault();
|
||||
@@ -1645,9 +1707,9 @@ helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
|
||||
padding = '';
|
||||
indent += transitions[fromTo];
|
||||
padding = ((function() {
|
||||
var _j, _ref, _results;
|
||||
var _j, _ref5, _results;
|
||||
_results = [];
|
||||
for (j = _j = 0, _ref = indent; 0 <= _ref ? _j < _ref : _j > _ref; j = 0 <= _ref ? ++_j : --_j) {
|
||||
for (j = _j = 0, _ref5 = indent; 0 <= _ref5 ? _j < _ref5 : _j > _ref5; j = 0 <= _ref5 ? ++_j : --_j) {
|
||||
_results.push(' ');
|
||||
}
|
||||
return _results;
|
||||
@@ -1673,7 +1735,7 @@ helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
|
||||
if (content === void 0) {
|
||||
code = $('<code />').text("no content");
|
||||
pre = $('<pre class="json" />').append(code);
|
||||
} else if (contentType.indexOf("application/json") === 0) {
|
||||
} else if (contentType.indexOf("application/json") === 0 || contentType.indexOf("application/hal+json") === 0) {
|
||||
code = $('<code />').text(JSON.stringify(JSON.parse(content), null, 2));
|
||||
pre = $('<pre class="json" />').append(code);
|
||||
} else if (contentType.indexOf("application/xml") === 0) {
|
||||
@@ -1712,11 +1774,11 @@ helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
|
||||
})(Backbone.View);
|
||||
|
||||
StatusCodeView = (function(_super) {
|
||||
|
||||
__extends(StatusCodeView, _super);
|
||||
|
||||
function StatusCodeView() {
|
||||
return StatusCodeView.__super__.constructor.apply(this, arguments);
|
||||
_ref5 = StatusCodeView.__super__.constructor.apply(this, arguments);
|
||||
return _ref5;
|
||||
}
|
||||
|
||||
StatusCodeView.prototype.initialize = function() {};
|
||||
@@ -1737,11 +1799,11 @@ helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
|
||||
})(Backbone.View);
|
||||
|
||||
ParameterView = (function(_super) {
|
||||
|
||||
__extends(ParameterView, _super);
|
||||
|
||||
function ParameterView() {
|
||||
return ParameterView.__super__.constructor.apply(this, arguments);
|
||||
_ref6 = ParameterView.__super__.constructor.apply(this, arguments);
|
||||
return _ref6;
|
||||
}
|
||||
|
||||
ParameterView.prototype.initialize = function() {};
|
||||
@@ -1818,11 +1880,11 @@ helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
|
||||
})(Backbone.View);
|
||||
|
||||
SignatureView = (function(_super) {
|
||||
|
||||
__extends(SignatureView, _super);
|
||||
|
||||
function SignatureView() {
|
||||
return SignatureView.__super__.constructor.apply(this, arguments);
|
||||
_ref7 = SignatureView.__super__.constructor.apply(this, arguments);
|
||||
return _ref7;
|
||||
}
|
||||
|
||||
SignatureView.prototype.events = {
|
||||
@@ -1887,11 +1949,11 @@ helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
|
||||
})(Backbone.View);
|
||||
|
||||
ContentTypeView = (function(_super) {
|
||||
|
||||
__extends(ContentTypeView, _super);
|
||||
|
||||
function ContentTypeView() {
|
||||
return ContentTypeView.__super__.constructor.apply(this, arguments);
|
||||
_ref8 = ContentTypeView.__super__.constructor.apply(this, arguments);
|
||||
return _ref8;
|
||||
}
|
||||
|
||||
ContentTypeView.prototype.initialize = function() {};
|
||||
@@ -1913,11 +1975,11 @@ helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
|
||||
})(Backbone.View);
|
||||
|
||||
ResponseContentTypeView = (function(_super) {
|
||||
|
||||
__extends(ResponseContentTypeView, _super);
|
||||
|
||||
function ResponseContentTypeView() {
|
||||
return ResponseContentTypeView.__super__.constructor.apply(this, arguments);
|
||||
_ref9 = ResponseContentTypeView.__super__.constructor.apply(this, arguments);
|
||||
return _ref9;
|
||||
}
|
||||
|
||||
ResponseContentTypeView.prototype.initialize = function() {};
|
||||
@@ -1939,11 +2001,11 @@ helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
|
||||
})(Backbone.View);
|
||||
|
||||
ParameterContentTypeView = (function(_super) {
|
||||
|
||||
__extends(ParameterContentTypeView, _super);
|
||||
|
||||
function ParameterContentTypeView() {
|
||||
return ParameterContentTypeView.__super__.constructor.apply(this, arguments);
|
||||
_ref10 = ParameterContentTypeView.__super__.constructor.apply(this, arguments);
|
||||
return _ref10;
|
||||
}
|
||||
|
||||
ParameterContentTypeView.prototype.initialize = function() {};
|
||||
|
||||
Vendored
+1
-1
File diff suppressed because one or more lines are too long
+156
-75
@@ -1,10 +1,9 @@
|
||||
// Generated by CoffeeScript 1.4.0
|
||||
// Generated by CoffeeScript 1.6.3
|
||||
(function() {
|
||||
var ApiKeyAuthorization, SwaggerApi, SwaggerAuthorizations, SwaggerHttp, SwaggerModel, SwaggerModelProperty, SwaggerOperation, SwaggerRequest, SwaggerResource,
|
||||
var ApiKeyAuthorization, PasswordAuthorization, SwaggerApi, SwaggerAuthorizations, SwaggerHttp, SwaggerModel, SwaggerModelProperty, SwaggerOperation, SwaggerRequest, SwaggerResource,
|
||||
__bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };
|
||||
|
||||
SwaggerApi = (function() {
|
||||
|
||||
SwaggerApi.prototype.url = "http://api.wordnik.com/v4/resources.json";
|
||||
|
||||
SwaggerApi.prototype.debug = false;
|
||||
@@ -33,13 +32,11 @@
|
||||
if (options.url != null) {
|
||||
this.url = options.url;
|
||||
}
|
||||
this.supportedSubmitMethods = options.supportedSubmitMethods != null ? options.supportedSubmitMethods : ['get'];
|
||||
if (options.success != null) {
|
||||
this.success = options.success;
|
||||
}
|
||||
this.failure = options.failure != null ? options.failure : function() {};
|
||||
this.progress = options.progress != null ? options.progress : function() {};
|
||||
this.defaultHeaders = options.headers != null ? options.headers : {};
|
||||
if (options.success != null) {
|
||||
this.build();
|
||||
}
|
||||
@@ -57,64 +54,23 @@
|
||||
error: function(response) {
|
||||
if (_this.url.substring(0, 4) !== 'http') {
|
||||
return _this.fail('Please specify the protocol for ' + _this.url);
|
||||
} else if (error.status === 0) {
|
||||
} else if (response.status === 0) {
|
||||
return _this.fail('Can\'t read from server. It may not have the appropriate access-control-origin settings.');
|
||||
} else if (error.status === 404) {
|
||||
} else if (response.status === 404) {
|
||||
return _this.fail('Can\'t read swagger JSON from ' + _this.url);
|
||||
} else {
|
||||
return _this.fail(error.status + ' : ' + error.statusText + ' ' + _this.url);
|
||||
return _this.fail(response.status + ' : ' + response.statusText + ' ' + _this.url);
|
||||
}
|
||||
},
|
||||
response: function(rawResponse) {
|
||||
var api, isApi, newName, operation, res, resource, response, _i, _j, _k, _len, _len1, _len2, _ref, _ref1, _ref2;
|
||||
var response;
|
||||
response = JSON.parse(rawResponse.content.data);
|
||||
if (response.apiVersion != null) {
|
||||
_this.apiVersion = response.apiVersion;
|
||||
}
|
||||
_this.apis = {};
|
||||
_this.apisArray = [];
|
||||
_this.produces = response.produces;
|
||||
if (response.info != null) {
|
||||
_this.info = response.info;
|
||||
}
|
||||
isApi = false;
|
||||
_ref = response.apis;
|
||||
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
||||
api = _ref[_i];
|
||||
if (api.operations) {
|
||||
_ref1 = api.operations;
|
||||
for (_j = 0, _len1 = _ref1.length; _j < _len1; _j++) {
|
||||
operation = _ref1[_j];
|
||||
isApi = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (isApi) {
|
||||
newName = response.resourcePath.replace(/\//g, '');
|
||||
_this.resourcePath = response.resourcePath;
|
||||
res = new SwaggerResource(response, _this);
|
||||
_this.apis[newName] = res;
|
||||
_this.apisArray.push(res);
|
||||
_this.swaggerVersion = response.swaggerVersion;
|
||||
if (_this.swaggerVersion === "1.2") {
|
||||
return _this.buildFromSpec(response);
|
||||
} else {
|
||||
if (response.basePath) {
|
||||
_this.basePath = response.basePath;
|
||||
} else if (_this.url.indexOf('?') > 0) {
|
||||
_this.basePath = _this.url.substring(0, _this.url.lastIndexOf('?'));
|
||||
} else {
|
||||
_this.basePath = _this.url;
|
||||
}
|
||||
_ref2 = response.apis;
|
||||
for (_k = 0, _len2 = _ref2.length; _k < _len2; _k++) {
|
||||
resource = _ref2[_k];
|
||||
res = new SwaggerResource(resource, _this);
|
||||
_this.apis[res.name] = res;
|
||||
_this.apisArray.push(res);
|
||||
}
|
||||
return _this.buildFrom1_1Spec(response);
|
||||
}
|
||||
if (_this.success) {
|
||||
_this.success();
|
||||
}
|
||||
return _this;
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -129,6 +85,110 @@
|
||||
return this;
|
||||
};
|
||||
|
||||
SwaggerApi.prototype.buildFromSpec = function(response) {
|
||||
var api, isApi, newName, operation, res, resource, _i, _j, _k, _len, _len1, _len2, _ref, _ref1, _ref2;
|
||||
if (response.apiVersion != null) {
|
||||
this.apiVersion = response.apiVersion;
|
||||
}
|
||||
this.apis = {};
|
||||
this.apisArray = [];
|
||||
this.produces = response.produces;
|
||||
this.authSchemes = response.authorizations;
|
||||
if (response.info != null) {
|
||||
this.info = response.info;
|
||||
}
|
||||
isApi = false;
|
||||
_ref = response.apis;
|
||||
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
||||
api = _ref[_i];
|
||||
if (api.operations) {
|
||||
_ref1 = api.operations;
|
||||
for (_j = 0, _len1 = _ref1.length; _j < _len1; _j++) {
|
||||
operation = _ref1[_j];
|
||||
isApi = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (response.basePath) {
|
||||
this.basePath = response.basePath;
|
||||
} else if (this.url.indexOf('?') > 0) {
|
||||
this.basePath = this.url.substring(0, this.url.lastIndexOf('?'));
|
||||
} else {
|
||||
this.basePath = this.url;
|
||||
}
|
||||
if (isApi) {
|
||||
newName = response.resourcePath.replace(/\//g, '');
|
||||
this.resourcePath = response.resourcePath;
|
||||
res = new SwaggerResource(response, this);
|
||||
this.apis[newName] = res;
|
||||
this.apisArray.push(res);
|
||||
} else {
|
||||
_ref2 = response.apis;
|
||||
for (_k = 0, _len2 = _ref2.length; _k < _len2; _k++) {
|
||||
resource = _ref2[_k];
|
||||
res = new SwaggerResource(resource, this);
|
||||
this.apis[res.name] = res;
|
||||
this.apisArray.push(res);
|
||||
}
|
||||
}
|
||||
if (this.success) {
|
||||
this.success();
|
||||
}
|
||||
return this;
|
||||
};
|
||||
|
||||
SwaggerApi.prototype.buildFrom1_1Spec = function(response) {
|
||||
var api, isApi, newName, operation, res, resource, _i, _j, _k, _len, _len1, _len2, _ref, _ref1, _ref2;
|
||||
console.log("This API is using a deprecated version of Swagger! Please see http://github.com/wordnik/swagger-core/wiki for more info");
|
||||
if (response.apiVersion != null) {
|
||||
this.apiVersion = response.apiVersion;
|
||||
}
|
||||
this.apis = {};
|
||||
this.apisArray = [];
|
||||
this.produces = response.produces;
|
||||
if (response.info != null) {
|
||||
this.info = response.info;
|
||||
}
|
||||
isApi = false;
|
||||
_ref = response.apis;
|
||||
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
||||
api = _ref[_i];
|
||||
if (api.operations) {
|
||||
_ref1 = api.operations;
|
||||
for (_j = 0, _len1 = _ref1.length; _j < _len1; _j++) {
|
||||
operation = _ref1[_j];
|
||||
isApi = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (response.basePath) {
|
||||
this.basePath = response.basePath;
|
||||
} else if (this.url.indexOf('?') > 0) {
|
||||
this.basePath = this.url.substring(0, this.url.lastIndexOf('?'));
|
||||
} else {
|
||||
this.basePath = this.url;
|
||||
}
|
||||
if (isApi) {
|
||||
newName = response.resourcePath.replace(/\//g, '');
|
||||
this.resourcePath = response.resourcePath;
|
||||
res = new SwaggerResource(response, this);
|
||||
this.apis[newName] = res;
|
||||
this.apisArray.push(res);
|
||||
} else {
|
||||
_ref2 = response.apis;
|
||||
for (_k = 0, _len2 = _ref2.length; _k < _len2; _k++) {
|
||||
resource = _ref2[_k];
|
||||
res = new SwaggerResource(resource, this);
|
||||
this.apis[res.name] = res;
|
||||
this.apisArray.push(res);
|
||||
}
|
||||
}
|
||||
if (this.success) {
|
||||
this.success();
|
||||
}
|
||||
return this;
|
||||
};
|
||||
|
||||
SwaggerApi.prototype.selfReflect = function() {
|
||||
var resource, resource_name, _ref;
|
||||
if (this.apis == null) {
|
||||
@@ -161,7 +221,7 @@
|
||||
for (resource_name in _ref) {
|
||||
resource = _ref[resource_name];
|
||||
for (modelName in resource.models) {
|
||||
if (!(this.models[modelName] != null)) {
|
||||
if (this.models[modelName] == null) {
|
||||
this.models[modelName] = resource.models[modelName];
|
||||
this.modelsArray.push(resource.models[modelName]);
|
||||
}
|
||||
@@ -201,7 +261,6 @@
|
||||
})();
|
||||
|
||||
SwaggerResource = (function() {
|
||||
|
||||
SwaggerResource.prototype.api = null;
|
||||
|
||||
SwaggerResource.prototype.produces = null;
|
||||
@@ -242,7 +301,7 @@
|
||||
headers: {},
|
||||
on: {
|
||||
error: function(response) {
|
||||
return _this.api.fail("Unable to read api '" + _this.name + "' from path " + _this.url + " (server returned " + error.statusText + ")");
|
||||
return _this.api.fail("Unable to read api '" + _this.name + "' from path " + _this.url + " (server returned " + response.statusText + ")");
|
||||
},
|
||||
response: function(rawResponse) {
|
||||
var response;
|
||||
@@ -290,7 +349,7 @@
|
||||
var model, modelName, swaggerModel, _i, _len, _ref, _results;
|
||||
if (models != null) {
|
||||
for (modelName in models) {
|
||||
if (!(this.models[modelName] != null)) {
|
||||
if (this.models[modelName] == null) {
|
||||
swaggerModel = new SwaggerModel(modelName, models[modelName]);
|
||||
this.modelsArray.push(swaggerModel);
|
||||
this.models[modelName] = swaggerModel;
|
||||
@@ -383,20 +442,20 @@
|
||||
})();
|
||||
|
||||
SwaggerModel = (function() {
|
||||
|
||||
function SwaggerModel(modelName, obj) {
|
||||
var propertyName, value;
|
||||
var prop, propertyName, value;
|
||||
this.name = obj.id != null ? obj.id : modelName;
|
||||
this.properties = [];
|
||||
for (propertyName in obj.properties) {
|
||||
if (obj["enum"] != null) {
|
||||
for (value in obj["enum"]) {
|
||||
if (propertyName === value) {
|
||||
if (obj.required != null) {
|
||||
for (value in obj.required) {
|
||||
if (propertyName === obj.required[value]) {
|
||||
obj.properties[propertyName].required = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
this.properties.push(new SwaggerModelProperty(propertyName, obj.properties[propertyName]));
|
||||
prop = new SwaggerModelProperty(propertyName, obj.properties[propertyName]);
|
||||
this.properties.push(prop);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -456,6 +515,7 @@
|
||||
prop = _ref[_i];
|
||||
result[prop.name] = prop.getSampleValue(modelsToIgnore);
|
||||
}
|
||||
modelsToIgnore.pop(this.name);
|
||||
return result;
|
||||
};
|
||||
|
||||
@@ -464,14 +524,12 @@
|
||||
})();
|
||||
|
||||
SwaggerModelProperty = (function() {
|
||||
|
||||
function SwaggerModelProperty(name, obj) {
|
||||
this.name = name;
|
||||
this.dataType = obj.type;
|
||||
this.dataType = obj.type || obj.dataType || obj["$ref"];
|
||||
this.isCollection = this.dataType && (this.dataType.toLowerCase() === 'array' || this.dataType.toLowerCase() === 'list' || this.dataType.toLowerCase() === 'set');
|
||||
this.descr = obj.description;
|
||||
this.required = obj.required;
|
||||
console.log(this);
|
||||
if (obj.items != null) {
|
||||
if (obj.items.type != null) {
|
||||
this.refDataType = obj.items.type;
|
||||
@@ -488,6 +546,13 @@
|
||||
this.valuesString = "'" + this.values.join("' or '") + "'";
|
||||
}
|
||||
}
|
||||
if (obj["enum"] != null) {
|
||||
this.valueType = "string";
|
||||
this.values = obj["enum"];
|
||||
if (this.values != null) {
|
||||
this.valueString = "'" + this.values.join("' or '") + "'";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
SwaggerModelProperty.prototype.getSampleValue = function(modelsToIgnore) {
|
||||
@@ -530,7 +595,6 @@
|
||||
})();
|
||||
|
||||
SwaggerOperation = (function() {
|
||||
|
||||
function SwaggerOperation(nickname, path, method, parameters, summary, notes, type, responseMessages, resource, consumes, produces) {
|
||||
var parameter, v, _i, _j, _k, _len, _len1, _len2, _ref, _ref1, _ref2, _ref3,
|
||||
_this = this;
|
||||
@@ -546,7 +610,6 @@
|
||||
this.consumes = consumes;
|
||||
this.produces = produces;
|
||||
this["do"] = __bind(this["do"], this);
|
||||
|
||||
if (this.nickname == null) {
|
||||
this.resource.api.fail("SwaggerOperations must have a nickname.");
|
||||
}
|
||||
@@ -560,7 +623,6 @@
|
||||
this.method = this.method.toLowerCase();
|
||||
this.isGetMethod = this.method === "get";
|
||||
this.resourceName = this.resource.name;
|
||||
console.log("model type: " + type);
|
||||
if (((_ref = this.type) != null ? _ref.toLowerCase() : void 0) === 'void') {
|
||||
this.type = void 0;
|
||||
}
|
||||
@@ -576,7 +638,7 @@
|
||||
type = parameter.type || parameter.dataType;
|
||||
if (type.toLowerCase() === 'boolean') {
|
||||
parameter.allowableValues = {};
|
||||
parameter.allowableValues.values = this.resource.api.booleanValues;
|
||||
parameter.allowableValues.values = ["true", "false"];
|
||||
}
|
||||
parameter.signature = this.getSignature(type, this.resource.models);
|
||||
parameter.sampleJSON = this.getSampleJSON(type, this.resource.models);
|
||||
@@ -847,7 +909,6 @@
|
||||
})();
|
||||
|
||||
SwaggerRequest = (function() {
|
||||
|
||||
function SwaggerRequest(type, url, params, opts, successCallback, errorCallback, operation, execution) {
|
||||
var body, e, fields, headers, key, myHeaders, name, obj, param, parent, possibleParams, requestContentType, responseContentType, urlEncoded, value, values,
|
||||
_this = this;
|
||||
@@ -1038,7 +1099,6 @@
|
||||
})();
|
||||
|
||||
SwaggerHttp = (function() {
|
||||
|
||||
SwaggerHttp.prototype.Shred = null;
|
||||
|
||||
SwaggerHttp.prototype.shred = null;
|
||||
@@ -1083,7 +1143,6 @@
|
||||
})();
|
||||
|
||||
SwaggerAuthorizations = (function() {
|
||||
|
||||
SwaggerAuthorizations.prototype.authz = null;
|
||||
|
||||
function SwaggerAuthorizations() {
|
||||
@@ -1111,7 +1170,6 @@
|
||||
})();
|
||||
|
||||
ApiKeyAuthorization = (function() {
|
||||
|
||||
ApiKeyAuthorization.prototype.type = null;
|
||||
|
||||
ApiKeyAuthorization.prototype.name = null;
|
||||
@@ -1141,6 +1199,27 @@
|
||||
|
||||
})();
|
||||
|
||||
PasswordAuthorization = (function() {
|
||||
PasswordAuthorization.prototype.name = null;
|
||||
|
||||
PasswordAuthorization.prototype.username = null;
|
||||
|
||||
PasswordAuthorization.prototype.password = null;
|
||||
|
||||
function PasswordAuthorization(name, username, password) {
|
||||
this.name = name;
|
||||
this.username = username;
|
||||
this.password = password;
|
||||
}
|
||||
|
||||
PasswordAuthorization.prototype.apply = function(obj) {
|
||||
return obj.headers["Authorization"] = "Basic " + btoa(this.username + ":" + this.password);
|
||||
};
|
||||
|
||||
return PasswordAuthorization;
|
||||
|
||||
})();
|
||||
|
||||
this.SwaggerApi = SwaggerApi;
|
||||
|
||||
this.SwaggerResource = SwaggerResource;
|
||||
@@ -1153,6 +1232,8 @@
|
||||
|
||||
this.ApiKeyAuthorization = ApiKeyAuthorization;
|
||||
|
||||
this.PasswordAuthorization = PasswordAuthorization;
|
||||
|
||||
this.authorizations = new SwaggerAuthorizations();
|
||||
|
||||
}).call(this);
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "swagger-ui",
|
||||
"version": "2.0.0",
|
||||
"version": "2.0.2",
|
||||
"description": "Swagger UI is a dependency-free collection of HTML, Javascript, and CSS assets that dynamically generate beautiful documentation from a Swagger-compliant API",
|
||||
"scripts": {
|
||||
"build": "PATH=$PATH:./node_modules/.bin cake dist",
|
||||
|
||||
@@ -83,24 +83,37 @@ class OperationView extends Backbone.View
|
||||
|
||||
for o in form.find("input")
|
||||
if(o.value? && jQuery.trim(o.value).length > 0)
|
||||
map[o.name] = encodeURI(o.value)
|
||||
map[o.name] = o.value
|
||||
|
||||
for o in form.find("textarea")
|
||||
if(o.value? && jQuery.trim(o.value).length > 0)
|
||||
map["body"] = o.value
|
||||
|
||||
for o in form.find("select")
|
||||
if(o.value? && jQuery.trim(o.value).length > 0)
|
||||
map[o.name] = o.value
|
||||
for o in form.find("select")
|
||||
val = this.getSelectedValue o
|
||||
if(val? && jQuery.trim(val).length > 0)
|
||||
map[o.name] = val
|
||||
|
||||
opts.responseContentType = $("div select[name=responseContentType]", $(@el)).val()
|
||||
opts.requestContentType = $("div select[name=parameterContentType]", $(@el)).val()
|
||||
|
||||
$(".response_throbber", $(@el)).show()
|
||||
|
||||
@model.do(map, opts, @showCompleteStatus, @showErrorStatus, @)
|
||||
|
||||
success: (response, parent) ->
|
||||
parent.showCompleteStatus response
|
||||
|
||||
|
||||
getSelectedValue: (select) ->
|
||||
if !select.multiple
|
||||
select.value
|
||||
else
|
||||
options = []
|
||||
options.push opt.value for opt in select.options when opt.selected
|
||||
if options.length > 0
|
||||
options.join ","
|
||||
else
|
||||
null
|
||||
|
||||
# handler for hide response link
|
||||
hideResponse: (e) ->
|
||||
@@ -192,7 +205,7 @@ class OperationView extends Backbone.View
|
||||
if content == undefined
|
||||
code = $('<code />').text("no content")
|
||||
pre = $('<pre class="json" />').append(code)
|
||||
else if contentType.indexOf("application/json") == 0
|
||||
else if contentType.indexOf("application/json") == 0 || contentType.indexOf("application/hal+json") == 0
|
||||
code = $('<code />').text(JSON.stringify(JSON.parse(content), null, 2))
|
||||
pre = $('<pre class="json" />').append(code)
|
||||
else if contentType.indexOf("application/xml") == 0
|
||||
|
||||
@@ -2,6 +2,7 @@ class ResourceView extends Backbone.View
|
||||
initialize: ->
|
||||
|
||||
render: ->
|
||||
console.log @model.description
|
||||
$(@el).html(Handlebars.templates.resource(@model))
|
||||
|
||||
@number = 0
|
||||
|
||||
@@ -1,16 +1,19 @@
|
||||
<td class='code'>{{name}}</td>
|
||||
<td>
|
||||
<select class='parameter' name='{{name}}'>
|
||||
<select {{#if allowMultiple}} multiple='multiple'{{/if}} class='parameter' name='{{name}}'>
|
||||
{{#if required}}
|
||||
{{else}}
|
||||
{{#if defaultValue}}
|
||||
{{else}}
|
||||
<option selected="" value=''></option>
|
||||
{{#if allowMultiple}}
|
||||
{{else}}
|
||||
<option selected="" value=''></option>
|
||||
{{/if}}
|
||||
{{/if}}
|
||||
{{/if}}
|
||||
{{#each allowableValues.descriptiveValues}}
|
||||
{{#if isDefault}}
|
||||
<option value='{{value}}'>{{value}} (default)</option>
|
||||
<option selected="" value='{{value}}'>{{value}} (default)</option>
|
||||
{{else}}
|
||||
<option value='{{value}}'>{{value}}</option>
|
||||
{{/if}}
|
||||
@@ -19,4 +22,4 @@
|
||||
</td>
|
||||
<td>{{{description}}}</td>
|
||||
<td>{{{paramType}}}</td>
|
||||
<td><span class="model-signature"></span></td>
|
||||
<td><span class="model-signature"></span></td>
|
||||
@@ -1,6 +1,6 @@
|
||||
<div class='heading'>
|
||||
<h2>
|
||||
<a href='#!/{{name}}' onclick="Docs.toggleEndpointListForResource('{{name}}');">{{name}}</a>
|
||||
<a href='#!/{{name}}' onclick="Docs.toggleEndpointListForResource('{{name}}');">{{name}}</a> {{#description}} : {{/description}}{{{description}}}
|
||||
</h2>
|
||||
<ul class='options'>
|
||||
<li>
|
||||
|
||||
Reference in New Issue
Block a user