updated from master

This commit is contained in:
Tony Tam
2015-02-18 21:18:53 -08:00
committed by Mohsen Azimi
parent c847551ac4
commit 9d0c6c50e7
12 changed files with 1204 additions and 757 deletions

View File

@@ -20,7 +20,7 @@ The Swagger Specification has undergone 4 revisions since initial creation in 20
Swagger UI Version | Release Date | Swagger Spec compatibility | Notes | Status Swagger UI Version | Release Date | Swagger Spec compatibility | Notes | Status
------------------ | ------------ | -------------------------- | ----- | ------ ------------------ | ------------ | -------------------------- | ----- | ------
2.1.0-M1 | 2015-01-31 | 1.1, 1.2, 2.0 | [master](https://github.com/swagger-api/swagger-ui) | 2.1.5-M1 | 2015-02-18 | 1.1, 1.2, 2.0 | [master](https://github.com/swagger-api/swagger-ui) |
2.0.24 | 2014-09-12 | 1.1, 1.2 | [tag v2.0.24](https://github.com/swagger-api/swagger-ui/tree/v2.0.24) | 2.0.24 | 2014-09-12 | 1.1, 1.2 | [tag v2.0.24](https://github.com/swagger-api/swagger-ui/tree/v2.0.24) |
1.0.13 | 2013-03-08 | 1.1, 1.2 | [tag v1.0.13](https://github.com/swagger-api/swagger-ui/tree/v1.0.13) | 1.0.13 | 2013-03-08 | 1.1, 1.2 | [tag v1.0.13](https://github.com/swagger-api/swagger-ui/tree/v1.0.13) |
1.0.1 | 2011-10-11 | 1.0, 1.1 | [tag v1.0.1](https://github.com/swagger-api/swagger-ui/tree/v1.0.1) | 1.0.1 | 2011-10-11 | 1.0, 1.1 | [tag v1.0.1](https://github.com/swagger-api/swagger-ui/tree/v1.0.1) |
@@ -51,7 +51,7 @@ docker run -p 127.0.0.1:8080:8080 swagger-ui-builder
This will start Swagger UI at `http://localhost:8080`. This will start Swagger UI at `http://localhost:8080`.
### Use ### Use
Once you open the Swagger UI, it will load the [Swagger Petstore](http://petstore.swagger.wordnik.com/v2/swagger.json) service and show its APIs. You can enter your own server url and click explore to view the API. Once you open the Swagger UI, it will load the [Swagger Petstore](http://petstore.swagger.io/v2/swagger.json) service and show its APIs. You can enter your own server url and click explore to view the API.
### Customize ### Customize
You may choose to customize Swagger UI for your organization. Here is an overview of whats in its various directories: You may choose to customize Swagger UI for your organization. Here is an overview of whats in its various directories:
@@ -71,7 +71,7 @@ To use swagger-ui you should take a look at the [source of swagger-ui html page]
```javascript ```javascript
window.swaggerUi = new SwaggerUi({ window.swaggerUi = new SwaggerUi({
url:"http://petstore.swagger.wordnik.com/v2/swagger.json", url:"http://petstore.swagger.io/v2/swagger.json",
dom_id:"swagger-ui-container" dom_id:"swagger-ui-container"
}); });
@@ -172,7 +172,7 @@ You can verify CORS support with one of three techniques:
- Curl your API and inspect the headers. For instance: - Curl your API and inspect the headers. For instance:
```bash ```bash
$ curl -I "http://petstore.swagger.wordnik.com/v2/swagger.json" $ curl -I "http://petstore.swagger.io/v2/swagger.json"
HTTP/1.1 200 OK HTTP/1.1 200 OK
Date: Sat, 31 Jan 2015 23:05:44 GMT Date: Sat, 31 Jan 2015 23:05:44 GMT
Access-Control-Allow-Origin: * Access-Control-Allow-Origin: *

6
dist/index.html vendored
View File

@@ -16,8 +16,6 @@
<script src='lib/underscore-min.js' type='text/javascript'></script> <script src='lib/underscore-min.js' type='text/javascript'></script>
<script src='lib/backbone-min.js' type='text/javascript'></script> <script src='lib/backbone-min.js' type='text/javascript'></script>
<script src='lib/swagger-client.js' type='text/javascript'></script> <script src='lib/swagger-client.js' type='text/javascript'></script>
<script src='lang/translator.js' type='text/javascript'></script>
<script src='lang/en.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/marked.js' type='text/javascript'></script> <script src='lib/marked.js' type='text/javascript'></script>
@@ -35,10 +33,8 @@
window.swaggerUi = new SwaggerUi({ window.swaggerUi = new SwaggerUi({
url: url, url: url,
dom_id: "swagger-ui-container", dom_id: "swagger-ui-container",
supportedSubmitMethods: ['get', 'post', 'put', 'delete'], supportedSubmitMethods: ['get', 'post', 'put', 'delete', 'patch'],
onComplete: function(swaggerApi, swaggerUi){ onComplete: function(swaggerApi, swaggerUi){
SwaggerTranslator.translate();
if(typeof initOAuth == "function") { if(typeof initOAuth == "function") {
/* /*
initOAuth({ initOAuth({

50
dist/lang/en.js vendored
View File

@@ -1,50 +0,0 @@
SwaggerTranslator.learn({
"Warning: Deprecated":"Warning: Deprecated",
"Implementation Notes":"Implementation Notes",
"Response Class":"Response Class",
"Status":"Status",
"Parameters":"Parameters",
"Parameter":"Parameter",
"Value":"Value",
"Description":"Description",
"Parameter Type":"Parameter Type",
"Data Type":"Data Type",
"Response Messages":"Response Messages",
"HTTP Status Code":"HTTP Status Code",
"Reason":"Reason",
"Response Model":"Response Model",
"Request URL":"Request URL",
"Response Body":"Response Body",
"Response Code":"Response Code",
"Response Headers":"Response Headers",
"Hide Response":"Hide Response",
"Try it out!":"Try it out!",
"Show/Hide":"Show/Hide",
"List Operations":"List Operations",
"Expand Operations":"Expand Operations",
"Raw":"Raw",
"can't parse JSON. Raw result":"can't parse JSON. Raw result",
"Model Schema":"Model Schema",
"Model":"Model",
"apply":"apply",
"Username":"Username",
"Password":"Password",
"Terms of service":"Terms of service",
"Created by":"Created by",
"See more at":"See more at",
"Contact the developer":"Contact the developer",
"api version":"api version",
"Response Content Type":"Response Content Type",
"fetching resource":"fetching resource",
"fetching resource list":"fetching resource list",
"Explore":"Explore",
"Show Swagger Petstore Example Apis":"Show Swagger Petstore Example Apis",
"Show Wordnik Developer Apis":"Show Wordnik Developer Apis",
"Can't read from server. It may not have the appropriate access-control-origin settings.":"Can't read from server. It may not have the appropriate access-control-origin settings.",
"Please specify the protocol for":"Please specify the protocol for",
"Can't read swagger JSON from":"Can't read swagger JSON from",
"Finished Loading Resource Information. Rendering Swagger UI":"Finished Loading Resource Information. Rendering Swagger UI",
"Unable to read api":"Unable to read api",
"from path":"from path",
"server returned":"server returned"
});

51
dist/lang/ru.js vendored
View File

@@ -1,51 +0,0 @@
SwaggerTranslator.learn({
"Warning: Deprecated":"Ворнинг: Депрекейтед",
"Implementation Notes":"Заметки",
"Response Class":"Пример ответа",
"Status":"Статус",
"Parameters":"Параметры",
"Parameter":"Параметр",
"Value":"Значение",
"Description":"Описание",
"Parameter Type":"Тип параметра",
"Data Type":"Тип данных",
"HTTP Status Code":"HTTP код",
"Reason":"Причина",
"Response Model":"Структура ответа",
"Request URL":"URL запроса",
"Response Body":"Тело ответа",
"Response Code":"HTTP код ответа",
"Response Headers":"Заголовки ответа",
"Hide Response":"Спрятать ответ",
"Response Messages":"Что может прийти в ответ",
"Try it out!":"Попробовать!",
"Show/Hide":"Показать/Скрыть",
"List Operations":"Операции кратко",
"Expand Operations":"Операции подробно",
"Raw":"В сыром виде",
"can't parse JSON. Raw result":"Не удается распарсить ответ:",
"Model Schema":"Структура",
"Model":"Описание",
"apply":"применить",
"Username":"Имя пользователя",
"Password":"Пароль",
"Terms of service":"Условия использования",
"Created by":"Разработано",
"See more at":"Еще тут",
"Contact the developer":"Связаться с разработчиком",
"api version":"Версия API",
"Response Content Type":"Content Type ответа",
"fetching resource":"Получение ресурса",
"fetching resource list":"Получение ресурсов",
"Explore":"Поехали",
"Show Swagger Petstore Example Apis":"Показать примеры АПИ",
"Show Wordnik Developer Apis":"Показать АПИ Wordnik Developer",
"Can't read from server. It may not have the appropriate access-control-origin settings.":"Не удается получить ответ от сервера. Возможно, какая-то лажа с настройками доступа",
"Please specify the protocol for":"Пожалуйста, укажите протогол для",
"Can't read swagger JSON from":"Не получается прочитать swagger json из",
"Finished Loading Resource Information. Rendering Swagger UI":"Загрузка информации о ресурсах завершена. Рендерим",
"Unable to read api":"Не удалось прочитать api",
"from path":"по адресу",
"server returned":"сервер сказал"
});

View File

@@ -1,53 +0,0 @@
/**
* Translator for documentation pages.
*
* To enable translation you should include one of language-files in your index.html
* after <script src='lang/translator.js' type='text/javascript'></script>.
* For example - <script src='lang/ru.js' type='text/javascript'></script>
*
* If you wish to translate some new texsts you should do two things:
* 1. Add a new phrase pair ("New Phrase": "New Translation") into your language file (for example lang/ru.js). It will be great if you add it in other language files too.
* 2. Mark that text it templates this way <anyHtmlTag data-sw-translate>New Phrase</anyHtmlTag> or <anyHtmlTag data-sw-translate value='New Phrase'/>.
* The main thing here is attribute data-sw-translate. Only inner text, title-attribute and value-attribute are going to translate.
*
*/
SwaggerTranslator = {
_words:[],
translate: function() {
var $this = this;
$("[data-sw-translate]").each(
function() {
if ($(this).text() && $(this).children().length == 0) {
$(this).text(
$this._tryTranslate($(this).text())
);
}
if ($(this).val()) {
$(this).val(
$this._tryTranslate($(this).val())
);
}
if ($(this).attr('title')) {
$(this).attr(
'title',
$this._tryTranslate($(this).attr('title'))
);
}
}
)
},
_tryTranslate: function(word) {
return this._words[word] != undefined ? this._words[word] : word;
},
learn: function(wordsMap) {
this._words = wordsMap;
}
}

View File

@@ -1,6 +1,6 @@
/** /**
* swagger-client - swagger.js is a javascript client for use with swaggering APIs. * swagger-client - swagger.js is a javascript client for use with swaggering APIs.
* @version v2.1.3-M1 * @version v2.1.9-M1
* @link http://swagger.io * @link http://swagger.io
* @license apache 2.0 * @license apache 2.0
*/ */
@@ -57,10 +57,31 @@ ArrayModel.prototype.getSampleValue = function(modelsToIgnore) {
ArrayModel.prototype.getMockSignature = function(modelsToIgnore) { ArrayModel.prototype.getMockSignature = function(modelsToIgnore) {
var propertiesStr = []; var propertiesStr = [];
var i, prop;
if(this.ref) { for (i = 0; i < this.properties.length; i++) {
return models[simpleRef(this.ref)].getMockSignature(); prop = this.properties[i];
propertiesStr.push(prop.toString());
} }
var strong = '<span class="strong">';
var stronger = '<span class="stronger">';
var strongClose = '</span>';
var classOpen = strong + 'array' + ' {' + strongClose;
var classClose = strong + '}' + strongClose;
var returnVal = classOpen + '<div>' + propertiesStr.join(',</div><div>') + '</div>' + classClose;
if (!modelsToIgnore)
modelsToIgnore = {};
modelsToIgnore[this.name] = this;
for (i = 0; i < this.properties.length; i++) {
prop = this.properties[i];
var ref = prop.$ref;
var model = models[ref];
if (model && typeof modelsToIgnore[ref] === 'undefined') {
returnVal = returnVal + ('<br>' + model.getMockSignature(modelsToIgnore));
}
}
return returnVal;
}; };
@@ -280,6 +301,206 @@ PrimitiveModel.prototype.getMockSignature = function(modelsToIgnore) {
} }
return returnVal; return returnVal;
}; };
/**
* Resolves a spec's remote references
*/
var Resolver = function (){};
Resolver.prototype.resolve = function(spec, callback, scope) {
this.scope = (scope || this);
var host, name, path, property, propertyName, type;
var processedCalls = 0, resolvedRefs = {}, unresolvedRefs = {};
// store objects for dereferencing
var resolutionTable = {};
// models
for(name in spec.definitions) {
var model = spec.definitions[name];
for(propertyName in model.properties) {
property = model.properties[propertyName];
this.resolveTo(property, resolutionTable);
}
}
// operations
for(name in spec.paths) {
var method, operation, responseCode;
path = spec.paths[name];
for(method in path) {
operation = path[method];
var i, parameters = operation.parameters;
for(i in parameters) {
var parameter = parameters[i];
if(parameter.in === 'body' && parameter.schema) {
this.resolveTo(parameter.schema, resolutionTable);
}
if(parameter.$ref) {
this.resolveInline(spec, parameter, resolutionTable, unresolvedRefs);
}
}
for(responseCode in operation.responses) {
var response = operation.responses[responseCode];
if(response.schema) {
this.resolveTo(response.schema, resolutionTable);
}
}
}
}
// get hosts
var opts = {}, expectedCalls = 0;
for(name in resolutionTable) {
var parts = name.split('#');
if(parts.length == 2) {
host = parts[0]; path = parts[1];
if(!Array.isArray(opts[host])) {
opts[host] = [];
expectedCalls += 1;
}
opts[host].push(path);
}
}
for(name in opts) {
var self = this, opt = opts[name];
host = name;
var obj = {
useJQuery: false, // TODO
url: host,
method: "get",
headers: {
accept: this.scope.swaggerRequestHeaders || 'application/json'
},
on: {
error: function(response) {
processedCalls += 1;
var i;
for(i = 0; i < opt.length; i++) {
// fail all of these
var resolved = host + '#' + opt[i];
unresolvedRefs[resolved] = null;
}
if(processedCalls === expectedCalls)
self.finish(spec, resolutionTable, resolvedRefs, unresolvedRefs, callback);
},
response: function(response) {
var i, j, swagger = response.obj;
processedCalls += 1;
for(i = 0; i < opt.length; i++) {
var location = swagger, path = opt[i], parts = path.split('/');
for(j = 0; j < parts.length; j++) {
var segment = parts[j];
if(typeof location === 'undefined')
break;
if(segment.length > 0)
location = location[segment];
}
var resolved = host + '#' + path, resolvedName = parts[j-1];
if(typeof location !== 'undefined') {
resolvedRefs[resolved] = {
name: resolvedName,
obj: location
};
}
else unresolvedRefs[resolved] = null;
}
if(processedCalls === expectedCalls)
self.finish(spec, resolutionTable, resolvedRefs, unresolvedRefs, callback);
}
}
};
authorizations.apply(obj);
new SwaggerHttp().execute(obj);
}
if(Object.keys(opts).length === 0)
callback.call(this.scope, spec, unresolvedRefs);
};
Resolver.prototype.finish = function(spec, resolutionTable, resolvedRefs, unresolvedRefs, callback) {
// walk resolution table and replace with resolved refs
var ref;
for(ref in resolutionTable) {
var i, locations = resolutionTable[ref];
for(i = 0; i < locations.length; i++) {
var resolvedTo = resolvedRefs[locations[i].obj.$ref];
if(resolvedTo) {
if(!spec.definitions)
spec.definitions = {};
if(locations[i].resolveAs === '$ref') {
spec.definitions[resolvedTo.name] = resolvedTo.obj;
locations[i].obj.$ref = '#/definitions/' + resolvedTo.name;
}
else if (locations[i].resolveAs === 'inline') {
var key;
var targetObj = locations[i].obj;
delete targetObj.$ref;
for(key in resolvedTo.obj) {
targetObj[key] = resolvedTo.obj[key];
}
}
}
}
}
callback.call(this.scope, spec, unresolvedRefs);
};
/**
* immediately in-lines local refs, queues remote refs
* for inline resolution
*/
Resolver.prototype.resolveInline = function (spec, property, objs, unresolvedRefs) {
var ref = property.$ref;
if(ref) {
if(ref.indexOf('http') === 0) {
if(Array.isArray(objs[ref])) {
objs[ref].push({obj: property, resolveAs: 'inline'});
}
else {
objs[ref] = [{obj: property, resolveAs: 'inline'}];
}
}
else if (ref.indexOf('#') === 0) {
// local resolve
var shortenedRef = ref.substring(1);
var i, parts = shortenedRef.split('/'), location = spec;
for(i = 0; i < parts.length; i++) {
var part = parts[i];
if(part.length > 0) {
location = location[part];
}
}
if(location) {
delete property.$ref;
var key;
for(key in location) {
property[key] = location[key];
}
}
else unresolvedRefs[ref] = null;
}
}
else if(property.type === 'array') {
this.resolveTo(property.items, objs);
}
};
Resolver.prototype.resolveTo = function (property, objs) {
var ref = property.$ref;
if(ref) {
if(ref.indexOf('http') === 0) {
if(Array.isArray(objs[ref])) {
objs[ref].push({obj: property, resolveAs: '$ref'});
}
else {
objs[ref] = [{obj: property, resolveAs: '$ref'}];
}
}
}
else if(property.type === 'array') {
var items = property.items;
this.resolveTo(items, objs);
}
};
var addModel = function(name, model) { var addModel = function(name, model) {
models[name] = model; models[name] = model;
}; };
@@ -325,8 +546,7 @@ SwaggerClient.prototype.initialize = function (url, options) {
if (options.authorizations) { if (options.authorizations) {
this.clientAuthorizations = options.authorizations; this.clientAuthorizations = options.authorizations;
} else { } else {
var e = (typeof window !== 'undefined' ? window : exports); this.clientAuthorizations = authorizations;
this.clientAuthorizations = e.authorizations;
} }
this.supportedSubmitMethods = options.supportedSubmitMethods || []; this.supportedSubmitMethods = options.supportedSubmitMethods || [];
@@ -336,6 +556,7 @@ SwaggerClient.prototype.initialize = function (url, options) {
this.options = options; this.options = options;
if (typeof options.success === 'function') { if (typeof options.success === 'function') {
this.ready = true;
this.build(); this.build();
} }
}; };
@@ -343,7 +564,7 @@ SwaggerClient.prototype.initialize = function (url, options) {
SwaggerClient.prototype.build = function(mock) { SwaggerClient.prototype.build = function(mock) {
if (this.isBuilt) return this; if (this.isBuilt) return this;
var self = this; var self = this;
this.progress('<span data-sw-translate>fetching resource list</span>: ' + this.url); this.progress('fetching resource list: ' + this.url);
var obj = { var obj = {
useJQuery: this.useJQuery, useJQuery: this.useJQuery,
url: this.url, url: this.url,
@@ -354,11 +575,11 @@ SwaggerClient.prototype.build = function(mock) {
on: { on: {
error: function(response) { error: function(response) {
if (self.url.substring(0, 4) !== 'http') if (self.url.substring(0, 4) !== 'http')
return self.fail('<span data-sw-translate>Please specify the protocol for</span> ' + self.url); return self.fail('Please specify the protocol for ' + self.url);
else if (response.status === 0) else if (response.status === 0)
return self.fail('<span data-sw-translate>Can\'t read from server. It may not have the appropriate access-control-origin settings.</span>'); return self.fail('Can\'t read from server. It may not have the appropriate access-control-origin settings.');
else if (response.status === 404) else if (response.status === 404)
return self.fail('<span data-sw-translate>Can\'t read swagger JSON from</span> ' + self.url); return self.fail('Can\'t read swagger JSON from ' + self.url);
else else
return self.fail(response.status + ' : ' + response.statusText + ' ' + self.url); return self.fail(response.status + ' : ' + response.statusText + ' ' + self.url);
}, },
@@ -368,7 +589,7 @@ SwaggerClient.prototype.build = function(mock) {
if(responseObj.swagger && parseInt(responseObj.swagger) === 2) { if(responseObj.swagger && parseInt(responseObj.swagger) === 2) {
self.swaggerVersion = responseObj.swagger; self.swaggerVersion = responseObj.swagger;
self.buildFromSpec(responseObj); new Resolver().resolve(responseObj, self.buildFromSpec, self);
self.isValid = true; self.isValid = true;
} }
else { else {
@@ -382,11 +603,12 @@ SwaggerClient.prototype.build = function(mock) {
} }
}; };
if(this.spec) { if(this.spec) {
setTimeout(function() { self.buildFromSpec(self.spec); }, 10); setTimeout(function() {
new Resolver().resolve(self.spec, self.buildFromSpec, self);
}, 10);
} }
else { else {
var e = (typeof window !== 'undefined' ? window : exports); authorizations.apply(obj);
var status = e.authorizations.apply(obj);
if(mock) if(mock)
return obj; return obj;
new SwaggerHttp().execute(obj); new SwaggerHttp().execute(obj);
@@ -411,8 +633,16 @@ SwaggerClient.prototype.buildFromSpec = function(response) {
// legacy support // legacy support
this.authSchemes = response.securityDefinitions; this.authSchemes = response.securityDefinitions;
var location; var definedTags = {};
if(Array.isArray(response.tags)) {
definedTags = {};
for(k = 0; k < response.tags.length; k++) {
var t = response.tags[k];
definedTags[t.name] = t;
}
}
var location;
if(typeof this.url === 'string') { if(typeof this.url === 'string') {
location = this.parseUri(this.url); location = this.parseUri(this.url);
} }
@@ -472,17 +702,32 @@ SwaggerClient.prototype.buildFromSpec = function(response) {
for(i = 0; i < tags.length; i++) { for(i = 0; i < tags.length; i++) {
var tag = this.tagFromLabel(tags[i]); var tag = this.tagFromLabel(tags[i]);
var operationGroup = this[tag]; var operationGroup = this[tag];
if(typeof this.apis[tag] === 'undefined')
this.apis[tag] = {};
if(typeof operationGroup === 'undefined') { if(typeof operationGroup === 'undefined') {
this[tag] = []; this[tag] = [];
operationGroup = this[tag]; operationGroup = this[tag];
operationGroup.operations = {}; operationGroup.operations = {};
operationGroup.label = tag; operationGroup.label = tag;
operationGroup.apis = []; operationGroup.apis = [];
this[tag].help = this.help.bind(operationGroup); var tagObject = definedTags[tag];
this.apisArray.push(new OperationGroup(tag, operationObject)); if(typeof tagObject === 'object') {
operationGroup.description = tagObject.description;
operationGroup.externalDocs = tagObject.externalDocs;
} }
this[tag].help = this.help.bind(operationGroup);
this.apisArray.push(new OperationGroup(tag, operationGroup.description, operationGroup.externalDocs, operationObject));
}
if(typeof this.apis[tag].help !== 'function')
this.apis[tag].help = this.help.bind(operationGroup);
// bind to the apis object
this.apis[tag][operationId] = operationObject.execute.bind(operationObject);
this.apis[tag][operationId].help = operationObject.help.bind(operationObject);
this.apis[tag][operationId].asCurl = operationObject.asCurl.bind(operationObject);
operationGroup[operationId] = operationObject.execute.bind(operationObject); operationGroup[operationId] = operationObject.execute.bind(operationObject);
operationGroup[operationId].help = operationObject.help.bind(operationObject); operationGroup[operationId].help = operationObject.help.bind(operationObject);
operationGroup[operationId].asCurl = operationObject.asCurl.bind(operationObject);
operationGroup.apis.push(operationObject); operationGroup.apis.push(operationObject);
operationGroup.operations[operationId] = operationObject; operationGroup.operations[operationId] = operationObject;
@@ -525,12 +770,18 @@ SwaggerClient.prototype.parseUri = function(uri) {
}; };
}; };
SwaggerClient.prototype.help = function() { SwaggerClient.prototype.help = function(dontPrint) {
var i; var i;
log('operations for the "' + this.label + '" tag'); var output = 'operations for the "' + this.label + '" tag';
for(i = 0; i < this.apis.length; i++) { for(i = 0; i < this.apis.length; i++) {
var api = this.apis[i]; var api = this.apis[i];
log(' * ' + api.nickname + ': ' + api.operation.summary); output += '\n * ' + api.nickname + ': ' + api.operation.summary;
}
if(dontPrint)
return output;
else {
log(output);
return output;
} }
}; };
@@ -548,14 +799,14 @@ SwaggerClient.prototype.fail = function(message) {
throw message; throw message;
}; };
var OperationGroup = function(tag, operation) { var OperationGroup = function(tag, description, externalDocs, operation) {
this.tag = tag; this.tag = tag;
this.path = tag; this.path = tag;
this.description = description;
this.externalDocs = externalDocs;
this.name = tag; this.name = tag;
this.operation = operation; this.operation = operation;
this.operationsArray = []; this.operationsArray = [];
this.description = operation.description || "";
}; };
var Operation = function(parent, scheme, operationId, httpMethod, path, args, definitions) { var Operation = function(parent, scheme, operationId, httpMethod, path, args, definitions) {
@@ -720,10 +971,14 @@ Operation.prototype.getType = function (param) {
str = 'long'; str = 'long';
else if(type === 'integer') else if(type === 'integer')
str = 'integer'; str = 'integer';
else if(type === 'string' && format === 'date-time') else if(type === 'string') {
if(format === 'date-time')
str = 'date-time'; str = 'date-time';
else if(type === 'string' && format === 'date') else if(format === 'date')
str = 'date'; str = 'date';
else
str = 'string';
}
else if(type === 'number' && format === 'float') else if(type === 'number' && format === 'float')
str = 'float'; str = 'float';
else if(type === 'number' && format === 'double') else if(type === 'number' && format === 'double')
@@ -732,8 +987,6 @@ Operation.prototype.getType = function (param) {
str = 'double'; str = 'double';
else if(type === 'boolean') else if(type === 'boolean')
str = 'boolean'; str = 'boolean';
else if(type === 'string')
str = 'string';
else if(type === 'array') { else if(type === 'array') {
isArray = true; isArray = true;
if(param.items) if(param.items)
@@ -780,7 +1033,7 @@ Operation.prototype.help = function(dontPrint) {
var out = this.nickname + ': ' + this.summary + '\n'; var out = this.nickname + ': ' + this.summary + '\n';
for(var i = 0; i < this.parameters.length; i++) { for(var i = 0; i < this.parameters.length; i++) {
var param = this.parameters[i]; var param = this.parameters[i];
var typeInfo = typeFromJsonSchema(param.type, param.format); var typeInfo = param.signature;
out += '\n * ' + param.name + ' (' + typeInfo + '): ' + param.description; out += '\n * ' + param.name + ' (' + typeInfo + '): ' + param.description;
} }
if(typeof dontPrint === 'undefined') if(typeof dontPrint === 'undefined')
@@ -898,9 +1151,8 @@ Operation.prototype.getMissingParams = function(args) {
return missingParams; return missingParams;
}; };
Operation.prototype.getBody = function(headers, args) { Operation.prototype.getBody = function(headers, args, opts) {
var formParams = {}; var formParams = {}, body, key;
var body;
for(var i = 0; i < this.parameters.length; i++) { for(var i = 0; i < this.parameters.length; i++) {
var param = this.parameters[i]; var param = this.parameters[i];
@@ -916,7 +1168,6 @@ Operation.prototype.getBody = function(headers, args) {
// handle form params // handle form params
if(headers['Content-Type'] === 'application/x-www-form-urlencoded') { if(headers['Content-Type'] === 'application/x-www-form-urlencoded') {
var encoded = ""; var encoded = "";
var key;
for(key in formParams) { for(key in formParams) {
value = formParams[key]; value = formParams[key];
if(typeof value !== 'undefined'){ if(typeof value !== 'undefined'){
@@ -927,6 +1178,25 @@ Operation.prototype.getBody = function(headers, args) {
} }
body = encoded; body = encoded;
} }
else if (headers['Content-Type'] && headers['Content-Type'].indexOf('multipart/form-data') >= 0) {
if(opts.useJQuery) {
var bodyParam = new FormData();
bodyParam.type = 'formData';
for (key in formParams) {
value = args[key];
if (typeof value !== 'undefined') {
// required for jquery file upload
if(value.type === 'file' && value.value) {
delete headers['Content-Type'];
bodyParam.append(key, value.value);
}
else
bodyParam.append(key, value);
}
}
body = bodyParam;
}
}
return body; return body;
}; };
@@ -989,9 +1259,8 @@ Operation.prototype.execute = function(arg1, arg2, arg3, arg4, parent) {
success = (success||log); success = (success||log);
error = (error||log); error = (error||log);
if(typeof opts.useJQuery === 'boolean') { if(opts.useJQuery)
this.useJQuery = opts.useJQuery; this.useJQuery = opts.useJQuery;
}
var missingParams = this.getMissingParams(args); var missingParams = this.getMissingParams(args);
if(missingParams.length > 0) { if(missingParams.length > 0) {
@@ -1006,7 +1275,7 @@ Operation.prototype.execute = function(arg1, arg2, arg3, arg4, parent) {
for (attrname in allHeaders) { headers[attrname] = allHeaders[attrname]; } for (attrname in allHeaders) { headers[attrname] = allHeaders[attrname]; }
for (attrname in contentTypeHeaders) { headers[attrname] = contentTypeHeaders[attrname]; } for (attrname in contentTypeHeaders) { headers[attrname] = contentTypeHeaders[attrname]; }
var body = this.getBody(headers, args); var body = this.getBody(headers, args, opts);
var url = this.urlify(args); var url = this.urlify(args);
var obj = { var obj = {
@@ -1024,18 +1293,17 @@ Operation.prototype.execute = function(arg1, arg2, arg3, arg4, parent) {
} }
} }
}; };
var status = e.authorizations.apply(obj, this.operation.security); var status = authorizations.apply(obj, this.operation.security);
if(opts.mock === true) if(opts.mock === true)
return obj; return obj;
else else
new SwaggerHttp().execute(obj); new SwaggerHttp().execute(obj, opts);
}; };
Operation.prototype.setContentTypes = function(args, opts) { Operation.prototype.setContentTypes = function(args, opts) {
// default type // default type
var accepts = 'application/json'; var accepts = 'application/json';
var consumes = args.parameterContentType || 'application/json'; var consumes = args.parameterContentType || 'application/json';
var allDefinedParams = this.parameters; var allDefinedParams = this.parameters;
var definedFormParams = []; var definedFormParams = [];
var definedFileParams = []; var definedFileParams = [];
@@ -1108,14 +1376,24 @@ Operation.prototype.setContentTypes = function(args, opts) {
}; };
Operation.prototype.asCurl = function (args) { Operation.prototype.asCurl = function (args) {
var obj = this.execute(args, {mock: true});
authorizations.apply(obj);
var results = []; var results = [];
var headers = this.getHeaderParams(args); results.push('-X ' + this.method.toUpperCase());
if (headers) { if (obj.headers) {
var key; var key;
for (key in headers) for (key in obj.headers)
results.push("--header \"" + key + ": " + headers[key] + "\""); results.push('--header "' + key + ': ' + obj.headers[key] + '"');
} }
return "curl " + (results.join(" ")) + " " + this.urlify(args); if(obj.body) {
var body;
if(typeof obj.body === 'object')
body = JSON.stringify(obj.body);
else
body = obj.body;
results.push('-d "' + body.replace(/"/g, '\\"') + '"');
}
return 'curl ' + (results.join(' ')) + ' "' + obj.url + '"';
}; };
Operation.prototype.encodePathCollection = function(type, name, value) { Operation.prototype.encodePathCollection = function(type, name, value) {
@@ -1223,12 +1501,12 @@ var Model = function(name, definition) {
}; };
Model.prototype.createJSONSample = function(modelsToIgnore) { Model.prototype.createJSONSample = function(modelsToIgnore) {
var i, result = {}; var i, result = {}, representations = {};
modelsToIgnore = (modelsToIgnore||{}); modelsToIgnore = (modelsToIgnore||{});
modelsToIgnore[this.name] = this; modelsToIgnore[this.name] = this;
for (i = 0; i < this.properties.length; i++) { for (i = 0; i < this.properties.length; i++) {
prop = this.properties[i]; prop = this.properties[i];
var sample = prop.getSampleValue(modelsToIgnore); var sample = prop.getSampleValue(modelsToIgnore, representations);
result[prop.name] = sample; result[prop.name] = sample;
} }
delete modelsToIgnore[this.name]; delete modelsToIgnore[this.name];
@@ -1236,10 +1514,10 @@ Model.prototype.createJSONSample = function(modelsToIgnore) {
}; };
Model.prototype.getSampleValue = function(modelsToIgnore) { Model.prototype.getSampleValue = function(modelsToIgnore) {
var i, obj = {}; var i, obj = {}, representations = {};
for(i = 0; i < this.properties.length; i++ ) { for(i = 0; i < this.properties.length; i++ ) {
var property = this.properties[i]; var property = this.properties[i];
obj[property.name] = property.sampleValue(false, modelsToIgnore); obj[property.name] = property.sampleValue(false, modelsToIgnore, representations);
} }
return obj; return obj;
}; };
@@ -1288,7 +1566,7 @@ var Property = function(name, obj, required) {
this.optional = true; this.optional = true;
this.optional = !required; this.optional = !required;
this.default = obj.default || null; this.default = obj.default || null;
this.example = obj.example || null; this.example = obj.example !== undefined ? obj.example : null;
this.collectionFormat = obj.collectionFormat || null; this.collectionFormat = obj.collectionFormat || null;
this.maximum = obj.maximum || null; this.maximum = obj.maximum || null;
this.exclusiveMaximum = obj.exclusiveMaximum || null; this.exclusiveMaximum = obj.exclusiveMaximum || null;
@@ -1304,8 +1582,8 @@ var Property = function(name, obj, required) {
this.multipleOf = obj.multipleOf || null; this.multipleOf = obj.multipleOf || null;
}; };
Property.prototype.getSampleValue = function (modelsToIgnore) { Property.prototype.getSampleValue = function (modelsToIgnore, representations) {
return this.sampleValue(false, modelsToIgnore); return this.sampleValue(false, modelsToIgnore, representations);
}; };
Property.prototype.isArray = function () { Property.prototype.isArray = function () {
@@ -1316,21 +1594,29 @@ Property.prototype.isArray = function () {
return false; return false;
}; };
Property.prototype.sampleValue = function(isArray, ignoredModels) { Property.prototype.sampleValue = function(isArray, ignoredModels, representations) {
isArray = (isArray || this.isArray()); isArray = (isArray || this.isArray());
ignoredModels = (ignoredModels || {}); ignoredModels = (ignoredModels || {});
// representations = (representations || {});
var type = getStringSignature(this.obj, true); var type = getStringSignature(this.obj, true);
var output; var output;
if(this.$ref) { if(this.$ref) {
var refModelName = simpleRef(this.$ref); var refModelName = simpleRef(this.$ref);
var refModel = models[refModelName]; var refModel = models[refModelName];
if(typeof representations[type] !== 'undefined') {
return representations[type];
}
else
if(refModel && typeof ignoredModels[type] === 'undefined') { if(refModel && typeof ignoredModels[type] === 'undefined') {
ignoredModels[type] = this; ignoredModels[type] = this;
output = refModel.getSampleValue(ignoredModels); output = refModel.getSampleValue(ignoredModels, representations);
representations[type] = output;
} }
else { else {
output = refModelName; output = (representations[type] || refModelName);
} }
} }
else if(this.example) else if(this.example)
@@ -1574,6 +1860,7 @@ SwaggerClient.prototype.buildFrom1_2Spec = function (response) {
res = new SwaggerResource(response, this); res = new SwaggerResource(response, this);
this.apis[newName] = res; this.apis[newName] = res;
this.apisArray.push(res); this.apisArray.push(res);
this.finish();
} else { } else {
var k; var k;
this.expectedResourceCount = response.apis.length; this.expectedResourceCount = response.apis.length;
@@ -1591,13 +1878,13 @@ SwaggerClient.prototype.buildFrom1_2Spec = function (response) {
SwaggerClient.prototype.finish = function() { SwaggerClient.prototype.finish = function() {
if (typeof this.success === 'function') { if (typeof this.success === 'function') {
this.isValid = true; this.isValid = true;
this.ready = true;
this.isBuilt = true; this.isBuilt = true;
this.selfReflect(); this.selfReflect();
this.success(); this.success();
} }
}; };
SwaggerClient.prototype.buildFrom1_1Spec = function (response) { SwaggerClient.prototype.buildFrom1_1Spec = function (response) {
log('This API is using a deprecated version of Swagger! Please see http://github.com/wordnik/swagger-core/wiki for more info'); 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) if (response.apiVersion !== null)
@@ -1629,7 +1916,9 @@ SwaggerClient.prototype.buildFrom1_1Spec = function (response) {
res = new SwaggerResource(response, this); res = new SwaggerResource(response, this);
this.apis[newName] = res; this.apis[newName] = res;
this.apisArray.push(res); this.apisArray.push(res);
this.finish();
} else { } else {
this.expectedResourceCount = response.apis.length;
for (k = 0; k < response.apis.length; k++) { for (k = 0; k < response.apis.length; k++) {
resource = response.apis[k]; resource = response.apis[k];
res = new SwaggerResource(resource, this); res = new SwaggerResource(resource, this);
@@ -1638,9 +1927,6 @@ SwaggerClient.prototype.buildFrom1_1Spec = function (response) {
} }
} }
this.isValid = true; this.isValid = true;
if (this.success) {
this.success();
}
return this; return this;
}; };
@@ -1662,16 +1948,18 @@ SwaggerClient.prototype.convertInfo = function (resp) {
}; };
SwaggerClient.prototype.selfReflect = function () { SwaggerClient.prototype.selfReflect = function () {
var resource, resource_name, ref; var resource, tag, ref;
if (this.apis === null) { if (this.apis === null) {
return false; return false;
} }
ref = this.apis; ref = this.apis;
for (resource_name in ref) { for (tag in ref) {
resource = ref[resource_name]; api = ref[tag];
if (resource.ready === null) { if (api.ready === null) {
return false; return false;
} }
this[tag] = api;
this[tag].help = __bind(api.help, api);
} }
this.setConsolidatedModels(); this.setConsolidatedModels();
this.ready = true; this.ready = true;
@@ -1707,7 +1995,6 @@ var SwaggerResource = function (resourceObj, api) {
this.description = resourceObj.description; this.description = resourceObj.description;
this.authorizations = (resourceObj.authorizations || {}); this.authorizations = (resourceObj.authorizations || {});
var parts = this.path.split('/'); var 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;
@@ -1729,7 +2016,7 @@ var SwaggerResource = function (resourceObj, api) {
} else { } else {
this.url = this.api.basePath + this.path.replace('{format}', 'json'); this.url = this.api.basePath + this.path.replace('{format}', 'json');
} }
this.api.progress('<span data-sw-translate>fetching resource</span> ' + this.name + ': ' + this.url); this.api.progress('fetching resource ' + this.name + ': ' + this.url);
var obj = { var obj = {
url: this.url, url: this.url,
method: 'GET', method: 'GET',
@@ -1745,8 +2032,8 @@ var SwaggerResource = function (resourceObj, api) {
}, },
error: function (response) { error: function (response) {
_this.api.resourceCount += 1; _this.api.resourceCount += 1;
return _this.api.fail('<span data-sw-translate>Unable to read api</span> \'' + return _this.api.fail('Unable to read api \'' +
_this.name + '\' <span data-sw-translate>from path</span> ' + _this.url + ' (<span data-sw-translate>server returned</span> ' + response.statusText + ')'); _this.name + '\' from path ' + _this.url + ' (server returned ' + response.statusText + ')');
} }
} }
}; };
@@ -1756,6 +2043,21 @@ var SwaggerResource = function (resourceObj, api) {
} }
}; };
SwaggerResource.prototype.help = function (dontPrint) {
var i;
var output = 'operations for the "' + this.name + '" tag';
for(i = 0; i < this.operationsArray.length; i++) {
var api = this.operationsArray[i];
output += '\n * ' + api.nickname + ': ' + api.description;
}
if(dontPrint)
return output;
else {
log(output);
return output;
}
};
SwaggerResource.prototype.getAbsoluteBasePath = function (relativeBasePath) { SwaggerResource.prototype.getAbsoluteBasePath = function (relativeBasePath) {
var pos, url; var pos, url;
url = this.api.basePath; url = this.api.basePath;
@@ -1787,7 +2089,7 @@ SwaggerResource.prototype.addApiDeclaration = function (response) {
if (typeof response.consumes === 'string') if (typeof response.consumes === 'string')
this.consumes = response.consumes; this.consumes = response.consumes;
if ((typeof response.basePath === 'string') && response.basePath.replace(/\s/g, '').length > 0) if ((typeof response.basePath === 'string') && response.basePath.replace(/\s/g, '').length > 0)
this.basePath = response.basePath.indexOf('http') === -1 ? this.getAbsoluteBasePath(response.basePath) : response.basePath; this.basePath = response.basePath.indexOf('http') !== 0 ? this.getAbsoluteBasePath(response.basePath) : response.basePath;
this.resourcePath = response.resourcePath; this.resourcePath = response.resourcePath;
this.addModels(response.models); this.addModels(response.models);
if (response.apis) { if (response.apis) {
@@ -2072,6 +2374,7 @@ var SwaggerOperation = function (nickname, path, method, parameters, summary, no
this.deprecated = deprecated; this.deprecated = deprecated;
this['do'] = __bind(this['do'], this); this['do'] = __bind(this['do'], this);
if(typeof this.deprecated === 'string') { if(typeof this.deprecated === 'string') {
switch(this.deprecated.toLowerCase()) { switch(this.deprecated.toLowerCase()) {
case 'true': case 'yes': case '1': { case 'true': case 'yes': case '1': {
@@ -2189,8 +2492,8 @@ var SwaggerOperation = function (nickname, path, method, parameters, summary, no
return _this['do'](arg1 || {}, arg2 || {}, arg3 || defaultSuccessCallback, arg4 || defaultErrorCallback); return _this['do'](arg1 || {}, arg2 || {}, arg3 || defaultSuccessCallback, arg4 || defaultErrorCallback);
}; };
this.resource[this.nickname].help = function () { this.resource[this.nickname].help = function (dontPrint) {
return _this.help(); return _this.help(dontPrint);
}; };
this.resource[this.nickname].asCurl = function (args) { this.resource[this.nickname].asCurl = function (args) {
return _this.asCurl(args); return _this.asCurl(args);
@@ -2357,7 +2660,7 @@ SwaggerOperation.prototype.urlify = function (args) {
if (param.paramType === 'path') { if (param.paramType === 'path') {
if (typeof args[param.name] !== 'undefined') { if (typeof args[param.name] !== 'undefined') {
// apply path params and remove from args // apply path params and remove from args
var reg = new RegExp('\\{\\s*?' + param.name + '.*?\\}(?=\\s*?(\\/?|$))', 'gi'); var reg = new RegExp('\\{\\s*?' + param.name + '[^\\{\\}\\/]*(?:\\{.*?\\}[^\\{\\}\\/]*)*\\}(?=(\\/?|$))', 'gi');
url = url.replace(reg, this.encodePathParam(args[param.name])); url = url.replace(reg, this.encodePathParam(args[param.name]));
delete args[param.name]; delete args[param.name];
} }
@@ -2429,16 +2732,19 @@ SwaggerOperation.prototype.getMatchingParams = function (paramTypes, args) {
return matchingParams; return matchingParams;
}; };
SwaggerOperation.prototype.help = function () { SwaggerOperation.prototype.help = function (dontPrint) {
var msg = ''; var msg = this.nickname + ': ' + this.summary;
var params = this.parameters; var params = this.parameters;
for (var i = 0; i < params.length; i++) { for (var i = 0; i < params.length; i++) {
var param = params[i]; var param = params[i];
if (msg !== '') msg += '\n* ' + param.name + (param.required ? ' (required)' : '') + " - " + param.description;
msg += '\n';
msg += '* ' + param.name + (param.required ? ' (required)' : '') + " - " + param.description;
} }
if(dontPrint)
return msg; return msg;
else {
console.log(msg);
return msg;
}
}; };
SwaggerOperation.prototype.asCurl = function (args) { SwaggerOperation.prototype.asCurl = function (args) {
@@ -2725,20 +3031,26 @@ SwaggerRequest.prototype.setHeaders = function (params, opts, operation) {
*/ */
var SwaggerHttp = function() {}; var SwaggerHttp = function() {};
SwaggerHttp.prototype.execute = function(obj) { SwaggerHttp.prototype.execute = function(obj, opts) {
if(obj && (typeof obj.useJQuery === 'boolean')) if(obj && (typeof obj.useJQuery === 'boolean'))
this.useJQuery = obj.useJQuery; this.useJQuery = obj.useJQuery;
else else
this.useJQuery = this.isIE8(); this.useJQuery = this.isIE8();
if(obj && typeof obj.body === 'object') { if(obj && typeof obj.body === 'object') {
if(obj.body.type && obj.body.type !== 'formData')
obj.body = JSON.stringify(obj.body); obj.body = JSON.stringify(obj.body);
else {
obj.contentType = false;
obj.processData = false;
delete obj.headers['Content-Type'];
}
} }
if(this.useJQuery) if(this.useJQuery)
return new JQueryHttpClient().execute(obj); return new JQueryHttpClient(opts).execute(obj);
else else
return new ShredHttpClient().execute(obj); return new ShredHttpClient(opts).execute(obj);
}; };
SwaggerHttp.prototype.isIE8 = function() { SwaggerHttp.prototype.isIE8 = function() {
@@ -2773,7 +3085,9 @@ JQueryHttpClient.prototype.execute = function(obj) {
obj.type = obj.method; obj.type = obj.method;
obj.cache = false; obj.cache = false;
delete obj.useJQuery;
/*
obj.beforeSend = function(xhr) { obj.beforeSend = function(xhr) {
var key, results; var key, results;
if (obj.headers) { if (obj.headers) {
@@ -2789,9 +3103,10 @@ JQueryHttpClient.prototype.execute = function(obj) {
} }
return results; return results;
} }
}; };*/
obj.data = obj.body; obj.data = obj.body;
delete obj.body;
obj.complete = function(response, textStatus, opts) { obj.complete = function(response, textStatus, opts) {
var headers = {}, var headers = {},
headerArray = response.getAllResponseHeaders().split("\n"); headerArray = response.getAllResponseHeaders().split("\n");
@@ -2815,6 +3130,7 @@ JQueryHttpClient.prototype.execute = function(obj) {
url: request.url, url: request.url,
method: request.method, method: request.method,
status: response.status, status: response.status,
statusText: response.statusText,
data: response.responseText, data: response.responseText,
headers: headers headers: headers
}; };
@@ -2846,8 +3162,8 @@ JQueryHttpClient.prototype.execute = function(obj) {
/* /*
* ShredHttpClient is a light-weight, node or browser HTTP client * ShredHttpClient is a light-weight, node or browser HTTP client
*/ */
var ShredHttpClient = function(options) { var ShredHttpClient = function(opts) {
this.options = (options||{}); this.opts = (opts||{});
this.isInitialized = false; this.isInitialized = false;
var identity, toString; var identity, toString;
@@ -2858,7 +3174,7 @@ var ShredHttpClient = function(options) {
} }
else else
this.Shred = require("shred"); this.Shred = require("shred");
this.shred = new this.Shred(options); this.shred = new this.Shred(opts);
}; };
ShredHttpClient.prototype.initShred = function () { ShredHttpClient.prototype.initShred = function () {
@@ -2964,7 +3280,7 @@ ShredHttpClient.prototype.execute = function(obj) {
var e = (typeof window !== 'undefined' ? window : exports); var e = (typeof window !== 'undefined' ? window : exports);
e.authorizations = new SwaggerAuthorizations(); e.authorizations = authorizations = new SwaggerAuthorizations();
e.ApiKeyAuthorization = ApiKeyAuthorization; e.ApiKeyAuthorization = ApiKeyAuthorization;
e.PasswordAuthorization = PasswordAuthorization; e.PasswordAuthorization = PasswordAuthorization;
e.CookieAuthorization = CookieAuthorization; e.CookieAuthorization = CookieAuthorization;
@@ -2973,5 +3289,5 @@ e.SwaggerApi = SwaggerClient;
e.Operation = Operation; e.Operation = Operation;
e.Model = Model; e.Model = Model;
e.addModel = addModel; e.addModel = addModel;
e.Resolver = Resolver;
})(); })();

358
dist/swagger-ui.js vendored
View File

@@ -1,18 +1,11 @@
/** /**
* swagger-ui - Swagger UI is a dependency-free collection of HTML, Javascript, and CSS assets that dynamically generate beautiful documentation from a Swagger-compliant API * swagger-ui - Swagger UI is a dependency-free collection of HTML, Javascript, and CSS assets that dynamically generate beautiful documentation from a Swagger-compliant API
* @version v2.1.4-M1 * @version v2.1.5-M1
* @link http://swagger.io * @link http://swagger.io
* @license Apache 2.0 * @license Apache 2.0
*/ */
// ругается
if (typeof marked === 'undefined') {
marked = function(text) {
return text;
}
}
$(function() { $(function() {
// Helper function for vertically aligning DOM elements // Helper function for vertically aligning DOM elements
// http://www.seodenver.com/simple-vertical-align-plugin-for-jquery/ // http://www.seodenver.com/simple-vertical-align-plugin-for-jquery/
$.fn.vAlign = function() { $.fn.vAlign = function() {
@@ -291,7 +284,6 @@ SwaggerUi = (function(_super) {
} }
this.options.url = url; this.options.url = url;
this.headerView.update(url); this.headerView.update(url);
return this.api = new SwaggerClient(this.options); return this.api = new SwaggerClient(this.options);
}; };
@@ -308,7 +300,7 @@ SwaggerUi = (function(_super) {
}; };
SwaggerUi.prototype.render = function() { SwaggerUi.prototype.render = function() {
this.showMessage('<span data-swTranslator="1">Finished Loading Resource Information. Rendering Swagger UI</span>...'); this.showMessage('Finished Loading Resource Information. Rendering Swagger UI...');
this.mainView = new MainView({ this.mainView = new MainView({
model: this.api, model: this.api,
el: $('#' + this.dom_id), el: $('#' + this.dom_id),
@@ -323,11 +315,6 @@ SwaggerUi = (function(_super) {
this.listAll(); this.listAll();
} }
this.renderGFM(); this.renderGFM();
if (typeof SwaggerTranslator != 'undefined') {
SwaggerTranslator.translate();
}
if (this.options.onComplete) { if (this.options.onComplete) {
this.options.onComplete(this.api, this); this.options.onComplete(this.api, this);
} }
@@ -335,7 +322,7 @@ SwaggerUi = (function(_super) {
return function() { return function() {
return Docs.shebang(); return Docs.shebang();
}; };
})(this), 4000); })(this), 100);
}; };
SwaggerUi.prototype.buildUrl = function(base, url) { SwaggerUi.prototype.buildUrl = function(base, url) {
@@ -366,14 +353,7 @@ SwaggerUi = (function(_super) {
} }
$('#message-bar').removeClass('message-fail'); $('#message-bar').removeClass('message-fail');
$('#message-bar').addClass('message-success'); $('#message-bar').addClass('message-success');
return $('#message-bar').html(data);
var result = $('#message-bar').html(data);
if (typeof SwaggerTranslator != 'undefined') {
SwaggerTranslator.translate();
}
return result;
}; };
SwaggerUi.prototype.onLoadFailure = function(data) { SwaggerUi.prototype.onLoadFailure = function(data) {
@@ -387,12 +367,6 @@ SwaggerUi = (function(_super) {
if (this.options.onFailure != null) { if (this.options.onFailure != null) {
this.options.onFailure(data); this.options.onFailure(data);
} }
if (typeof SwaggerTranslator != 'undefined') {
SwaggerTranslator.translate();
}
return val; return val;
}; };
@@ -419,14 +393,14 @@ this["Handlebars"]["templates"]["apikey_button_view"] = Handlebars.template({"co
+ escapeExpression(((helper = (helper = helpers.keyName || (depth0 != null ? depth0.keyName : depth0)) != null ? helper : helperMissing),(typeof helper === functionType ? helper.call(depth0, {"name":"keyName","hash":{},"data":data}) : helper))) + escapeExpression(((helper = (helper = helpers.keyName || (depth0 != null ? depth0.keyName : depth0)) != null ? helper : helperMissing),(typeof helper === functionType ? helper.call(depth0, {"name":"keyName","hash":{},"data":data}) : helper)))
+ "</div>\n <input placeholder=\"api_key\" class=\"auth_input\" id=\"input_apiKey_entry\" name=\"apiKey\" type=\"text\"/>\n <div class='auth_submit'><a class='auth_submit_button' id=\"apply_api_key\" href=\"#\">apply</a></div>\n </div>\n</div>\n\n"; + "</div>\n <input placeholder=\"api_key\" class=\"auth_input\" id=\"input_apiKey_entry\" name=\"apiKey\" type=\"text\"/>\n <div class='auth_submit'><a class='auth_submit_button' id=\"apply_api_key\" href=\"#\">apply</a></div>\n </div>\n</div>\n\n";
},"useData":true}); },"useData":true});
this["Handlebars"]["templates"]["basic_auth_button_view"] = Handlebars.template({"compiler":[6,">= 2.0.0-beta.1"],"main":function(depth0,helpers,partials,data) {
return "<div class='auth_button' id='basic_auth_button'><img class='auth_icon' src='images/password.jpeg'></div>\n<div class='auth_container' id='basic_auth_container'>\n <div class='key_input_container'>\n <div class=\"auth_label\">Username</div>\n <input placeholder=\"username\" class=\"auth_input\" id=\"input_username\" name=\"username\" type=\"text\"/>\n <div class=\"auth_label\">Password</div>\n <input placeholder=\"password\" class=\"auth_input\" id=\"input_password\" name=\"password\" type=\"password\"/>\n <div class='auth_submit'><a class='auth_submit_button' id=\"apply_basic_auth\" href=\"#\">apply</a></div>\n </div>\n</div>\n\n";
},"useData":true});
Handlebars.registerHelper('sanitize', function(html) { Handlebars.registerHelper('sanitize', function(html) {
html = html.replace(/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi, ''); html = html.replace(/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi, '');
return new Handlebars.SafeString(html); return new Handlebars.SafeString(html);
}); });
this["Handlebars"]["templates"]["basic_auth_button_view"] = Handlebars.template({"compiler":[6,">= 2.0.0-beta.1"],"main":function(depth0,helpers,partials,data) {
return "<div class='auth_button' id='basic_auth_button'><img class='auth_icon' src='images/password.jpeg'></div>\n<div class='auth_container' id='basic_auth_container'>\n <div class='key_input_container'>\n <div class=\"auth_label\" data-sw-translate>Username</div>\n <input placeholder=\"username\" class=\"auth_input\" id=\"input_username\" name=\"username\" type=\"text\"/>\n <div class=\"auth_label\" data-sw-translate>Password</div>\n <input placeholder=\"password\" class=\"auth_input\" id=\"input_password\" name=\"password\" type=\"password\"/>\n <div class='auth_submit'><a class='auth_submit_button' id=\"apply_basic_auth\" href=\"#\" data-sw-translate>apply</a></div>\n </div>\n</div>\n\n";
},"useData":true});
var ApiKeyButton, var ApiKeyButton,
__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; },
__hasProp = {}.hasOwnProperty; __hasProp = {}.hasOwnProperty;
@@ -556,8 +530,6 @@ BasicAuthButton = (function(_super) {
})(Backbone.View); })(Backbone.View);
this["Handlebars"]["templates"]["main"] = Handlebars.template({"1":function(depth0,helpers,partials,data) { this["Handlebars"]["templates"]["main"] = Handlebars.template({"1":function(depth0,helpers,partials,data) {
var stack1, lambda=this.lambda, escapeExpression=this.escapeExpression, buffer = " <div class=\"info_title\">" var stack1, lambda=this.lambda, escapeExpression=this.escapeExpression, buffer = " <div class=\"info_title\">"
+ escapeExpression(lambda(((stack1 = (depth0 != null ? depth0.info : depth0)) != null ? stack1.title : stack1), depth0)) + escapeExpression(lambda(((stack1 = (depth0 != null ? depth0.info : depth0)) != null ? stack1.title : stack1), depth0))
@@ -584,15 +556,15 @@ this["Handlebars"]["templates"]["main"] = Handlebars.template({"1":function(dept
var stack1, lambda=this.lambda, escapeExpression=this.escapeExpression; var stack1, lambda=this.lambda, escapeExpression=this.escapeExpression;
return "<div class=\"info_tos\"><a href=\"" return "<div class=\"info_tos\"><a href=\""
+ escapeExpression(lambda(((stack1 = (depth0 != null ? depth0.info : depth0)) != null ? stack1.termsOfServiceUrl : stack1), depth0)) + escapeExpression(lambda(((stack1 = (depth0 != null ? depth0.info : depth0)) != null ? stack1.termsOfServiceUrl : stack1), depth0))
+ "\" data-sw-translate>Terms of service</a></div>"; + "\">Terms of service</a></div>";
},"4":function(depth0,helpers,partials,data) { },"4":function(depth0,helpers,partials,data) {
var stack1, lambda=this.lambda, escapeExpression=this.escapeExpression; var stack1, lambda=this.lambda, escapeExpression=this.escapeExpression;
return "<div class='info_name'><span data-sw-translate>Created by</span> " return "<div class='info_name'>Created by "
+ escapeExpression(lambda(((stack1 = ((stack1 = (depth0 != null ? depth0.info : depth0)) != null ? stack1.contact : stack1)) != null ? stack1.name : stack1), depth0)) + escapeExpression(lambda(((stack1 = ((stack1 = (depth0 != null ? depth0.info : depth0)) != null ? stack1.contact : stack1)) != null ? stack1.name : stack1), depth0))
+ "</div>"; + "</div>";
},"6":function(depth0,helpers,partials,data) { },"6":function(depth0,helpers,partials,data) {
var stack1, lambda=this.lambda, escapeExpression=this.escapeExpression; var stack1, lambda=this.lambda, escapeExpression=this.escapeExpression;
return "<div class='info_url'><span data-sw-translate>See more at</span> <a href=\"" return "<div class='info_url'>See more at <a href=\""
+ escapeExpression(lambda(((stack1 = ((stack1 = (depth0 != null ? depth0.info : depth0)) != null ? stack1.contact : stack1)) != null ? stack1.url : stack1), depth0)) + escapeExpression(lambda(((stack1 = ((stack1 = (depth0 != null ? depth0.info : depth0)) != null ? stack1.contact : stack1)) != null ? stack1.url : stack1), depth0))
+ "\">" + "\">"
+ escapeExpression(lambda(((stack1 = ((stack1 = (depth0 != null ? depth0.info : depth0)) != null ? stack1.contact : stack1)) != null ? stack1.url : stack1), depth0)) + escapeExpression(lambda(((stack1 = ((stack1 = (depth0 != null ? depth0.info : depth0)) != null ? stack1.contact : stack1)) != null ? stack1.url : stack1), depth0))
@@ -603,7 +575,7 @@ this["Handlebars"]["templates"]["main"] = Handlebars.template({"1":function(dept
+ escapeExpression(lambda(((stack1 = ((stack1 = (depth0 != null ? depth0.info : depth0)) != null ? stack1.contact : stack1)) != null ? stack1.email : stack1), depth0)) + escapeExpression(lambda(((stack1 = ((stack1 = (depth0 != null ? depth0.info : depth0)) != null ? stack1.contact : stack1)) != null ? stack1.email : stack1), depth0))
+ "?subject=" + "?subject="
+ escapeExpression(lambda(((stack1 = (depth0 != null ? depth0.info : depth0)) != null ? stack1.title : stack1), depth0)) + escapeExpression(lambda(((stack1 = (depth0 != null ? depth0.info : depth0)) != null ? stack1.title : stack1), depth0))
+ "\" data-sw-translate>Contact the developer</a></div>"; + "\">Contact the developer</a></div>";
},"10":function(depth0,helpers,partials,data) { },"10":function(depth0,helpers,partials,data) {
var stack1, lambda=this.lambda, escapeExpression=this.escapeExpression; var stack1, lambda=this.lambda, escapeExpression=this.escapeExpression;
return "<div class='info_license'><a href='" return "<div class='info_license'><a href='"
@@ -613,7 +585,7 @@ this["Handlebars"]["templates"]["main"] = Handlebars.template({"1":function(dept
+ "</a></div>"; + "</a></div>";
},"12":function(depth0,helpers,partials,data) { },"12":function(depth0,helpers,partials,data) {
var stack1, lambda=this.lambda, escapeExpression=this.escapeExpression; var stack1, lambda=this.lambda, escapeExpression=this.escapeExpression;
return " , <span style=\"font-variant: small-caps\" data-sw-translate>api version</span>: " return " , <span style=\"font-variant: small-caps\">api version</span>: "
+ escapeExpression(lambda(((stack1 = (depth0 != null ? depth0.info : depth0)) != null ? stack1.version : stack1), depth0)) + escapeExpression(lambda(((stack1 = (depth0 != null ? depth0.info : depth0)) != null ? stack1.version : stack1), depth0))
+ "\n "; + "\n ";
},"14":function(depth0,helpers,partials,data) { },"14":function(depth0,helpers,partials,data) {
@@ -631,7 +603,7 @@ this["Handlebars"]["templates"]["main"] = Handlebars.template({"1":function(dept
var stack1, helper, functionType="function", helperMissing=helpers.helperMissing, escapeExpression=this.escapeExpression, buffer = "<div class='info' id='api_info'>\n"; var stack1, helper, functionType="function", helperMissing=helpers.helperMissing, escapeExpression=this.escapeExpression, buffer = "<div class='info' id='api_info'>\n";
stack1 = helpers['if'].call(depth0, (depth0 != null ? depth0.info : depth0), {"name":"if","hash":{},"fn":this.program(1, data),"inverse":this.noop,"data":data}); stack1 = helpers['if'].call(depth0, (depth0 != null ? depth0.info : depth0), {"name":"if","hash":{},"fn":this.program(1, data),"inverse":this.noop,"data":data});
if (stack1 != null) { buffer += stack1; } if (stack1 != null) { buffer += stack1; }
buffer += "</div>\n<div class='container' id='resources_container'>\n <ul id='resources'></ul>\n\n <div class=\"footer\">\n <br>\n <br>\n <h4 style=\"color: #999\">[ <span style=\"font-variant: small-caps\" data-sw-translate>base url</span>: " buffer += "</div>\n<div class='container' id='resources_container'>\n <ul id='resources'></ul>\n\n <div class=\"footer\">\n <br>\n <br>\n <h4 style=\"color: #999\">[ <span style=\"font-variant: small-caps\">base url</span>: "
+ escapeExpression(((helper = (helper = helpers.basePath || (depth0 != null ? depth0.basePath : depth0)) != null ? helper : helperMissing),(typeof helper === functionType ? helper.call(depth0, {"name":"basePath","hash":{},"data":data}) : helper))) + escapeExpression(((helper = (helper = helpers.basePath || (depth0 != null ? depth0.basePath : depth0)) != null ? helper : helperMissing),(typeof helper === functionType ? helper.call(depth0, {"name":"basePath","hash":{},"data":data}) : helper)))
+ "\n"; + "\n";
stack1 = helpers['if'].call(depth0, ((stack1 = (depth0 != null ? depth0.info : depth0)) != null ? stack1.version : stack1), {"name":"if","hash":{},"fn":this.program(12, data),"inverse":this.noop,"data":data}); stack1 = helpers['if'].call(depth0, ((stack1 = (depth0 != null ? depth0.info : depth0)) != null ? stack1.version : stack1), {"name":"if","hash":{},"fn":this.program(12, data),"inverse":this.noop,"data":data});
@@ -673,9 +645,9 @@ ContentTypeView = (function(_super) {
this["Handlebars"]["templates"]["operation"] = Handlebars.template({"1":function(depth0,helpers,partials,data) { this["Handlebars"]["templates"]["operation"] = Handlebars.template({"1":function(depth0,helpers,partials,data) {
return "deprecated"; return "deprecated";
},"3":function(depth0,helpers,partials,data) { },"3":function(depth0,helpers,partials,data) {
return " <h4 data-sw-translate>Warning: Deprecated</h4>\n"; return " <h4>Warning: Deprecated</h4>\n";
},"5":function(depth0,helpers,partials,data) { },"5":function(depth0,helpers,partials,data) {
var stack1, helper, functionType="function", helperMissing=helpers.helperMissing, buffer = " <h4 data-sw-translate>Implementation Notes</h4>\n <p class=\"markdown\">"; var stack1, helper, functionType="function", helperMissing=helpers.helperMissing, buffer = " <h4>Implementation Notes</h4>\n <p class=\"markdown\">";
stack1 = ((helper = (helper = helpers.description || (depth0 != null ? depth0.description : depth0)) != null ? helper : helperMissing),(typeof helper === functionType ? helper.call(depth0, {"name":"description","hash":{},"data":data}) : helper)); stack1 = ((helper = (helper = helpers.description || (depth0 != null ? depth0.description : depth0)) != null ? helper : helperMissing),(typeof helper === functionType ? helper.call(depth0, {"name":"description","hash":{},"data":data}) : helper));
if (stack1 != null) { buffer += stack1; } if (stack1 != null) { buffer += stack1; }
return buffer + "</p>\n"; return buffer + "</p>\n";
@@ -699,17 +671,17 @@ this["Handlebars"]["templates"]["operation"] = Handlebars.template({"1":function
return " <div class='access'>\n <span class=\"api-ic ic-off\" title=\"click to authenticate\"></span>\n </div>\n"; return " <div class='access'>\n <span class=\"api-ic ic-off\" title=\"click to authenticate\"></span>\n </div>\n";
},"16":function(depth0,helpers,partials,data) { },"16":function(depth0,helpers,partials,data) {
var helper, functionType="function", helperMissing=helpers.helperMissing, escapeExpression=this.escapeExpression; var helper, functionType="function", helperMissing=helpers.helperMissing, escapeExpression=this.escapeExpression;
return " <h4><span data-sw-translate>Response Class</span> (Status " return " <h4>Response Class (Status "
+ escapeExpression(((helper = (helper = helpers.successCode || (depth0 != null ? depth0.successCode : depth0)) != null ? helper : helperMissing),(typeof helper === functionType ? helper.call(depth0, {"name":"successCode","hash":{},"data":data}) : helper))) + escapeExpression(((helper = (helper = helpers.successCode || (depth0 != null ? depth0.successCode : depth0)) != null ? helper : helperMissing),(typeof helper === functionType ? helper.call(depth0, {"name":"successCode","hash":{},"data":data}) : helper)))
+ ")</h4>\n <p><span class=\"model-signature\" /></p>\n <br/>\n <div class=\"response-content-type\" />\n"; + ")</h4>\n <p><span class=\"model-signature\" /></p>\n <br/>\n <div class=\"response-content-type\" />\n";
},"18":function(depth0,helpers,partials,data) { },"18":function(depth0,helpers,partials,data) {
return " <h4 data-sw-translate>Parameters</h4>\n <table class='fullwidth'>\n <thead>\n <tr>\n <th style=\"width: 100px; max-width: 100px\" data-sw-translate>Parameter</th>\n <th style=\"width: 310px; max-width: 310px\" data-sw-translate>Value</th>\n <th style=\"width: 200px; max-width: 200px\" data-sw-translate>Description</th>\n <th style=\"width: 100px; max-width: 100px\" data-sw-translate>Parameter Type</th>\n <th style=\"width: 220px; max-width: 230px\" data-sw-translate>Data Type</th>\n </tr>\n </thead>\n <tbody class=\"operation-params\">\n\n </tbody>\n </table>\n"; return " <h4>Parameters</h4>\n <table class='fullwidth'>\n <thead>\n <tr>\n <th style=\"width: 100px; max-width: 100px\">Parameter</th>\n <th style=\"width: 310px; max-width: 310px\">Value</th>\n <th style=\"width: 200px; max-width: 200px\">Description</th>\n <th style=\"width: 100px; max-width: 100px\">Parameter Type</th>\n <th style=\"width: 220px; max-width: 230px\">Data Type</th>\n </tr>\n </thead>\n <tbody class=\"operation-params\">\n\n </tbody>\n </table>\n";
},"20":function(depth0,helpers,partials,data) { },"20":function(depth0,helpers,partials,data) {
return " <div style='margin:0;padding:0;display:inline'></div>\n <h4 data-sw-translate>Response Messages</h4>\n <table class='fullwidth'>\n <thead>\n <tr>\n <th data-sw-translate>HTTP Status Code</th>\n <th data-sw-translate>Reason</th>\n <th data-sw-translate>Response Model</th>\n </tr>\n </thead>\n <tbody class=\"operation-status\">\n \n </tbody>\n </table>\n"; return " <div style='margin:0;padding:0;display:inline'></div>\n <h4>Response Messages</h4>\n <table class='fullwidth'>\n <thead>\n <tr>\n <th>HTTP Status Code</th>\n <th>Reason</th>\n <th>Response Model</th>\n </tr>\n </thead>\n <tbody class=\"operation-status\">\n \n </tbody>\n </table>\n";
},"22":function(depth0,helpers,partials,data) { },"22":function(depth0,helpers,partials,data) {
return ""; return "";
},"24":function(depth0,helpers,partials,data) { },"24":function(depth0,helpers,partials,data) {
return " <div class='sandbox_header'>\n <input class='submit' name='commit' type='button' data-sw-translate value='Try it out!' />\n <a href='#' class='response_hider' style='display:none' data-sw-translate>Hide Response</a>\n <span class='response_throbber' style='display:none'></span>\n </div>\n"; return " <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 <span class='response_throbber' style='display:none'></span>\n </div>\n";
},"compiler":[6,">= 2.0.0-beta.1"],"main":function(depth0,helpers,partials,data) { },"compiler":[6,">= 2.0.0-beta.1"],"main":function(depth0,helpers,partials,data) {
var stack1, helper, options, functionType="function", helperMissing=helpers.helperMissing, escapeExpression=this.escapeExpression, blockHelperMissing=helpers.blockHelperMissing, buffer = "\n <ul class='operations' >\n <li class='" var stack1, helper, options, functionType="function", helperMissing=helpers.helperMissing, escapeExpression=this.escapeExpression, blockHelperMissing=helpers.blockHelperMissing, buffer = "\n <ul class='operations' >\n <li class='"
+ escapeExpression(((helper = (helper = helpers.method || (depth0 != null ? depth0.method : depth0)) != null ? helper : helperMissing),(typeof helper === functionType ? helper.call(depth0, {"name":"method","hash":{},"data":data}) : helper))) + escapeExpression(((helper = (helper = helpers.method || (depth0 != null ? depth0.method : depth0)) != null ? helper : helperMissing),(typeof helper === functionType ? helper.call(depth0, {"name":"method","hash":{},"data":data}) : helper)))
@@ -771,7 +743,7 @@ this["Handlebars"]["templates"]["operation"] = Handlebars.template({"1":function
if (stack1 != null) { buffer += stack1; } if (stack1 != null) { buffer += stack1; }
stack1 = helpers['if'].call(depth0, (depth0 != null ? depth0.isReadOnly : depth0), {"name":"if","hash":{},"fn":this.program(22, data),"inverse":this.program(24, data),"data":data}); stack1 = helpers['if'].call(depth0, (depth0 != null ? depth0.isReadOnly : depth0), {"name":"if","hash":{},"fn":this.program(22, data),"inverse":this.program(24, data),"data":data});
if (stack1 != null) { buffer += stack1; } if (stack1 != null) { buffer += stack1; }
return buffer + " </form>\n <div class='response' style='display:none'>\n <h4 data-sw-translate>Request URL</h4>\n <div class='block request_url'></div>\n <h4 data-sw-translate>Response Body</h4>\n <div class='block response_body'></div>\n <h4 data-sw-translate>Response Code</h4>\n <div class='block response_code'></div>\n <h4 data-sw-translate>Response Headers</h4>\n <div class='block response_headers'></div>\n </div>\n </div>\n </li>\n </ul>\n"; return buffer + " </form>\n <div class='response' style='display:none'>\n <h4>Request URL</h4>\n <div class='block request_url'></div>\n <h4>Response Body</h4>\n <div class='block response_body'></div>\n <h4>Response Code</h4>\n <div class='block response_code'></div>\n <h4>Response Headers</h4>\n <div class='block response_headers'></div>\n </div>\n </div>\n </li>\n </ul>\n";
},"useData":true}); },"useData":true});
var HeaderView, var HeaderView,
__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; },
@@ -1635,7 +1607,7 @@ OperationView = (function(_super) {
json = JSON.stringify(JSON.parse(content), null, " "); json = JSON.stringify(JSON.parse(content), null, " ");
} catch (_error) { } catch (_error) {
e = _error; e = _error;
json = "<span data-sw-translate>can't parse JSON. Raw result</span>:\n\n" + content; json = "can't parse JSON. Raw result:\n\n" + content;
} }
code = $('<code />').text(json); code = $('<code />').text(json);
pre = $('<pre class="json" />').append(code); pre = $('<pre class="json" />').append(code);
@@ -1778,6 +1750,74 @@ this["Handlebars"]["templates"]["param_readonly_required"] = Handlebars.template
if (stack1 != null) { buffer += stack1; } if (stack1 != null) { buffer += stack1; }
return buffer + "</td>\n<td><span class=\"model-signature\"></span></td>\n"; return buffer + "</td>\n<td><span class=\"model-signature\"></span></td>\n";
},"useData":true}); },"useData":true});
this["Handlebars"]["templates"]["param_required"] = Handlebars.template({"1":function(depth0,helpers,partials,data) {
var stack1, buffer = "";
stack1 = helpers['if'].call(depth0, (depth0 != null ? depth0.isFile : depth0), {"name":"if","hash":{},"fn":this.program(2, data),"inverse":this.program(4, data),"data":data});
if (stack1 != null) { buffer += stack1; }
return buffer;
},"2":function(depth0,helpers,partials,data) {
var helper, functionType="function", helperMissing=helpers.helperMissing, escapeExpression=this.escapeExpression;
return " <input type=\"file\" name='"
+ escapeExpression(((helper = (helper = helpers.name || (depth0 != null ? depth0.name : depth0)) != null ? helper : helperMissing),(typeof helper === functionType ? helper.call(depth0, {"name":"name","hash":{},"data":data}) : helper)))
+ "'/>\n";
},"4":function(depth0,helpers,partials,data) {
var stack1, buffer = "";
stack1 = helpers['if'].call(depth0, (depth0 != null ? depth0['default'] : depth0), {"name":"if","hash":{},"fn":this.program(5, data),"inverse":this.program(7, data),"data":data});
if (stack1 != null) { buffer += stack1; }
return buffer;
},"5":function(depth0,helpers,partials,data) {
var helper, functionType="function", helperMissing=helpers.helperMissing, escapeExpression=this.escapeExpression;
return " <textarea class='body-textarea required' placeholder='(required)' name='"
+ escapeExpression(((helper = (helper = helpers.name || (depth0 != null ? depth0.name : depth0)) != null ? helper : helperMissing),(typeof helper === functionType ? helper.call(depth0, {"name":"name","hash":{},"data":data}) : helper)))
+ "'>"
+ escapeExpression(((helper = (helper = helpers['default'] || (depth0 != null ? depth0['default'] : depth0)) != null ? helper : helperMissing),(typeof helper === functionType ? helper.call(depth0, {"name":"default","hash":{},"data":data}) : helper)))
+ "</textarea>\n <br />\n <div class=\"parameter-content-type\" />\n";
},"7":function(depth0,helpers,partials,data) {
var helper, functionType="function", helperMissing=helpers.helperMissing, escapeExpression=this.escapeExpression;
return " <textarea class='body-textarea required' placeholder='(required)' name='"
+ escapeExpression(((helper = (helper = helpers.name || (depth0 != null ? depth0.name : depth0)) != null ? helper : helperMissing),(typeof helper === functionType ? helper.call(depth0, {"name":"name","hash":{},"data":data}) : helper)))
+ "'></textarea>\n <br />\n <div class=\"parameter-content-type\" />\n";
},"9":function(depth0,helpers,partials,data) {
var stack1, buffer = "";
stack1 = helpers['if'].call(depth0, (depth0 != null ? depth0.isFile : depth0), {"name":"if","hash":{},"fn":this.program(10, data),"inverse":this.program(12, data),"data":data});
if (stack1 != null) { buffer += stack1; }
return buffer;
},"10":function(depth0,helpers,partials,data) {
var helper, functionType="function", helperMissing=helpers.helperMissing, escapeExpression=this.escapeExpression;
return " <input class='parameter' class='required' type='file' name='"
+ escapeExpression(((helper = (helper = helpers.name || (depth0 != null ? depth0.name : depth0)) != null ? helper : helperMissing),(typeof helper === functionType ? helper.call(depth0, {"name":"name","hash":{},"data":data}) : helper)))
+ "'/>\n";
},"12":function(depth0,helpers,partials,data) {
var stack1, buffer = "";
stack1 = helpers['if'].call(depth0, (depth0 != null ? depth0['default'] : depth0), {"name":"if","hash":{},"fn":this.program(13, data),"inverse":this.program(15, data),"data":data});
if (stack1 != null) { buffer += stack1; }
return buffer;
},"13":function(depth0,helpers,partials,data) {
var helper, functionType="function", helperMissing=helpers.helperMissing, escapeExpression=this.escapeExpression;
return " <input class='parameter required' minlength='1' name='"
+ escapeExpression(((helper = (helper = helpers.name || (depth0 != null ? depth0.name : depth0)) != null ? helper : helperMissing),(typeof helper === functionType ? helper.call(depth0, {"name":"name","hash":{},"data":data}) : helper)))
+ "' placeholder='(required)' type='text' value='"
+ escapeExpression(((helper = (helper = helpers['default'] || (depth0 != null ? depth0['default'] : depth0)) != null ? helper : helperMissing),(typeof helper === functionType ? helper.call(depth0, {"name":"default","hash":{},"data":data}) : helper)))
+ "'/>\n";
},"15":function(depth0,helpers,partials,data) {
var helper, functionType="function", helperMissing=helpers.helperMissing, escapeExpression=this.escapeExpression;
return " <input class='parameter required' minlength='1' name='"
+ escapeExpression(((helper = (helper = helpers.name || (depth0 != null ? depth0.name : depth0)) != null ? helper : helperMissing),(typeof helper === functionType ? helper.call(depth0, {"name":"name","hash":{},"data":data}) : helper)))
+ "' placeholder='(required)' type='text' value=''/>\n";
},"compiler":[6,">= 2.0.0-beta.1"],"main":function(depth0,helpers,partials,data) {
var stack1, helper, functionType="function", helperMissing=helpers.helperMissing, escapeExpression=this.escapeExpression, buffer = "<td class='code required'>"
+ escapeExpression(((helper = (helper = helpers.name || (depth0 != null ? depth0.name : depth0)) != null ? helper : helperMissing),(typeof helper === functionType ? helper.call(depth0, {"name":"name","hash":{},"data":data}) : helper)))
+ "</td>\n<td>\n";
stack1 = helpers['if'].call(depth0, (depth0 != null ? depth0.isBody : depth0), {"name":"if","hash":{},"fn":this.program(1, data),"inverse":this.program(9, data),"data":data});
if (stack1 != null) { buffer += stack1; }
buffer += "</td>\n<td>\n <strong><span class=\"markdown\">";
stack1 = ((helper = (helper = helpers.description || (depth0 != null ? depth0.description : depth0)) != null ? helper : helperMissing),(typeof helper === functionType ? helper.call(depth0, {"name":"description","hash":{},"data":data}) : helper));
if (stack1 != null) { buffer += stack1; }
buffer += "</span></strong>\n</td>\n<td>";
stack1 = ((helper = (helper = helpers.paramType || (depth0 != null ? depth0.paramType : depth0)) != null ? helper : helperMissing),(typeof helper === functionType ? helper.call(depth0, {"name":"paramType","hash":{},"data":data}) : helper));
if (stack1 != null) { buffer += stack1; }
return buffer + "</td>\n<td><span class=\"model-signature\"></span></td>\n";
},"useData":true});
var ParameterView, var ParameterView,
__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; },
__hasProp = {}.hasOwnProperty; __hasProp = {}.hasOwnProperty;
@@ -1887,73 +1927,26 @@ ParameterView = (function(_super) {
})(Backbone.View); })(Backbone.View);
this["Handlebars"]["templates"]["param_required"] = Handlebars.template({"1":function(depth0,helpers,partials,data) { this["Handlebars"]["templates"]["parameter_content_type"] = Handlebars.template({"1":function(depth0,helpers,partials,data) {
var stack1, buffer = ""; var stack1, buffer = "";
stack1 = helpers['if'].call(depth0, (depth0 != null ? depth0.isFile : depth0), {"name":"if","hash":{},"fn":this.program(2, data),"inverse":this.program(4, data),"data":data}); stack1 = helpers.each.call(depth0, (depth0 != null ? depth0.consumes : depth0), {"name":"each","hash":{},"fn":this.program(2, data),"inverse":this.noop,"data":data});
if (stack1 != null) { buffer += stack1; } if (stack1 != null) { buffer += stack1; }
return buffer; return buffer;
},"2":function(depth0,helpers,partials,data) { },"2":function(depth0,helpers,partials,data) {
var helper, functionType="function", helperMissing=helpers.helperMissing, escapeExpression=this.escapeExpression; var stack1, lambda=this.lambda, buffer = " <option value=\"";
return " <input type=\"file\" name='" stack1 = lambda(depth0, depth0);
+ escapeExpression(((helper = (helper = helpers.name || (depth0 != null ? depth0.name : depth0)) != null ? helper : helperMissing),(typeof helper === functionType ? helper.call(depth0, {"name":"name","hash":{},"data":data}) : helper))) if (stack1 != null) { buffer += stack1; }
+ "'/>\n"; buffer += "\">";
stack1 = lambda(depth0, depth0);
if (stack1 != null) { buffer += stack1; }
return buffer + "</option>\n";
},"4":function(depth0,helpers,partials,data) { },"4":function(depth0,helpers,partials,data) {
var stack1, buffer = ""; return " <option value=\"application/json\">application/json</option>\n";
stack1 = helpers['if'].call(depth0, (depth0 != null ? depth0['default'] : depth0), {"name":"if","hash":{},"fn":this.program(5, data),"inverse":this.program(7, data),"data":data}); },"compiler":[6,">= 2.0.0-beta.1"],"main":function(depth0,helpers,partials,data) {
var stack1, buffer = "<label for=\"parameterContentType\"></label>\n<select name=\"parameterContentType\">\n";
stack1 = helpers['if'].call(depth0, (depth0 != null ? depth0.consumes : depth0), {"name":"if","hash":{},"fn":this.program(1, data),"inverse":this.program(4, data),"data":data});
if (stack1 != null) { buffer += stack1; } if (stack1 != null) { buffer += stack1; }
return buffer; return buffer + "</select>\n";
},"5":function(depth0,helpers,partials,data) {
var helper, functionType="function", helperMissing=helpers.helperMissing, escapeExpression=this.escapeExpression;
return " <textarea class='body-textarea required' placeholder='(required)' name='"
+ escapeExpression(((helper = (helper = helpers.name || (depth0 != null ? depth0.name : depth0)) != null ? helper : helperMissing),(typeof helper === functionType ? helper.call(depth0, {"name":"name","hash":{},"data":data}) : helper)))
+ "'>"
+ escapeExpression(((helper = (helper = helpers['default'] || (depth0 != null ? depth0['default'] : depth0)) != null ? helper : helperMissing),(typeof helper === functionType ? helper.call(depth0, {"name":"default","hash":{},"data":data}) : helper)))
+ "</textarea>\n <br />\n <div class=\"parameter-content-type\" />\n";
},"7":function(depth0,helpers,partials,data) {
var helper, functionType="function", helperMissing=helpers.helperMissing, escapeExpression=this.escapeExpression;
return " <textarea class='body-textarea required' placeholder='(required)' name='"
+ escapeExpression(((helper = (helper = helpers.name || (depth0 != null ? depth0.name : depth0)) != null ? helper : helperMissing),(typeof helper === functionType ? helper.call(depth0, {"name":"name","hash":{},"data":data}) : helper)))
+ "'></textarea>\n <br />\n <div class=\"parameter-content-type\" />\n";
},"9":function(depth0,helpers,partials,data) {
var stack1, buffer = "";
stack1 = helpers['if'].call(depth0, (depth0 != null ? depth0.isFile : depth0), {"name":"if","hash":{},"fn":this.program(10, data),"inverse":this.program(12, data),"data":data});
if (stack1 != null) { buffer += stack1; }
return buffer;
},"10":function(depth0,helpers,partials,data) {
var helper, functionType="function", helperMissing=helpers.helperMissing, escapeExpression=this.escapeExpression;
return " <input class='parameter' class='required' type='file' name='"
+ escapeExpression(((helper = (helper = helpers.name || (depth0 != null ? depth0.name : depth0)) != null ? helper : helperMissing),(typeof helper === functionType ? helper.call(depth0, {"name":"name","hash":{},"data":data}) : helper)))
+ "'/>\n";
},"12":function(depth0,helpers,partials,data) {
var stack1, buffer = "";
stack1 = helpers['if'].call(depth0, (depth0 != null ? depth0['default'] : depth0), {"name":"if","hash":{},"fn":this.program(13, data),"inverse":this.program(15, data),"data":data});
if (stack1 != null) { buffer += stack1; }
return buffer;
},"13":function(depth0,helpers,partials,data) {
var helper, functionType="function", helperMissing=helpers.helperMissing, escapeExpression=this.escapeExpression;
return " <input class='parameter required' minlength='1' name='"
+ escapeExpression(((helper = (helper = helpers.name || (depth0 != null ? depth0.name : depth0)) != null ? helper : helperMissing),(typeof helper === functionType ? helper.call(depth0, {"name":"name","hash":{},"data":data}) : helper)))
+ "' placeholder='(required)' type='text' value='"
+ escapeExpression(((helper = (helper = helpers['default'] || (depth0 != null ? depth0['default'] : depth0)) != null ? helper : helperMissing),(typeof helper === functionType ? helper.call(depth0, {"name":"default","hash":{},"data":data}) : helper)))
+ "'/>\n";
},"15":function(depth0,helpers,partials,data) {
var helper, functionType="function", helperMissing=helpers.helperMissing, escapeExpression=this.escapeExpression;
return " <input class='parameter required' minlength='1' name='"
+ escapeExpression(((helper = (helper = helpers.name || (depth0 != null ? depth0.name : depth0)) != null ? helper : helperMissing),(typeof helper === functionType ? helper.call(depth0, {"name":"name","hash":{},"data":data}) : helper)))
+ "' placeholder='(required)' type='text' value=''/>\n";
},"compiler":[6,">= 2.0.0-beta.1"],"main":function(depth0,helpers,partials,data) {
var stack1, helper, functionType="function", helperMissing=helpers.helperMissing, escapeExpression=this.escapeExpression, buffer = "<td class='code required'>"
+ escapeExpression(((helper = (helper = helpers.name || (depth0 != null ? depth0.name : depth0)) != null ? helper : helperMissing),(typeof helper === functionType ? helper.call(depth0, {"name":"name","hash":{},"data":data}) : helper)))
+ "</td>\n<td>\n";
stack1 = helpers['if'].call(depth0, (depth0 != null ? depth0.isBody : depth0), {"name":"if","hash":{},"fn":this.program(1, data),"inverse":this.program(9, data),"data":data});
if (stack1 != null) { buffer += stack1; }
buffer += "</td>\n<td>\n <strong><span class=\"markdown\">";
stack1 = ((helper = (helper = helpers.description || (depth0 != null ? depth0.description : depth0)) != null ? helper : helperMissing),(typeof helper === functionType ? helper.call(depth0, {"name":"description","hash":{},"data":data}) : helper));
if (stack1 != null) { buffer += stack1; }
buffer += "</span></strong>\n</td>\n<td>";
stack1 = ((helper = (helper = helpers.paramType || (depth0 != null ? depth0.paramType : depth0)) != null ? helper : helperMissing),(typeof helper === functionType ? helper.call(depth0, {"name":"paramType","hash":{},"data":data}) : helper));
if (stack1 != null) { buffer += stack1; }
return buffer + "</td>\n<td><span class=\"model-signature\"></span></td>\n";
},"useData":true}); },"useData":true});
var ResourceView, var ResourceView,
__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; },
@@ -1972,16 +1965,16 @@ ResourceView = (function(_super) {
} }
this.auths = opts.auths; this.auths = opts.auths;
if ("" === this.model.description) { if ("" === this.model.description) {
return this.model.description = null; this.model.description = null;
}
if (this.model.description != null) {
return this.model.summary = this.model.description;
} }
}; };
ResourceView.prototype.render = function() { ResourceView.prototype.render = function() {
var counter, id, methods, operation, _i, _len, _ref; var counter, id, methods, operation, _i, _len, _ref;
methods = {}; methods = {};
if (this.model.description != null) {
this.model.summary = this.model.description;
}
$(this.el).html(Handlebars.templates.resource(this.model)); $(this.el).html(Handlebars.templates.resource(this.model));
_ref = this.model.operationsArray; _ref = this.model.operationsArray;
for (_i = 0, _len = _ref.length; _i < _len; _i++) { for (_i = 0, _len = _ref.length; _i < _len; _i++) {
@@ -2026,26 +2019,43 @@ ResourceView = (function(_super) {
})(Backbone.View); })(Backbone.View);
this["Handlebars"]["templates"]["parameter_content_type"] = Handlebars.template({"1":function(depth0,helpers,partials,data) { this["Handlebars"]["templates"]["resource"] = Handlebars.template({"1":function(depth0,helpers,partials,data) {
var stack1, buffer = ""; return " : ";
stack1 = helpers.each.call(depth0, (depth0 != null ? depth0.consumes : depth0), {"name":"each","hash":{},"fn":this.program(2, data),"inverse":this.noop,"data":data}); },"3":function(depth0,helpers,partials,data) {
var helper, functionType="function", helperMissing=helpers.helperMissing, escapeExpression=this.escapeExpression;
return "<li>\n <a href='"
+ escapeExpression(((helper = (helper = helpers.url || (depth0 != null ? depth0.url : depth0)) != null ? helper : helperMissing),(typeof helper === functionType ? helper.call(depth0, {"name":"url","hash":{},"data":data}) : helper)))
+ "'>Raw</a>\n </li>";
},"compiler":[6,">= 2.0.0-beta.1"],"main":function(depth0,helpers,partials,data) {
var stack1, helper, options, functionType="function", helperMissing=helpers.helperMissing, escapeExpression=this.escapeExpression, blockHelperMissing=helpers.blockHelperMissing, buffer = "<div class='heading'>\n <h2>\n <a href='#!/"
+ escapeExpression(((helper = (helper = helpers.id || (depth0 != null ? depth0.id : depth0)) != null ? helper : helperMissing),(typeof helper === functionType ? helper.call(depth0, {"name":"id","hash":{},"data":data}) : helper)))
+ "' class=\"toggleEndpointList\" data-id=\""
+ escapeExpression(((helper = (helper = helpers.id || (depth0 != null ? depth0.id : depth0)) != null ? helper : helperMissing),(typeof helper === functionType ? helper.call(depth0, {"name":"id","hash":{},"data":data}) : helper)))
+ "\">"
+ escapeExpression(((helper = (helper = helpers.name || (depth0 != null ? depth0.name : depth0)) != null ? helper : helperMissing),(typeof helper === functionType ? helper.call(depth0, {"name":"name","hash":{},"data":data}) : helper)))
+ "</a> ";
stack1 = ((helper = (helper = helpers.summary || (depth0 != null ? depth0.summary : depth0)) != null ? helper : helperMissing),(options={"name":"summary","hash":{},"fn":this.program(1, data),"inverse":this.noop,"data":data}),(typeof helper === functionType ? helper.call(depth0, options) : helper));
if (!helpers.summary) { stack1 = blockHelperMissing.call(depth0, stack1, options); }
if (stack1 != null) { buffer += stack1; } if (stack1 != null) { buffer += stack1; }
return buffer; stack1 = ((helper = (helper = helpers.summary || (depth0 != null ? depth0.summary : depth0)) != null ? helper : helperMissing),(typeof helper === functionType ? helper.call(depth0, {"name":"summary","hash":{},"data":data}) : helper));
},"2":function(depth0,helpers,partials,data) {
var stack1, lambda=this.lambda, buffer = " <option value=\"";
stack1 = lambda(depth0, depth0);
if (stack1 != null) { buffer += stack1; } if (stack1 != null) { buffer += stack1; }
buffer += "\">"; buffer += "\n </h2>\n <ul class='options'>\n <li>\n <a href='#!/"
stack1 = lambda(depth0, depth0); + escapeExpression(((helper = (helper = helpers.id || (depth0 != null ? depth0.id : depth0)) != null ? helper : helperMissing),(typeof helper === functionType ? helper.call(depth0, {"name":"id","hash":{},"data":data}) : helper)))
+ "' id='endpointListTogger_"
+ escapeExpression(((helper = (helper = helpers.id || (depth0 != null ? depth0.id : depth0)) != null ? helper : helperMissing),(typeof helper === functionType ? helper.call(depth0, {"name":"id","hash":{},"data":data}) : helper)))
+ "' class=\"toggleEndpointList\" data-id=\""
+ escapeExpression(((helper = (helper = helpers.id || (depth0 != null ? depth0.id : depth0)) != null ? helper : helperMissing),(typeof helper === functionType ? helper.call(depth0, {"name":"id","hash":{},"data":data}) : helper)))
+ "\">Show/Hide</a>\n </li>\n <li>\n <a href='#' class=\"collapseResource\" data-id=\""
+ escapeExpression(((helper = (helper = helpers.id || (depth0 != null ? depth0.id : depth0)) != null ? helper : helperMissing),(typeof helper === functionType ? helper.call(depth0, {"name":"id","hash":{},"data":data}) : helper)))
+ "\">\n List Operations\n </a>\n </li>\n <li>\n <a href='#' class=\"expandResource\" data-id=\""
+ escapeExpression(((helper = (helper = helpers.id || (depth0 != null ? depth0.id : depth0)) != null ? helper : helperMissing),(typeof helper === functionType ? helper.call(depth0, {"name":"id","hash":{},"data":data}) : helper)))
+ "\">\n Expand Operations\n </a>\n </li>\n ";
stack1 = ((helper = (helper = helpers.url || (depth0 != null ? depth0.url : depth0)) != null ? helper : helperMissing),(options={"name":"url","hash":{},"fn":this.program(3, data),"inverse":this.noop,"data":data}),(typeof helper === functionType ? helper.call(depth0, options) : helper));
if (!helpers.url) { stack1 = blockHelperMissing.call(depth0, stack1, options); }
if (stack1 != null) { buffer += stack1; } if (stack1 != null) { buffer += stack1; }
return buffer + "</option>\n"; return buffer + "\n </ul>\n</div>\n<ul class='endpoints' id='"
},"4":function(depth0,helpers,partials,data) { + escapeExpression(((helper = (helper = helpers.id || (depth0 != null ? depth0.id : depth0)) != null ? helper : helperMissing),(typeof helper === functionType ? helper.call(depth0, {"name":"id","hash":{},"data":data}) : helper)))
return " <option value=\"application/json\">application/json</option>\n"; + "_endpoint_list' style='display:none'>\n\n</ul>\n";
},"compiler":[6,">= 2.0.0-beta.1"],"main":function(depth0,helpers,partials,data) {
var stack1, buffer = "<label for=\"parameterContentType\"></label>\n<select name=\"parameterContentType\">\n";
stack1 = helpers['if'].call(depth0, (depth0 != null ? depth0.consumes : depth0), {"name":"if","hash":{},"fn":this.program(1, data),"inverse":this.program(4, data),"data":data});
if (stack1 != null) { buffer += stack1; }
return buffer + "</select>\n";
},"useData":true}); },"useData":true});
var ResponseContentTypeView, var ResponseContentTypeView,
__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; },
@@ -2076,43 +2086,26 @@ ResponseContentTypeView = (function(_super) {
})(Backbone.View); })(Backbone.View);
this["Handlebars"]["templates"]["resource"] = Handlebars.template({"1":function(depth0,helpers,partials,data) { this["Handlebars"]["templates"]["response_content_type"] = Handlebars.template({"1":function(depth0,helpers,partials,data) {
return " : "; var stack1, buffer = "";
},"3":function(depth0,helpers,partials,data) { stack1 = helpers.each.call(depth0, (depth0 != null ? depth0.produces : depth0), {"name":"each","hash":{},"fn":this.program(2, data),"inverse":this.noop,"data":data});
var helper, functionType="function", helperMissing=helpers.helperMissing, escapeExpression=this.escapeExpression;
return "<li>\n <a href='"
+ escapeExpression(((helper = (helper = helpers.url || (depth0 != null ? depth0.url : depth0)) != null ? helper : helperMissing),(typeof helper === functionType ? helper.call(depth0, {"name":"url","hash":{},"data":data}) : helper)))
+ "' data-sw-translate>Raw</a>\n </li>";
},"compiler":[6,">= 2.0.0-beta.1"],"main":function(depth0,helpers,partials,data) {
var stack1, helper, options, functionType="function", helperMissing=helpers.helperMissing, escapeExpression=this.escapeExpression, blockHelperMissing=helpers.blockHelperMissing, buffer = "<div class='heading'>\n <h2>\n <a href='#!/"
+ escapeExpression(((helper = (helper = helpers.id || (depth0 != null ? depth0.id : depth0)) != null ? helper : helperMissing),(typeof helper === functionType ? helper.call(depth0, {"name":"id","hash":{},"data":data}) : helper)))
+ "' class=\"toggleEndpointList\" data-id=\""
+ escapeExpression(((helper = (helper = helpers.id || (depth0 != null ? depth0.id : depth0)) != null ? helper : helperMissing),(typeof helper === functionType ? helper.call(depth0, {"name":"id","hash":{},"data":data}) : helper)))
+ "\">"
+ escapeExpression(((helper = (helper = helpers.name || (depth0 != null ? depth0.name : depth0)) != null ? helper : helperMissing),(typeof helper === functionType ? helper.call(depth0, {"name":"name","hash":{},"data":data}) : helper)))
+ "</a> ";
stack1 = ((helper = (helper = helpers.summary || (depth0 != null ? depth0.summary : depth0)) != null ? helper : helperMissing),(options={"name":"summary","hash":{},"fn":this.program(1, data),"inverse":this.noop,"data":data}),(typeof helper === functionType ? helper.call(depth0, options) : helper));
if (!helpers.summary) { stack1 = blockHelperMissing.call(depth0, stack1, options); }
if (stack1 != null) { buffer += stack1; } if (stack1 != null) { buffer += stack1; }
stack1 = ((helper = (helper = helpers.summary || (depth0 != null ? depth0.summary : depth0)) != null ? helper : helperMissing),(typeof helper === functionType ? helper.call(depth0, {"name":"summary","hash":{},"data":data}) : helper)); return buffer;
},"2":function(depth0,helpers,partials,data) {
var stack1, lambda=this.lambda, buffer = " <option value=\"";
stack1 = lambda(depth0, depth0);
if (stack1 != null) { buffer += stack1; } if (stack1 != null) { buffer += stack1; }
buffer += "\n </h2>\n <ul class='options'>\n <li>\n <a href='#!/" buffer += "\">";
+ escapeExpression(((helper = (helper = helpers.id || (depth0 != null ? depth0.id : depth0)) != null ? helper : helperMissing),(typeof helper === functionType ? helper.call(depth0, {"name":"id","hash":{},"data":data}) : helper))) stack1 = lambda(depth0, depth0);
+ "' id='endpointListTogger_"
+ escapeExpression(((helper = (helper = helpers.id || (depth0 != null ? depth0.id : depth0)) != null ? helper : helperMissing),(typeof helper === functionType ? helper.call(depth0, {"name":"id","hash":{},"data":data}) : helper)))
+ "' class=\"toggleEndpointList\" data-id=\""
+ escapeExpression(((helper = (helper = helpers.id || (depth0 != null ? depth0.id : depth0)) != null ? helper : helperMissing),(typeof helper === functionType ? helper.call(depth0, {"name":"id","hash":{},"data":data}) : helper)))
+ "\" data-sw-translate>Show/Hide</a>\n </li>\n <li>\n <a href='#' class=\"collapseResource\" data-id=\""
+ escapeExpression(((helper = (helper = helpers.id || (depth0 != null ? depth0.id : depth0)) != null ? helper : helperMissing),(typeof helper === functionType ? helper.call(depth0, {"name":"id","hash":{},"data":data}) : helper)))
+ "\">\n <span data-sw-translate>List Operations</span>\n </a>\n </li>\n <li>\n <a href='#' class=\"expandResource\" data-id=\""
+ escapeExpression(((helper = (helper = helpers.id || (depth0 != null ? depth0.id : depth0)) != null ? helper : helperMissing),(typeof helper === functionType ? helper.call(depth0, {"name":"id","hash":{},"data":data}) : helper)))
+ "\">\n <span data-sw-translate>Expand Operations</span>\n </a>\n </li>\n ";
stack1 = ((helper = (helper = helpers.url || (depth0 != null ? depth0.url : depth0)) != null ? helper : helperMissing),(options={"name":"url","hash":{},"fn":this.program(3, data),"inverse":this.noop,"data":data}),(typeof helper === functionType ? helper.call(depth0, options) : helper));
if (!helpers.url) { stack1 = blockHelperMissing.call(depth0, stack1, options); }
if (stack1 != null) { buffer += stack1; } if (stack1 != null) { buffer += stack1; }
return buffer + "\n </ul>\n</div>\n<ul class='endpoints' id='" return buffer + "</option>\n";
+ escapeExpression(((helper = (helper = helpers.id || (depth0 != null ? depth0.id : depth0)) != null ? helper : helperMissing),(typeof helper === functionType ? helper.call(depth0, {"name":"id","hash":{},"data":data}) : helper))) },"4":function(depth0,helpers,partials,data) {
+ "_endpoint_list' style='display:none'>\n\n</ul>\n"; return " <option value=\"application/json\">application/json</option>\n";
},"compiler":[6,">= 2.0.0-beta.1"],"main":function(depth0,helpers,partials,data) {
var stack1, buffer = "<label for=\"responseContentType\"></label>\n<select name=\"responseContentType\">\n";
stack1 = helpers['if'].call(depth0, (depth0 != null ? depth0.produces : depth0), {"name":"if","hash":{},"fn":this.program(1, data),"inverse":this.program(4, data),"data":data});
if (stack1 != null) { buffer += stack1; }
return buffer + "</select>\n";
},"useData":true}); },"useData":true});
var SignatureView, var SignatureView,
__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; },
@@ -2186,26 +2179,13 @@ SignatureView = (function(_super) {
})(Backbone.View); })(Backbone.View);
this["Handlebars"]["templates"]["response_content_type"] = Handlebars.template({"1":function(depth0,helpers,partials,data) { this["Handlebars"]["templates"]["signature"] = Handlebars.template({"compiler":[6,">= 2.0.0-beta.1"],"main":function(depth0,helpers,partials,data) {
var stack1, buffer = ""; var stack1, helper, functionType="function", helperMissing=helpers.helperMissing, escapeExpression=this.escapeExpression, buffer = "<div>\n<ul class=\"signature-nav\">\n <li><a class=\"description-link\" href=\"#\">Model</a></li>\n <li><a class=\"snippet-link\" href=\"#\">Model Schema</a></li>\n</ul>\n<div>\n\n<div class=\"signature-container\">\n <div class=\"description\">\n ";
stack1 = helpers.each.call(depth0, (depth0 != null ? depth0.produces : depth0), {"name":"each","hash":{},"fn":this.program(2, data),"inverse":this.noop,"data":data}); stack1 = ((helper = (helper = helpers.signature || (depth0 != null ? depth0.signature : depth0)) != null ? helper : helperMissing),(typeof helper === functionType ? helper.call(depth0, {"name":"signature","hash":{},"data":data}) : helper));
if (stack1 != null) { buffer += stack1; } if (stack1 != null) { buffer += stack1; }
return buffer; return buffer + "\n </div>\n\n <div class=\"snippet\">\n <pre><code>"
},"2":function(depth0,helpers,partials,data) { + escapeExpression(((helper = (helper = helpers.sampleJSON || (depth0 != null ? depth0.sampleJSON : depth0)) != null ? helper : helperMissing),(typeof helper === functionType ? helper.call(depth0, {"name":"sampleJSON","hash":{},"data":data}) : helper)))
var stack1, lambda=this.lambda, buffer = " <option value=\""; + "</code></pre>\n <small class=\"notice\"></small>\n </div>\n</div>\n\n";
stack1 = lambda(depth0, depth0);
if (stack1 != null) { buffer += stack1; }
buffer += "\">";
stack1 = lambda(depth0, depth0);
if (stack1 != null) { buffer += stack1; }
return buffer + "</option>\n";
},"4":function(depth0,helpers,partials,data) {
return " <option value=\"application/json\">application/json</option>\n";
},"compiler":[6,">= 2.0.0-beta.1"],"main":function(depth0,helpers,partials,data) {
var stack1, buffer = "<label for=\"responseContentType\" data-sw-translate=1></label>\n<select name=\"responseContentType\">\n";
stack1 = helpers['if'].call(depth0, (depth0 != null ? depth0.produces : depth0), {"name":"if","hash":{},"fn":this.program(1, data),"inverse":this.program(4, data),"data":data});
if (stack1 != null) { buffer += stack1; }
return buffer + "</select>\n";
},"useData":true}); },"useData":true});
var StatusCodeView, var StatusCodeView,
__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; },
@@ -2249,14 +2229,6 @@ StatusCodeView = (function(_super) {
})(Backbone.View); })(Backbone.View);
this["Handlebars"]["templates"]["signature"] = Handlebars.template({"compiler":[6,">= 2.0.0-beta.1"],"main":function(depth0,helpers,partials,data) {
var stack1, helper, functionType="function", helperMissing=helpers.helperMissing, escapeExpression=this.escapeExpression, buffer = "<div>\n<ul class=\"signature-nav\">\n <li><a class=\"description-link\" href=\"#\" data-sw-translate>Model</a></li>\n <li><a class=\"snippet-link\" href=\"#\" data-sw-translate>Model Schema</a></li>\n</ul>\n<div>\n\n<div class=\"signature-container\">\n <div class=\"description\">\n ";
stack1 = ((helper = (helper = helpers.signature || (depth0 != null ? depth0.signature : depth0)) != null ? helper : helperMissing),(typeof helper === functionType ? helper.call(depth0, {"name":"signature","hash":{},"data":data}) : helper));
if (stack1 != null) { buffer += stack1; }
return buffer + "\n </div>\n\n <div class=\"snippet\">\n <pre><code>"
+ escapeExpression(((helper = (helper = helpers.sampleJSON || (depth0 != null ? depth0.sampleJSON : depth0)) != null ? helper : helperMissing),(typeof helper === functionType ? helper.call(depth0, {"name":"sampleJSON","hash":{},"data":data}) : helper)))
+ "</code></pre>\n <small class=\"notice\"></small>\n </div>\n</div>\n\n";
},"useData":true});
this["Handlebars"]["templates"]["status_code"] = Handlebars.template({"compiler":[6,">= 2.0.0-beta.1"],"main":function(depth0,helpers,partials,data) { this["Handlebars"]["templates"]["status_code"] = Handlebars.template({"compiler":[6,">= 2.0.0-beta.1"],"main":function(depth0,helpers,partials,data) {
var stack1, helper, functionType="function", helperMissing=helpers.helperMissing, escapeExpression=this.escapeExpression, buffer = "<td width='15%' class='code'>" var stack1, helper, functionType="function", helperMissing=helpers.helperMissing, escapeExpression=this.escapeExpression, buffer = "<td width='15%' class='code'>"
+ escapeExpression(((helper = (helper = helpers.code || (depth0 != null ? depth0.code : depth0)) != null ? helper : helperMissing),(typeof helper === functionType ? helper.call(depth0, {"name":"code","hash":{},"data":data}) : helper))) + escapeExpression(((helper = (helper = helpers.code || (depth0 != null ? depth0.code : depth0)) != null ? helper : helperMissing),(typeof helper === functionType ? helper.call(depth0, {"name":"code","hash":{},"data":data}) : helper)))

File diff suppressed because one or more lines are too long

View File

@@ -1,6 +1,6 @@
/** /**
* swagger-client - swagger.js is a javascript client for use with swaggering APIs. * swagger-client - swagger.js is a javascript client for use with swaggering APIs.
* @version v2.1.3-M1 * @version v2.1.9-M1
* @link http://swagger.io * @link http://swagger.io
* @license apache 2.0 * @license apache 2.0
*/ */
@@ -57,10 +57,31 @@ ArrayModel.prototype.getSampleValue = function(modelsToIgnore) {
ArrayModel.prototype.getMockSignature = function(modelsToIgnore) { ArrayModel.prototype.getMockSignature = function(modelsToIgnore) {
var propertiesStr = []; var propertiesStr = [];
var i, prop;
if(this.ref) { for (i = 0; i < this.properties.length; i++) {
return models[simpleRef(this.ref)].getMockSignature(); prop = this.properties[i];
propertiesStr.push(prop.toString());
} }
var strong = '<span class="strong">';
var stronger = '<span class="stronger">';
var strongClose = '</span>';
var classOpen = strong + 'array' + ' {' + strongClose;
var classClose = strong + '}' + strongClose;
var returnVal = classOpen + '<div>' + propertiesStr.join(',</div><div>') + '</div>' + classClose;
if (!modelsToIgnore)
modelsToIgnore = {};
modelsToIgnore[this.name] = this;
for (i = 0; i < this.properties.length; i++) {
prop = this.properties[i];
var ref = prop.$ref;
var model = models[ref];
if (model && typeof modelsToIgnore[ref] === 'undefined') {
returnVal = returnVal + ('<br>' + model.getMockSignature(modelsToIgnore));
}
}
return returnVal;
}; };
@@ -280,6 +301,206 @@ PrimitiveModel.prototype.getMockSignature = function(modelsToIgnore) {
} }
return returnVal; return returnVal;
}; };
/**
* Resolves a spec's remote references
*/
var Resolver = function (){};
Resolver.prototype.resolve = function(spec, callback, scope) {
this.scope = (scope || this);
var host, name, path, property, propertyName, type;
var processedCalls = 0, resolvedRefs = {}, unresolvedRefs = {};
// store objects for dereferencing
var resolutionTable = {};
// models
for(name in spec.definitions) {
var model = spec.definitions[name];
for(propertyName in model.properties) {
property = model.properties[propertyName];
this.resolveTo(property, resolutionTable);
}
}
// operations
for(name in spec.paths) {
var method, operation, responseCode;
path = spec.paths[name];
for(method in path) {
operation = path[method];
var i, parameters = operation.parameters;
for(i in parameters) {
var parameter = parameters[i];
if(parameter.in === 'body' && parameter.schema) {
this.resolveTo(parameter.schema, resolutionTable);
}
if(parameter.$ref) {
this.resolveInline(spec, parameter, resolutionTable, unresolvedRefs);
}
}
for(responseCode in operation.responses) {
var response = operation.responses[responseCode];
if(response.schema) {
this.resolveTo(response.schema, resolutionTable);
}
}
}
}
// get hosts
var opts = {}, expectedCalls = 0;
for(name in resolutionTable) {
var parts = name.split('#');
if(parts.length == 2) {
host = parts[0]; path = parts[1];
if(!Array.isArray(opts[host])) {
opts[host] = [];
expectedCalls += 1;
}
opts[host].push(path);
}
}
for(name in opts) {
var self = this, opt = opts[name];
host = name;
var obj = {
useJQuery: false, // TODO
url: host,
method: "get",
headers: {
accept: this.scope.swaggerRequestHeaders || 'application/json'
},
on: {
error: function(response) {
processedCalls += 1;
var i;
for(i = 0; i < opt.length; i++) {
// fail all of these
var resolved = host + '#' + opt[i];
unresolvedRefs[resolved] = null;
}
if(processedCalls === expectedCalls)
self.finish(spec, resolutionTable, resolvedRefs, unresolvedRefs, callback);
},
response: function(response) {
var i, j, swagger = response.obj;
processedCalls += 1;
for(i = 0; i < opt.length; i++) {
var location = swagger, path = opt[i], parts = path.split('/');
for(j = 0; j < parts.length; j++) {
var segment = parts[j];
if(typeof location === 'undefined')
break;
if(segment.length > 0)
location = location[segment];
}
var resolved = host + '#' + path, resolvedName = parts[j-1];
if(typeof location !== 'undefined') {
resolvedRefs[resolved] = {
name: resolvedName,
obj: location
};
}
else unresolvedRefs[resolved] = null;
}
if(processedCalls === expectedCalls)
self.finish(spec, resolutionTable, resolvedRefs, unresolvedRefs, callback);
}
}
};
authorizations.apply(obj);
new SwaggerHttp().execute(obj);
}
if(Object.keys(opts).length === 0)
callback.call(this.scope, spec, unresolvedRefs);
};
Resolver.prototype.finish = function(spec, resolutionTable, resolvedRefs, unresolvedRefs, callback) {
// walk resolution table and replace with resolved refs
var ref;
for(ref in resolutionTable) {
var i, locations = resolutionTable[ref];
for(i = 0; i < locations.length; i++) {
var resolvedTo = resolvedRefs[locations[i].obj.$ref];
if(resolvedTo) {
if(!spec.definitions)
spec.definitions = {};
if(locations[i].resolveAs === '$ref') {
spec.definitions[resolvedTo.name] = resolvedTo.obj;
locations[i].obj.$ref = '#/definitions/' + resolvedTo.name;
}
else if (locations[i].resolveAs === 'inline') {
var key;
var targetObj = locations[i].obj;
delete targetObj.$ref;
for(key in resolvedTo.obj) {
targetObj[key] = resolvedTo.obj[key];
}
}
}
}
}
callback.call(this.scope, spec, unresolvedRefs);
};
/**
* immediately in-lines local refs, queues remote refs
* for inline resolution
*/
Resolver.prototype.resolveInline = function (spec, property, objs, unresolvedRefs) {
var ref = property.$ref;
if(ref) {
if(ref.indexOf('http') === 0) {
if(Array.isArray(objs[ref])) {
objs[ref].push({obj: property, resolveAs: 'inline'});
}
else {
objs[ref] = [{obj: property, resolveAs: 'inline'}];
}
}
else if (ref.indexOf('#') === 0) {
// local resolve
var shortenedRef = ref.substring(1);
var i, parts = shortenedRef.split('/'), location = spec;
for(i = 0; i < parts.length; i++) {
var part = parts[i];
if(part.length > 0) {
location = location[part];
}
}
if(location) {
delete property.$ref;
var key;
for(key in location) {
property[key] = location[key];
}
}
else unresolvedRefs[ref] = null;
}
}
else if(property.type === 'array') {
this.resolveTo(property.items, objs);
}
};
Resolver.prototype.resolveTo = function (property, objs) {
var ref = property.$ref;
if(ref) {
if(ref.indexOf('http') === 0) {
if(Array.isArray(objs[ref])) {
objs[ref].push({obj: property, resolveAs: '$ref'});
}
else {
objs[ref] = [{obj: property, resolveAs: '$ref'}];
}
}
}
else if(property.type === 'array') {
var items = property.items;
this.resolveTo(items, objs);
}
};
var addModel = function(name, model) { var addModel = function(name, model) {
models[name] = model; models[name] = model;
}; };
@@ -325,8 +546,7 @@ SwaggerClient.prototype.initialize = function (url, options) {
if (options.authorizations) { if (options.authorizations) {
this.clientAuthorizations = options.authorizations; this.clientAuthorizations = options.authorizations;
} else { } else {
var e = (typeof window !== 'undefined' ? window : exports); this.clientAuthorizations = authorizations;
this.clientAuthorizations = e.authorizations;
} }
this.supportedSubmitMethods = options.supportedSubmitMethods || []; this.supportedSubmitMethods = options.supportedSubmitMethods || [];
@@ -336,6 +556,7 @@ SwaggerClient.prototype.initialize = function (url, options) {
this.options = options; this.options = options;
if (typeof options.success === 'function') { if (typeof options.success === 'function') {
this.ready = true;
this.build(); this.build();
} }
}; };
@@ -368,7 +589,7 @@ SwaggerClient.prototype.build = function(mock) {
if(responseObj.swagger && parseInt(responseObj.swagger) === 2) { if(responseObj.swagger && parseInt(responseObj.swagger) === 2) {
self.swaggerVersion = responseObj.swagger; self.swaggerVersion = responseObj.swagger;
self.buildFromSpec(responseObj); new Resolver().resolve(responseObj, self.buildFromSpec, self);
self.isValid = true; self.isValid = true;
} }
else { else {
@@ -382,11 +603,12 @@ SwaggerClient.prototype.build = function(mock) {
} }
}; };
if(this.spec) { if(this.spec) {
setTimeout(function() { self.buildFromSpec(self.spec); }, 10); setTimeout(function() {
new Resolver().resolve(self.spec, self.buildFromSpec, self);
}, 10);
} }
else { else {
var e = (typeof window !== 'undefined' ? window : exports); authorizations.apply(obj);
var status = e.authorizations.apply(obj);
if(mock) if(mock)
return obj; return obj;
new SwaggerHttp().execute(obj); new SwaggerHttp().execute(obj);
@@ -411,8 +633,16 @@ SwaggerClient.prototype.buildFromSpec = function(response) {
// legacy support // legacy support
this.authSchemes = response.securityDefinitions; this.authSchemes = response.securityDefinitions;
var location; var definedTags = {};
if(Array.isArray(response.tags)) {
definedTags = {};
for(k = 0; k < response.tags.length; k++) {
var t = response.tags[k];
definedTags[t.name] = t;
}
}
var location;
if(typeof this.url === 'string') { if(typeof this.url === 'string') {
location = this.parseUri(this.url); location = this.parseUri(this.url);
} }
@@ -472,17 +702,32 @@ SwaggerClient.prototype.buildFromSpec = function(response) {
for(i = 0; i < tags.length; i++) { for(i = 0; i < tags.length; i++) {
var tag = this.tagFromLabel(tags[i]); var tag = this.tagFromLabel(tags[i]);
var operationGroup = this[tag]; var operationGroup = this[tag];
if(typeof this.apis[tag] === 'undefined')
this.apis[tag] = {};
if(typeof operationGroup === 'undefined') { if(typeof operationGroup === 'undefined') {
this[tag] = []; this[tag] = [];
operationGroup = this[tag]; operationGroup = this[tag];
operationGroup.operations = {}; operationGroup.operations = {};
operationGroup.label = tag; operationGroup.label = tag;
operationGroup.apis = []; operationGroup.apis = [];
this[tag].help = this.help.bind(operationGroup); var tagObject = definedTags[tag];
this.apisArray.push(new OperationGroup(tag, operationObject)); if(typeof tagObject === 'object') {
operationGroup.description = tagObject.description;
operationGroup.externalDocs = tagObject.externalDocs;
} }
this[tag].help = this.help.bind(operationGroup);
this.apisArray.push(new OperationGroup(tag, operationGroup.description, operationGroup.externalDocs, operationObject));
}
if(typeof this.apis[tag].help !== 'function')
this.apis[tag].help = this.help.bind(operationGroup);
// bind to the apis object
this.apis[tag][operationId] = operationObject.execute.bind(operationObject);
this.apis[tag][operationId].help = operationObject.help.bind(operationObject);
this.apis[tag][operationId].asCurl = operationObject.asCurl.bind(operationObject);
operationGroup[operationId] = operationObject.execute.bind(operationObject); operationGroup[operationId] = operationObject.execute.bind(operationObject);
operationGroup[operationId].help = operationObject.help.bind(operationObject); operationGroup[operationId].help = operationObject.help.bind(operationObject);
operationGroup[operationId].asCurl = operationObject.asCurl.bind(operationObject);
operationGroup.apis.push(operationObject); operationGroup.apis.push(operationObject);
operationGroup.operations[operationId] = operationObject; operationGroup.operations[operationId] = operationObject;
@@ -525,12 +770,18 @@ SwaggerClient.prototype.parseUri = function(uri) {
}; };
}; };
SwaggerClient.prototype.help = function() { SwaggerClient.prototype.help = function(dontPrint) {
var i; var i;
log('operations for the "' + this.label + '" tag'); var output = 'operations for the "' + this.label + '" tag';
for(i = 0; i < this.apis.length; i++) { for(i = 0; i < this.apis.length; i++) {
var api = this.apis[i]; var api = this.apis[i];
log(' * ' + api.nickname + ': ' + api.operation.summary); output += '\n * ' + api.nickname + ': ' + api.operation.summary;
}
if(dontPrint)
return output;
else {
log(output);
return output;
} }
}; };
@@ -548,14 +799,14 @@ SwaggerClient.prototype.fail = function(message) {
throw message; throw message;
}; };
var OperationGroup = function(tag, operation) { var OperationGroup = function(tag, description, externalDocs, operation) {
this.tag = tag; this.tag = tag;
this.path = tag; this.path = tag;
this.description = description;
this.externalDocs = externalDocs;
this.name = tag; this.name = tag;
this.operation = operation; this.operation = operation;
this.operationsArray = []; this.operationsArray = [];
this.description = operation.description || "";
}; };
var Operation = function(parent, scheme, operationId, httpMethod, path, args, definitions) { var Operation = function(parent, scheme, operationId, httpMethod, path, args, definitions) {
@@ -720,10 +971,14 @@ Operation.prototype.getType = function (param) {
str = 'long'; str = 'long';
else if(type === 'integer') else if(type === 'integer')
str = 'integer'; str = 'integer';
else if(type === 'string' && format === 'date-time') else if(type === 'string') {
if(format === 'date-time')
str = 'date-time'; str = 'date-time';
else if(type === 'string' && format === 'date') else if(format === 'date')
str = 'date'; str = 'date';
else
str = 'string';
}
else if(type === 'number' && format === 'float') else if(type === 'number' && format === 'float')
str = 'float'; str = 'float';
else if(type === 'number' && format === 'double') else if(type === 'number' && format === 'double')
@@ -732,8 +987,6 @@ Operation.prototype.getType = function (param) {
str = 'double'; str = 'double';
else if(type === 'boolean') else if(type === 'boolean')
str = 'boolean'; str = 'boolean';
else if(type === 'string')
str = 'string';
else if(type === 'array') { else if(type === 'array') {
isArray = true; isArray = true;
if(param.items) if(param.items)
@@ -780,7 +1033,7 @@ Operation.prototype.help = function(dontPrint) {
var out = this.nickname + ': ' + this.summary + '\n'; var out = this.nickname + ': ' + this.summary + '\n';
for(var i = 0; i < this.parameters.length; i++) { for(var i = 0; i < this.parameters.length; i++) {
var param = this.parameters[i]; var param = this.parameters[i];
var typeInfo = typeFromJsonSchema(param.type, param.format); var typeInfo = param.signature;
out += '\n * ' + param.name + ' (' + typeInfo + '): ' + param.description; out += '\n * ' + param.name + ' (' + typeInfo + '): ' + param.description;
} }
if(typeof dontPrint === 'undefined') if(typeof dontPrint === 'undefined')
@@ -898,9 +1151,8 @@ Operation.prototype.getMissingParams = function(args) {
return missingParams; return missingParams;
}; };
Operation.prototype.getBody = function(headers, args) { Operation.prototype.getBody = function(headers, args, opts) {
var formParams = {}; var formParams = {}, body, key;
var body;
for(var i = 0; i < this.parameters.length; i++) { for(var i = 0; i < this.parameters.length; i++) {
var param = this.parameters[i]; var param = this.parameters[i];
@@ -916,7 +1168,6 @@ Operation.prototype.getBody = function(headers, args) {
// handle form params // handle form params
if(headers['Content-Type'] === 'application/x-www-form-urlencoded') { if(headers['Content-Type'] === 'application/x-www-form-urlencoded') {
var encoded = ""; var encoded = "";
var key;
for(key in formParams) { for(key in formParams) {
value = formParams[key]; value = formParams[key];
if(typeof value !== 'undefined'){ if(typeof value !== 'undefined'){
@@ -927,6 +1178,25 @@ Operation.prototype.getBody = function(headers, args) {
} }
body = encoded; body = encoded;
} }
else if (headers['Content-Type'] && headers['Content-Type'].indexOf('multipart/form-data') >= 0) {
if(opts.useJQuery) {
var bodyParam = new FormData();
bodyParam.type = 'formData';
for (key in formParams) {
value = args[key];
if (typeof value !== 'undefined') {
// required for jquery file upload
if(value.type === 'file' && value.value) {
delete headers['Content-Type'];
bodyParam.append(key, value.value);
}
else
bodyParam.append(key, value);
}
}
body = bodyParam;
}
}
return body; return body;
}; };
@@ -989,9 +1259,8 @@ Operation.prototype.execute = function(arg1, arg2, arg3, arg4, parent) {
success = (success||log); success = (success||log);
error = (error||log); error = (error||log);
if(typeof opts.useJQuery === 'boolean') { if(opts.useJQuery)
this.useJQuery = opts.useJQuery; this.useJQuery = opts.useJQuery;
}
var missingParams = this.getMissingParams(args); var missingParams = this.getMissingParams(args);
if(missingParams.length > 0) { if(missingParams.length > 0) {
@@ -1006,7 +1275,7 @@ Operation.prototype.execute = function(arg1, arg2, arg3, arg4, parent) {
for (attrname in allHeaders) { headers[attrname] = allHeaders[attrname]; } for (attrname in allHeaders) { headers[attrname] = allHeaders[attrname]; }
for (attrname in contentTypeHeaders) { headers[attrname] = contentTypeHeaders[attrname]; } for (attrname in contentTypeHeaders) { headers[attrname] = contentTypeHeaders[attrname]; }
var body = this.getBody(headers, args); var body = this.getBody(headers, args, opts);
var url = this.urlify(args); var url = this.urlify(args);
var obj = { var obj = {
@@ -1024,18 +1293,17 @@ Operation.prototype.execute = function(arg1, arg2, arg3, arg4, parent) {
} }
} }
}; };
var status = e.authorizations.apply(obj, this.operation.security); var status = authorizations.apply(obj, this.operation.security);
if(opts.mock === true) if(opts.mock === true)
return obj; return obj;
else else
new SwaggerHttp().execute(obj); new SwaggerHttp().execute(obj, opts);
}; };
Operation.prototype.setContentTypes = function(args, opts) { Operation.prototype.setContentTypes = function(args, opts) {
// default type // default type
var accepts = 'application/json'; var accepts = 'application/json';
var consumes = args.parameterContentType || 'application/json'; var consumes = args.parameterContentType || 'application/json';
var allDefinedParams = this.parameters; var allDefinedParams = this.parameters;
var definedFormParams = []; var definedFormParams = [];
var definedFileParams = []; var definedFileParams = [];
@@ -1108,14 +1376,24 @@ Operation.prototype.setContentTypes = function(args, opts) {
}; };
Operation.prototype.asCurl = function (args) { Operation.prototype.asCurl = function (args) {
var obj = this.execute(args, {mock: true});
authorizations.apply(obj);
var results = []; var results = [];
var headers = this.getHeaderParams(args); results.push('-X ' + this.method.toUpperCase());
if (headers) { if (obj.headers) {
var key; var key;
for (key in headers) for (key in obj.headers)
results.push("--header \"" + key + ": " + headers[key] + "\""); results.push('--header "' + key + ': ' + obj.headers[key] + '"');
} }
return "curl " + (results.join(" ")) + " " + this.urlify(args); if(obj.body) {
var body;
if(typeof obj.body === 'object')
body = JSON.stringify(obj.body);
else
body = obj.body;
results.push('-d "' + body.replace(/"/g, '\\"') + '"');
}
return 'curl ' + (results.join(' ')) + ' "' + obj.url + '"';
}; };
Operation.prototype.encodePathCollection = function(type, name, value) { Operation.prototype.encodePathCollection = function(type, name, value) {
@@ -1223,12 +1501,12 @@ var Model = function(name, definition) {
}; };
Model.prototype.createJSONSample = function(modelsToIgnore) { Model.prototype.createJSONSample = function(modelsToIgnore) {
var i, result = {}; var i, result = {}, representations = {};
modelsToIgnore = (modelsToIgnore||{}); modelsToIgnore = (modelsToIgnore||{});
modelsToIgnore[this.name] = this; modelsToIgnore[this.name] = this;
for (i = 0; i < this.properties.length; i++) { for (i = 0; i < this.properties.length; i++) {
prop = this.properties[i]; prop = this.properties[i];
var sample = prop.getSampleValue(modelsToIgnore); var sample = prop.getSampleValue(modelsToIgnore, representations);
result[prop.name] = sample; result[prop.name] = sample;
} }
delete modelsToIgnore[this.name]; delete modelsToIgnore[this.name];
@@ -1236,10 +1514,10 @@ Model.prototype.createJSONSample = function(modelsToIgnore) {
}; };
Model.prototype.getSampleValue = function(modelsToIgnore) { Model.prototype.getSampleValue = function(modelsToIgnore) {
var i, obj = {}; var i, obj = {}, representations = {};
for(i = 0; i < this.properties.length; i++ ) { for(i = 0; i < this.properties.length; i++ ) {
var property = this.properties[i]; var property = this.properties[i];
obj[property.name] = property.sampleValue(false, modelsToIgnore); obj[property.name] = property.sampleValue(false, modelsToIgnore, representations);
} }
return obj; return obj;
}; };
@@ -1288,7 +1566,7 @@ var Property = function(name, obj, required) {
this.optional = true; this.optional = true;
this.optional = !required; this.optional = !required;
this.default = obj.default || null; this.default = obj.default || null;
this.example = obj.example || null; this.example = obj.example !== undefined ? obj.example : null;
this.collectionFormat = obj.collectionFormat || null; this.collectionFormat = obj.collectionFormat || null;
this.maximum = obj.maximum || null; this.maximum = obj.maximum || null;
this.exclusiveMaximum = obj.exclusiveMaximum || null; this.exclusiveMaximum = obj.exclusiveMaximum || null;
@@ -1304,8 +1582,8 @@ var Property = function(name, obj, required) {
this.multipleOf = obj.multipleOf || null; this.multipleOf = obj.multipleOf || null;
}; };
Property.prototype.getSampleValue = function (modelsToIgnore) { Property.prototype.getSampleValue = function (modelsToIgnore, representations) {
return this.sampleValue(false, modelsToIgnore); return this.sampleValue(false, modelsToIgnore, representations);
}; };
Property.prototype.isArray = function () { Property.prototype.isArray = function () {
@@ -1316,21 +1594,29 @@ Property.prototype.isArray = function () {
return false; return false;
}; };
Property.prototype.sampleValue = function(isArray, ignoredModels) { Property.prototype.sampleValue = function(isArray, ignoredModels, representations) {
isArray = (isArray || this.isArray()); isArray = (isArray || this.isArray());
ignoredModels = (ignoredModels || {}); ignoredModels = (ignoredModels || {});
// representations = (representations || {});
var type = getStringSignature(this.obj, true); var type = getStringSignature(this.obj, true);
var output; var output;
if(this.$ref) { if(this.$ref) {
var refModelName = simpleRef(this.$ref); var refModelName = simpleRef(this.$ref);
var refModel = models[refModelName]; var refModel = models[refModelName];
if(typeof representations[type] !== 'undefined') {
return representations[type];
}
else
if(refModel && typeof ignoredModels[type] === 'undefined') { if(refModel && typeof ignoredModels[type] === 'undefined') {
ignoredModels[type] = this; ignoredModels[type] = this;
output = refModel.getSampleValue(ignoredModels); output = refModel.getSampleValue(ignoredModels, representations);
representations[type] = output;
} }
else { else {
output = refModelName; output = (representations[type] || refModelName);
} }
} }
else if(this.example) else if(this.example)
@@ -1574,6 +1860,7 @@ SwaggerClient.prototype.buildFrom1_2Spec = function (response) {
res = new SwaggerResource(response, this); res = new SwaggerResource(response, this);
this.apis[newName] = res; this.apis[newName] = res;
this.apisArray.push(res); this.apisArray.push(res);
this.finish();
} else { } else {
var k; var k;
this.expectedResourceCount = response.apis.length; this.expectedResourceCount = response.apis.length;
@@ -1591,6 +1878,7 @@ SwaggerClient.prototype.buildFrom1_2Spec = function (response) {
SwaggerClient.prototype.finish = function() { SwaggerClient.prototype.finish = function() {
if (typeof this.success === 'function') { if (typeof this.success === 'function') {
this.isValid = true; this.isValid = true;
this.ready = true;
this.isBuilt = true; this.isBuilt = true;
this.selfReflect(); this.selfReflect();
this.success(); this.success();
@@ -1628,7 +1916,9 @@ SwaggerClient.prototype.buildFrom1_1Spec = function (response) {
res = new SwaggerResource(response, this); res = new SwaggerResource(response, this);
this.apis[newName] = res; this.apis[newName] = res;
this.apisArray.push(res); this.apisArray.push(res);
this.finish();
} else { } else {
this.expectedResourceCount = response.apis.length;
for (k = 0; k < response.apis.length; k++) { for (k = 0; k < response.apis.length; k++) {
resource = response.apis[k]; resource = response.apis[k];
res = new SwaggerResource(resource, this); res = new SwaggerResource(resource, this);
@@ -1637,9 +1927,6 @@ SwaggerClient.prototype.buildFrom1_1Spec = function (response) {
} }
} }
this.isValid = true; this.isValid = true;
if (this.success) {
this.success();
}
return this; return this;
}; };
@@ -1661,16 +1948,18 @@ SwaggerClient.prototype.convertInfo = function (resp) {
}; };
SwaggerClient.prototype.selfReflect = function () { SwaggerClient.prototype.selfReflect = function () {
var resource, resource_name, ref; var resource, tag, ref;
if (this.apis === null) { if (this.apis === null) {
return false; return false;
} }
ref = this.apis; ref = this.apis;
for (resource_name in ref) { for (tag in ref) {
resource = ref[resource_name]; api = ref[tag];
if (resource.ready === null) { if (api.ready === null) {
return false; return false;
} }
this[tag] = api;
this[tag].help = __bind(api.help, api);
} }
this.setConsolidatedModels(); this.setConsolidatedModels();
this.ready = true; this.ready = true;
@@ -1706,7 +1995,6 @@ var SwaggerResource = function (resourceObj, api) {
this.description = resourceObj.description; this.description = resourceObj.description;
this.authorizations = (resourceObj.authorizations || {}); this.authorizations = (resourceObj.authorizations || {});
var parts = this.path.split('/'); var 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;
@@ -1755,6 +2043,21 @@ var SwaggerResource = function (resourceObj, api) {
} }
}; };
SwaggerResource.prototype.help = function (dontPrint) {
var i;
var output = 'operations for the "' + this.name + '" tag';
for(i = 0; i < this.operationsArray.length; i++) {
var api = this.operationsArray[i];
output += '\n * ' + api.nickname + ': ' + api.description;
}
if(dontPrint)
return output;
else {
log(output);
return output;
}
};
SwaggerResource.prototype.getAbsoluteBasePath = function (relativeBasePath) { SwaggerResource.prototype.getAbsoluteBasePath = function (relativeBasePath) {
var pos, url; var pos, url;
url = this.api.basePath; url = this.api.basePath;
@@ -1786,7 +2089,7 @@ SwaggerResource.prototype.addApiDeclaration = function (response) {
if (typeof response.consumes === 'string') if (typeof response.consumes === 'string')
this.consumes = response.consumes; this.consumes = response.consumes;
if ((typeof response.basePath === 'string') && response.basePath.replace(/\s/g, '').length > 0) if ((typeof response.basePath === 'string') && response.basePath.replace(/\s/g, '').length > 0)
this.basePath = response.basePath.indexOf('http') === -1 ? this.getAbsoluteBasePath(response.basePath) : response.basePath; this.basePath = response.basePath.indexOf('http') !== 0 ? this.getAbsoluteBasePath(response.basePath) : response.basePath;
this.resourcePath = response.resourcePath; this.resourcePath = response.resourcePath;
this.addModels(response.models); this.addModels(response.models);
if (response.apis) { if (response.apis) {
@@ -2071,6 +2374,7 @@ var SwaggerOperation = function (nickname, path, method, parameters, summary, no
this.deprecated = deprecated; this.deprecated = deprecated;
this['do'] = __bind(this['do'], this); this['do'] = __bind(this['do'], this);
if(typeof this.deprecated === 'string') { if(typeof this.deprecated === 'string') {
switch(this.deprecated.toLowerCase()) { switch(this.deprecated.toLowerCase()) {
case 'true': case 'yes': case '1': { case 'true': case 'yes': case '1': {
@@ -2188,8 +2492,8 @@ var SwaggerOperation = function (nickname, path, method, parameters, summary, no
return _this['do'](arg1 || {}, arg2 || {}, arg3 || defaultSuccessCallback, arg4 || defaultErrorCallback); return _this['do'](arg1 || {}, arg2 || {}, arg3 || defaultSuccessCallback, arg4 || defaultErrorCallback);
}; };
this.resource[this.nickname].help = function () { this.resource[this.nickname].help = function (dontPrint) {
return _this.help(); return _this.help(dontPrint);
}; };
this.resource[this.nickname].asCurl = function (args) { this.resource[this.nickname].asCurl = function (args) {
return _this.asCurl(args); return _this.asCurl(args);
@@ -2356,7 +2660,7 @@ SwaggerOperation.prototype.urlify = function (args) {
if (param.paramType === 'path') { if (param.paramType === 'path') {
if (typeof args[param.name] !== 'undefined') { if (typeof args[param.name] !== 'undefined') {
// apply path params and remove from args // apply path params and remove from args
var reg = new RegExp('\\{\\s*?' + param.name + '.*?\\}(?=\\s*?(\\/?|$))', 'gi'); var reg = new RegExp('\\{\\s*?' + param.name + '[^\\{\\}\\/]*(?:\\{.*?\\}[^\\{\\}\\/]*)*\\}(?=(\\/?|$))', 'gi');
url = url.replace(reg, this.encodePathParam(args[param.name])); url = url.replace(reg, this.encodePathParam(args[param.name]));
delete args[param.name]; delete args[param.name];
} }
@@ -2428,16 +2732,19 @@ SwaggerOperation.prototype.getMatchingParams = function (paramTypes, args) {
return matchingParams; return matchingParams;
}; };
SwaggerOperation.prototype.help = function () { SwaggerOperation.prototype.help = function (dontPrint) {
var msg = ''; var msg = this.nickname + ': ' + this.summary;
var params = this.parameters; var params = this.parameters;
for (var i = 0; i < params.length; i++) { for (var i = 0; i < params.length; i++) {
var param = params[i]; var param = params[i];
if (msg !== '') msg += '\n* ' + param.name + (param.required ? ' (required)' : '') + " - " + param.description;
msg += '\n';
msg += '* ' + param.name + (param.required ? ' (required)' : '') + " - " + param.description;
} }
if(dontPrint)
return msg; return msg;
else {
console.log(msg);
return msg;
}
}; };
SwaggerOperation.prototype.asCurl = function (args) { SwaggerOperation.prototype.asCurl = function (args) {
@@ -2724,20 +3031,26 @@ SwaggerRequest.prototype.setHeaders = function (params, opts, operation) {
*/ */
var SwaggerHttp = function() {}; var SwaggerHttp = function() {};
SwaggerHttp.prototype.execute = function(obj) { SwaggerHttp.prototype.execute = function(obj, opts) {
if(obj && (typeof obj.useJQuery === 'boolean')) if(obj && (typeof obj.useJQuery === 'boolean'))
this.useJQuery = obj.useJQuery; this.useJQuery = obj.useJQuery;
else else
this.useJQuery = this.isIE8(); this.useJQuery = this.isIE8();
if(obj && typeof obj.body === 'object') { if(obj && typeof obj.body === 'object') {
if(obj.body.type && obj.body.type !== 'formData')
obj.body = JSON.stringify(obj.body); obj.body = JSON.stringify(obj.body);
else {
obj.contentType = false;
obj.processData = false;
delete obj.headers['Content-Type'];
}
} }
if(this.useJQuery) if(this.useJQuery)
return new JQueryHttpClient().execute(obj); return new JQueryHttpClient(opts).execute(obj);
else else
return new ShredHttpClient().execute(obj); return new ShredHttpClient(opts).execute(obj);
}; };
SwaggerHttp.prototype.isIE8 = function() { SwaggerHttp.prototype.isIE8 = function() {
@@ -2772,7 +3085,9 @@ JQueryHttpClient.prototype.execute = function(obj) {
obj.type = obj.method; obj.type = obj.method;
obj.cache = false; obj.cache = false;
delete obj.useJQuery;
/*
obj.beforeSend = function(xhr) { obj.beforeSend = function(xhr) {
var key, results; var key, results;
if (obj.headers) { if (obj.headers) {
@@ -2788,9 +3103,10 @@ JQueryHttpClient.prototype.execute = function(obj) {
} }
return results; return results;
} }
}; };*/
obj.data = obj.body; obj.data = obj.body;
delete obj.body;
obj.complete = function(response, textStatus, opts) { obj.complete = function(response, textStatus, opts) {
var headers = {}, var headers = {},
headerArray = response.getAllResponseHeaders().split("\n"); headerArray = response.getAllResponseHeaders().split("\n");
@@ -2814,6 +3130,7 @@ JQueryHttpClient.prototype.execute = function(obj) {
url: request.url, url: request.url,
method: request.method, method: request.method,
status: response.status, status: response.status,
statusText: response.statusText,
data: response.responseText, data: response.responseText,
headers: headers headers: headers
}; };
@@ -2845,8 +3162,8 @@ JQueryHttpClient.prototype.execute = function(obj) {
/* /*
* ShredHttpClient is a light-weight, node or browser HTTP client * ShredHttpClient is a light-weight, node or browser HTTP client
*/ */
var ShredHttpClient = function(options) { var ShredHttpClient = function(opts) {
this.options = (options||{}); this.opts = (opts||{});
this.isInitialized = false; this.isInitialized = false;
var identity, toString; var identity, toString;
@@ -2857,7 +3174,7 @@ var ShredHttpClient = function(options) {
} }
else else
this.Shred = require("shred"); this.Shred = require("shred");
this.shred = new this.Shred(options); this.shred = new this.Shred(opts);
}; };
ShredHttpClient.prototype.initShred = function () { ShredHttpClient.prototype.initShred = function () {
@@ -2963,7 +3280,7 @@ ShredHttpClient.prototype.execute = function(obj) {
var e = (typeof window !== 'undefined' ? window : exports); var e = (typeof window !== 'undefined' ? window : exports);
e.authorizations = new SwaggerAuthorizations(); e.authorizations = authorizations = new SwaggerAuthorizations();
e.ApiKeyAuthorization = ApiKeyAuthorization; e.ApiKeyAuthorization = ApiKeyAuthorization;
e.PasswordAuthorization = PasswordAuthorization; e.PasswordAuthorization = PasswordAuthorization;
e.CookieAuthorization = CookieAuthorization; e.CookieAuthorization = CookieAuthorization;
@@ -2972,5 +3289,5 @@ e.SwaggerApi = SwaggerClient;
e.Operation = Operation; e.Operation = Operation;
e.Model = Model; e.Model = Model;
e.addModel = addModel; e.addModel = addModel;
e.Resolver = Resolver;
})(); })();

View File

@@ -15,8 +15,8 @@ function handleLogin() {
var defs = auths; var defs = auths;
for(key in defs) { for(key in defs) {
var auth = defs[key]; var auth = defs[key];
oauth2KeyName = key;
if(auth.type === 'oauth2' && auth.scopes) { if(auth.type === 'oauth2' && auth.scopes) {
oauth2KeyName = key;
var scope; var scope;
if(Array.isArray(auth.scopes)) { if(Array.isArray(auth.scopes)) {
// 1.2 support // 1.2 support

View File

@@ -2,7 +2,7 @@
"name": "swagger-ui", "name": "swagger-ui",
"author": "Tony Tam <fehguy@gmail.com>", "author": "Tony Tam <fehguy@gmail.com>",
"description": "Swagger UI is a dependency-free collection of HTML, Javascript, and CSS assets that dynamically generate beautiful documentation from a Swagger-compliant API", "description": "Swagger UI is a dependency-free collection of HTML, Javascript, and CSS assets that dynamically generate beautiful documentation from a Swagger-compliant API",
"version": "2.1.4-M1", "version": "2.1.5-M1",
"homepage": "http://swagger.io", "homepage": "http://swagger.io",
"license": "Apache 2.0", "license": "Apache 2.0",
"scripts": { "scripts": {
@@ -18,7 +18,7 @@
"dependencies": { "dependencies": {
"shred": "0.8.10", "shred": "0.8.10",
"btoa": "1.1.1", "btoa": "1.1.1",
"swagger-client": "2.1.4-M1" "swagger-client": "2.1.5-M1"
}, },
"devDependencies": { "devDependencies": {
"chai": "^1.10.0", "chai": "^1.10.0",

View File

@@ -33,7 +33,7 @@
window.swaggerUi = new SwaggerUi({ window.swaggerUi = new SwaggerUi({
url: url, url: url,
dom_id: "swagger-ui-container", dom_id: "swagger-ui-container",
supportedSubmitMethods: ['get', 'post', 'put', 'delete'], supportedSubmitMethods: ['get', 'post', 'put', 'delete', 'patch'],
onComplete: function(swaggerApi, swaggerUi){ onComplete: function(swaggerApi, swaggerUi){
if(typeof initOAuth == "function") { if(typeof initOAuth == "function") {
/* /*