fix for #602
This commit is contained in:
19
dist/lib/swagger-client.js
vendored
19
dist/lib/swagger-client.js
vendored
@@ -187,6 +187,7 @@ var SwaggerClient = function(url, options) {
|
||||
this.isValid = false;
|
||||
this.info = null;
|
||||
this.useJQuery = false;
|
||||
this.models = models;
|
||||
|
||||
options = (options||{});
|
||||
if (url)
|
||||
@@ -237,10 +238,12 @@ SwaggerClient.prototype.build = function() {
|
||||
if(responseObj.swagger && responseObj.swagger === 2.0) {
|
||||
self.swaggerVersion = responseObj.swagger;
|
||||
self.buildFromSpec(responseObj);
|
||||
this.isValid = true;
|
||||
self.isValid = true;
|
||||
}
|
||||
else {
|
||||
self.isValid = false;
|
||||
self.failure();
|
||||
}
|
||||
else
|
||||
this.isValid = false;
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -418,16 +421,22 @@ var Operation = function(parent, operationId, httpMethod, path, args, definition
|
||||
var model;
|
||||
var responses = this.responses;
|
||||
|
||||
if(responses['200'])
|
||||
if(responses['200']) {
|
||||
response = responses['200'];
|
||||
else if(responses['default'])
|
||||
defaultResponseCode = '200';
|
||||
}
|
||||
else if(responses['default']) {
|
||||
response = responses['default'];
|
||||
defaultResponseCode = 'default';
|
||||
}
|
||||
|
||||
if(response && response.schema) {
|
||||
var resolvedModel = this.resolveModel(response.schema, definitions);
|
||||
if(resolvedModel) {
|
||||
this.type = resolvedModel.name;
|
||||
this.responseSampleJSON = JSON.stringify(resolvedModel.getSampleValue(), null, 2);
|
||||
this.responseClassSignature = resolvedModel.getMockSignature();
|
||||
delete responses[defaultResponseCode];
|
||||
}
|
||||
else {
|
||||
this.type = response.schema.type;
|
||||
|
||||
770
dist/lib/swagger.js
vendored
770
dist/lib/swagger.js
vendored
File diff suppressed because it is too large
Load Diff
46
dist/swagger-ui.js
vendored
46
dist/swagger-ui.js
vendored
@@ -1637,7 +1637,7 @@ helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
|
||||
};
|
||||
|
||||
OperationView.prototype.render = function() {
|
||||
var contentTypeModel, isMethodSubmissionSupported, k, o, param, ref, responseContentTypeView, responseSignatureView, schema, signatureModel, statusCode, type, v, _i, _j, _k, _l, _len, _len1, _len2, _len3, _ref5, _ref6, _ref7, _ref8;
|
||||
var code, contentTypeModel, isMethodSubmissionSupported, k, o, param, ref, responseContentTypeView, responseSignatureView, schema, schemaObj, signatureModel, statusCode, type, v, value, _i, _j, _k, _l, _len, _len1, _len2, _len3, _ref5, _ref6, _ref7, _ref8, _ref9;
|
||||
isMethodSubmissionSupported = true;
|
||||
if (!isMethodSubmissionSupported) {
|
||||
this.model.isReadOnly = true;
|
||||
@@ -1661,6 +1661,29 @@ helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
|
||||
}
|
||||
}
|
||||
}
|
||||
if (typeof this.model.responses !== 'undefined') {
|
||||
this.model.responseMessages = [];
|
||||
_ref6 = this.model.responses;
|
||||
for (code in _ref6) {
|
||||
value = _ref6[code];
|
||||
schema = null;
|
||||
schemaObj = this.model.responses[code].schema;
|
||||
if (schemaObj && schemaObj['$ref']) {
|
||||
schema = schemaObj['$ref'];
|
||||
if (schema.indexOf('#/definitions/') === 0) {
|
||||
schema = schema.substring('#/definitions/'.length);
|
||||
}
|
||||
}
|
||||
this.model.responseMessages.push({
|
||||
code: code,
|
||||
message: value.description,
|
||||
responseModel: schema
|
||||
});
|
||||
}
|
||||
}
|
||||
if (typeof this.model.responseMessages === 'undefined') {
|
||||
this.model.responseMessages = [];
|
||||
}
|
||||
$(this.el).html(Handlebars.templates.operation(this.model));
|
||||
if (this.model.responseClassSignature && this.model.responseClassSignature !== 'string') {
|
||||
signatureModel = {
|
||||
@@ -1682,9 +1705,9 @@ helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
|
||||
};
|
||||
contentTypeModel.consumes = this.model.consumes;
|
||||
contentTypeModel.produces = this.model.produces;
|
||||
_ref6 = this.model.parameters;
|
||||
for (_j = 0, _len1 = _ref6.length; _j < _len1; _j++) {
|
||||
param = _ref6[_j];
|
||||
_ref7 = this.model.parameters;
|
||||
for (_j = 0, _len1 = _ref7.length; _j < _len1; _j++) {
|
||||
param = _ref7[_j];
|
||||
type = param.type || param.dataType;
|
||||
if (typeof type === 'undefined') {
|
||||
schema = param.schema;
|
||||
@@ -1708,17 +1731,14 @@ helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
|
||||
model: contentTypeModel
|
||||
});
|
||||
$('.response-content-type', $(this.el)).append(responseContentTypeView.render().el);
|
||||
_ref7 = this.model.parameters;
|
||||
for (_k = 0, _len2 = _ref7.length; _k < _len2; _k++) {
|
||||
param = _ref7[_k];
|
||||
_ref8 = this.model.parameters;
|
||||
for (_k = 0, _len2 = _ref8.length; _k < _len2; _k++) {
|
||||
param = _ref8[_k];
|
||||
this.addParameter(param, contentTypeModel.consumes);
|
||||
}
|
||||
if (typeof this.model.responseMessages === 'undefined') {
|
||||
this.model.responseMessages = [];
|
||||
}
|
||||
_ref8 = this.model.responseMessages;
|
||||
for (_l = 0, _len3 = _ref8.length; _l < _len3; _l++) {
|
||||
statusCode = _ref8[_l];
|
||||
_ref9 = this.model.responseMessages;
|
||||
for (_l = 0, _len3 = _ref9.length; _l < _len3; _l++) {
|
||||
statusCode = _ref9[_l];
|
||||
this.addStatusCode(statusCode);
|
||||
}
|
||||
return this;
|
||||
|
||||
2
dist/swagger-ui.min.js
vendored
2
dist/swagger-ui.min.js
vendored
File diff suppressed because one or more lines are too long
@@ -187,6 +187,7 @@ var SwaggerClient = function(url, options) {
|
||||
this.isValid = false;
|
||||
this.info = null;
|
||||
this.useJQuery = false;
|
||||
this.models = models;
|
||||
|
||||
options = (options||{});
|
||||
if (url)
|
||||
@@ -237,10 +238,12 @@ SwaggerClient.prototype.build = function() {
|
||||
if(responseObj.swagger && responseObj.swagger === 2.0) {
|
||||
self.swaggerVersion = responseObj.swagger;
|
||||
self.buildFromSpec(responseObj);
|
||||
this.isValid = true;
|
||||
self.isValid = true;
|
||||
}
|
||||
else {
|
||||
self.isValid = false;
|
||||
self.failure();
|
||||
}
|
||||
else
|
||||
this.isValid = false;
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -418,16 +421,22 @@ var Operation = function(parent, operationId, httpMethod, path, args, definition
|
||||
var model;
|
||||
var responses = this.responses;
|
||||
|
||||
if(responses['200'])
|
||||
if(responses['200']) {
|
||||
response = responses['200'];
|
||||
else if(responses['default'])
|
||||
defaultResponseCode = '200';
|
||||
}
|
||||
else if(responses['default']) {
|
||||
response = responses['default'];
|
||||
defaultResponseCode = 'default';
|
||||
}
|
||||
|
||||
if(response && response.schema) {
|
||||
var resolvedModel = this.resolveModel(response.schema, definitions);
|
||||
if(resolvedModel) {
|
||||
this.type = resolvedModel.name;
|
||||
this.responseSampleJSON = JSON.stringify(resolvedModel.getSampleValue(), null, 2);
|
||||
this.responseClassSignature = resolvedModel.getMockSignature();
|
||||
delete responses[defaultResponseCode];
|
||||
}
|
||||
else {
|
||||
this.type = response.schema.type;
|
||||
@@ -446,7 +455,158 @@ OperationGroup.prototype.sort = function(sorter) {
|
||||
|
||||
Operation.prototype.getType = function (param) {
|
||||
var type = param.type;
|
||||
var format = param.format;
|
||||
var format = param.forma/**
|
||||
* SwaggerHttp is a wrapper for executing requests
|
||||
*/
|
||||
var SwaggerHttp = function() {};
|
||||
|
||||
SwaggerHttp.prototype.execute = function(obj) {
|
||||
if(obj && (typeof obj.useJQuery === 'boolean'))
|
||||
this.useJQuery = obj.useJQuery;
|
||||
else
|
||||
this.useJQuery = this.isIE8();
|
||||
|
||||
if(this.useJQuery)
|
||||
return new JQueryHttpClient().execute(obj);
|
||||
else
|
||||
return new ShredHttpClient().execute(obj);
|
||||
}
|
||||
|
||||
SwaggerHttp.prototype.isIE8 = function() {
|
||||
var detectedIE = false;
|
||||
if (typeof navigator !== 'undefined' && navigator.userAgent) {
|
||||
nav = navigator.userAgent.toLowerCase();
|
||||
if (nav.indexOf('msie') !== -1) {
|
||||
var version = parseInt(nav.split('msie')[1]);
|
||||
if (version <= 8) {
|
||||
detectedIE = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return detectedIE;
|
||||
};
|
||||
|
||||
/*
|
||||
* JQueryHttpClient lets a browser take advantage of JQuery's cross-browser magic.
|
||||
* NOTE: when jQuery is available it will export both '$' and 'jQuery' to the global space.
|
||||
* Since we are using closures here we need to alias it for internal use.
|
||||
*/
|
||||
var JQueryHttpClient = function(options) {
|
||||
"use strict";
|
||||
if(!jQuery){
|
||||
var jQuery = window.jQuery;
|
||||
}
|
||||
}
|
||||
|
||||
JQueryHttpClient.prototype.execute = function(obj) {
|
||||
var cb = obj.on;
|
||||
var request = obj;
|
||||
|
||||
obj.type = obj.method;
|
||||
obj.cache = false;
|
||||
|
||||
obj.beforeSend = function(xhr) {
|
||||
var key, results;
|
||||
if (obj.headers) {
|
||||
results = [];
|
||||
var key;
|
||||
for (key in obj.headers) {
|
||||
if (key.toLowerCase() === "content-type") {
|
||||
results.push(obj.contentType = obj.headers[key]);
|
||||
} else if (key.toLowerCase() === "accept") {
|
||||
results.push(obj.accepts = obj.headers[key]);
|
||||
} else {
|
||||
results.push(xhr.setRequestHeader(key, obj.headers[key]));
|
||||
}
|
||||
}
|
||||
return results;
|
||||
}
|
||||
};
|
||||
|
||||
obj.data = obj.body;
|
||||
obj.complete = function(response, textStatus, opts) {
|
||||
var headers = {},
|
||||
headerArray = response.getAllResponseHeaders().split("\n");
|
||||
|
||||
for(var i = 0; i < headerArray.length; i++) {
|
||||
var toSplit = headerArray[i].trim();
|
||||
if(toSplit.length === 0)
|
||||
continue;
|
||||
var separator = toSplit.indexOf(":");
|
||||
if(separator === -1) {
|
||||
// Name but no value in the header
|
||||
headers[toSplit] = null;
|
||||
continue;
|
||||
}
|
||||
var name = toSplit.substring(0, separator).trim(),
|
||||
value = toSplit.substring(separator + 1).trim();
|
||||
headers[name] = value;
|
||||
}
|
||||
|
||||
var out = {
|
||||
url: request.url,
|
||||
method: request.method,
|
||||
status: response.status,
|
||||
data: response.responseText,
|
||||
headers: headers
|
||||
};
|
||||
|
||||
var contentType = (headers["content-type"]||headers["Content-Type"]||null)
|
||||
|
||||
if(contentType != null) {
|
||||
if(contentType.indexOf("application/json") == 0 || contentType.indexOf("+json") > 0) {
|
||||
if(response.responseText && response.responseText !== "")
|
||||
out.obj = JSON.parse(response.responseText);
|
||||
else
|
||||
out.obj = {}
|
||||
}
|
||||
}
|
||||
|
||||
if(response.status >= 200 && response.status < 300)
|
||||
cb.response(out);
|
||||
else if(response.status === 0 || (response.status >= 400 && response.status < 599))
|
||||
cb.error(out);
|
||||
else
|
||||
return cb.response(out);
|
||||
};
|
||||
|
||||
jQuery.support.cors = true;
|
||||
return jQuery.ajax(obj);
|
||||
}
|
||||
|
||||
/*
|
||||
* ShredHttpClient is a light-weight, node or browser HTTP client
|
||||
*/
|
||||
var ShredHttpClient = function(options) {
|
||||
this.options = (options||{});
|
||||
this.isInitialized = false;
|
||||
|
||||
var identity, toString;
|
||||
|
||||
if (typeof window !== 'undefined') {
|
||||
this.Shred = require("./shred");
|
||||
this.content = require("./shred/content");
|
||||
}
|
||||
else
|
||||
this.Shred = require("shred");
|
||||
this.shred = new this.Shred();
|
||||
}
|
||||
|
||||
ShredHttpClient.prototype.initShred = function () {
|
||||
this.isInitialized = true;
|
||||
this.registerProcessors(this.shred);
|
||||
}
|
||||
|
||||
ShredHttpClient.prototype.registerProcessors = function(shred) {
|
||||
var identity = function(x) {
|
||||
return x;
|
||||
};
|
||||
var toString = function(x) {
|
||||
return x.toString();
|
||||
};
|
||||
|
||||
if (typeof window !== 'undefined') {
|
||||
this.content.registerProcessor(["application/json; charset=utf-8", "application/jsot;
|
||||
var isArray = false;
|
||||
var str;
|
||||
if(type === 'integer' && format === 'int32')
|
||||
@@ -608,7 +768,69 @@ Operation.prototype.execute = function(arg1, arg2, arg3, arg4, parent) {
|
||||
return;
|
||||
}
|
||||
|
||||
// set content type negotiation
|
||||
// set content typn", "json"], {
|
||||
parser: identity,
|
||||
stringify: toString
|
||||
});
|
||||
} else {
|
||||
this.Shred.registerProcessor(["application/json; charset=utf-8", "application/json", "json"], {
|
||||
parser: identity,
|
||||
stringify: toString
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
ShredHttpClient.prototype.execute = function(obj) {
|
||||
if(!this.isInitialized)
|
||||
this.initShred();
|
||||
|
||||
var cb = obj.on, res;
|
||||
|
||||
var transform = function(response) {
|
||||
var out = {
|
||||
headers: response._headers,
|
||||
url: response.request.url,
|
||||
method: response.request.method,
|
||||
status: response.status,
|
||||
data: response.content.data
|
||||
};
|
||||
|
||||
var contentType = (response._headers["content-type"]||response._headers["Content-Type"]||null)
|
||||
|
||||
if(contentType != null) {
|
||||
if(contentType.indexOf("application/json") == 0 || contentType.indexOf("+json") > 0) {
|
||||
if(response.content.data && response.content.data !== "")
|
||||
out.obj = JSON.parse(response.content.data);
|
||||
else
|
||||
out.obj = {}
|
||||
}
|
||||
}
|
||||
return out;
|
||||
};
|
||||
|
||||
res = {
|
||||
error: function(response) {
|
||||
if (obj)
|
||||
return cb.error(transform(response));
|
||||
},
|
||||
redirect: function(response) {
|
||||
if (obj)
|
||||
return cb.redirect(transform(response));
|
||||
},
|
||||
307: function(response) {
|
||||
if (obj)
|
||||
return cb.redirect(transform(response));
|
||||
},
|
||||
response: function(response) {
|
||||
if (obj)
|
||||
return cb.response(transform(response));
|
||||
}
|
||||
};
|
||||
if (obj) {
|
||||
obj.on = res;
|
||||
}
|
||||
return this.shred.request(obj);
|
||||
};e negotiation
|
||||
var consumes = this.consumes || this.parent.consumes || [ 'application/json' ];
|
||||
var produces = this.produces || this.parent.produces || [ 'application/json' ];
|
||||
|
||||
@@ -1112,217 +1334,4 @@ e.authorizations = new SwaggerAuthorizations();
|
||||
e.ApiKeyAuthorization = ApiKeyAuthorization;
|
||||
e.PasswordAuthorization = PasswordAuthorization;
|
||||
e.CookieAuthorization = CookieAuthorization;
|
||||
e.SwaggerClient = SwaggerClient;/**
|
||||
* SwaggerHttp is a wrapper for executing requests
|
||||
*/
|
||||
var SwaggerHttp = function() {};
|
||||
|
||||
SwaggerHttp.prototype.execute = function(obj) {
|
||||
if(obj && (typeof obj.useJQuery === 'boolean'))
|
||||
this.useJQuery = obj.useJQuery;
|
||||
else
|
||||
this.useJQuery = this.isIE8();
|
||||
|
||||
if(this.useJQuery)
|
||||
return new JQueryHttpClient().execute(obj);
|
||||
else
|
||||
return new ShredHttpClient().execute(obj);
|
||||
}
|
||||
|
||||
SwaggerHttp.prototype.isIE8 = function() {
|
||||
var detectedIE = false;
|
||||
if (typeof navigator !== 'undefined' && navigator.userAgent) {
|
||||
nav = navigator.userAgent.toLowerCase();
|
||||
if (nav.indexOf('msie') !== -1) {
|
||||
var version = parseInt(nav.split('msie')[1]);
|
||||
if (version <= 8) {
|
||||
detectedIE = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return detectedIE;
|
||||
};
|
||||
|
||||
/*
|
||||
* JQueryHttpClient lets a browser take advantage of JQuery's cross-browser magic.
|
||||
* NOTE: when jQuery is available it will export both '$' and 'jQuery' to the global space.
|
||||
* Since we are using closures here we need to alias it for internal use.
|
||||
*/
|
||||
var JQueryHttpClient = function(options) {
|
||||
"use strict";
|
||||
if(!jQuery){
|
||||
var jQuery = window.jQuery;
|
||||
}
|
||||
}
|
||||
|
||||
JQueryHttpClient.prototype.execute = function(obj) {
|
||||
var cb = obj.on;
|
||||
var request = obj;
|
||||
|
||||
obj.type = obj.method;
|
||||
obj.cache = false;
|
||||
|
||||
obj.beforeSend = function(xhr) {
|
||||
var key, results;
|
||||
if (obj.headers) {
|
||||
results = [];
|
||||
var key;
|
||||
for (key in obj.headers) {
|
||||
if (key.toLowerCase() === "content-type") {
|
||||
results.push(obj.contentType = obj.headers[key]);
|
||||
} else if (key.toLowerCase() === "accept") {
|
||||
results.push(obj.accepts = obj.headers[key]);
|
||||
} else {
|
||||
results.push(xhr.setRequestHeader(key, obj.headers[key]));
|
||||
}
|
||||
}
|
||||
return results;
|
||||
}
|
||||
};
|
||||
|
||||
obj.data = obj.body;
|
||||
obj.complete = function(response, textStatus, opts) {
|
||||
var headers = {},
|
||||
headerArray = response.getAllResponseHeaders().split("\n");
|
||||
|
||||
for(var i = 0; i < headerArray.length; i++) {
|
||||
var toSplit = headerArray[i].trim();
|
||||
if(toSplit.length === 0)
|
||||
continue;
|
||||
var separator = toSplit.indexOf(":");
|
||||
if(separator === -1) {
|
||||
// Name but no value in the header
|
||||
headers[toSplit] = null;
|
||||
continue;
|
||||
}
|
||||
var name = toSplit.substring(0, separator).trim(),
|
||||
value = toSplit.substring(separator + 1).trim();
|
||||
headers[name] = value;
|
||||
}
|
||||
|
||||
var out = {
|
||||
url: request.url,
|
||||
method: request.method,
|
||||
status: response.status,
|
||||
data: response.responseText,
|
||||
headers: headers
|
||||
};
|
||||
|
||||
var contentType = (headers["content-type"]||headers["Content-Type"]||null)
|
||||
|
||||
if(contentType != null) {
|
||||
if(contentType.indexOf("application/json") == 0 || contentType.indexOf("+json") > 0) {
|
||||
if(response.responseText && response.responseText !== "")
|
||||
out.obj = JSON.parse(response.responseText);
|
||||
else
|
||||
out.obj = {}
|
||||
}
|
||||
}
|
||||
|
||||
if(response.status >= 200 && response.status < 300)
|
||||
cb.response(out);
|
||||
else if(response.status === 0 || (response.status >= 400 && response.status < 599))
|
||||
cb.error(out);
|
||||
else
|
||||
return cb.response(out);
|
||||
};
|
||||
|
||||
jQuery.support.cors = true;
|
||||
return jQuery.ajax(obj);
|
||||
}
|
||||
|
||||
/*
|
||||
* ShredHttpClient is a light-weight, node or browser HTTP client
|
||||
*/
|
||||
var ShredHttpClient = function(options) {
|
||||
this.options = (options||{});
|
||||
this.isInitialized = false;
|
||||
|
||||
var identity, toString;
|
||||
|
||||
if (typeof window !== 'undefined') {
|
||||
this.Shred = require("./shred");
|
||||
this.content = require("./shred/content");
|
||||
}
|
||||
else
|
||||
this.Shred = require("shred");
|
||||
this.shred = new this.Shred();
|
||||
}
|
||||
|
||||
ShredHttpClient.prototype.initShred = function () {
|
||||
this.isInitialized = true;
|
||||
this.registerProcessors(this.shred);
|
||||
}
|
||||
|
||||
ShredHttpClient.prototype.registerProcessors = function(shred) {
|
||||
var identity = function(x) {
|
||||
return x;
|
||||
};
|
||||
var toString = function(x) {
|
||||
return x.toString();
|
||||
};
|
||||
|
||||
if (typeof window !== 'undefined') {
|
||||
this.content.registerProcessor(["application/json; charset=utf-8", "application/json", "json"], {
|
||||
parser: identity,
|
||||
stringify: toString
|
||||
});
|
||||
} else {
|
||||
this.Shred.registerProcessor(["application/json; charset=utf-8", "application/json", "json"], {
|
||||
parser: identity,
|
||||
stringify: toString
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
ShredHttpClient.prototype.execute = function(obj) {
|
||||
if(!this.isInitialized)
|
||||
this.initShred();
|
||||
|
||||
var cb = obj.on, res;
|
||||
|
||||
var transform = function(response) {
|
||||
var out = {
|
||||
headers: response._headers,
|
||||
url: response.request.url,
|
||||
method: response.request.method,
|
||||
status: response.status,
|
||||
data: response.content.data
|
||||
};
|
||||
|
||||
var contentType = (response._headers["content-type"]||response._headers["Content-Type"]||null)
|
||||
|
||||
if(contentType != null) {
|
||||
if(contentType.indexOf("application/json") == 0 || contentType.indexOf("+json") > 0) {
|
||||
if(response.content.data && response.content.data !== "")
|
||||
out.obj = JSON.parse(response.content.data);
|
||||
else
|
||||
out.obj = {}
|
||||
}
|
||||
}
|
||||
return out;
|
||||
};
|
||||
|
||||
res = {
|
||||
error: function(response) {
|
||||
if (obj)
|
||||
return cb.error(transform(response));
|
||||
},
|
||||
redirect: function(response) {
|
||||
if (obj)
|
||||
return cb.redirect(transform(response));
|
||||
},
|
||||
307: function(response) {
|
||||
if (obj)
|
||||
return cb.redirect(transform(response));
|
||||
},
|
||||
response: function(response) {
|
||||
if (obj)
|
||||
return cb.response(transform(response));
|
||||
}
|
||||
};
|
||||
if (obj) {
|
||||
obj.on = res;
|
||||
}
|
||||
return this.shred.request(obj);
|
||||
};
|
||||
e.SwaggerClient = SwaggerClient;
|
||||
@@ -55,6 +55,20 @@ class OperationView extends Backbone.View
|
||||
for o in v
|
||||
@model.oauth.scopes.push o
|
||||
|
||||
if typeof @model.responses isnt 'undefined'
|
||||
@model.responseMessages = []
|
||||
for code, value of @model.responses
|
||||
schema = null
|
||||
schemaObj = @model.responses[code].schema
|
||||
if schemaObj and schemaObj['$ref']
|
||||
schema = schemaObj['$ref']
|
||||
if schema.indexOf('#/definitions/') is 0
|
||||
schema = schema.substring('#/definitions/'.length)
|
||||
@model.responseMessages.push {code: code, message: value.description, responseModel: schema }
|
||||
|
||||
if typeof @model.responseMessages is 'undefined'
|
||||
@model.responseMessages = []
|
||||
|
||||
$(@el).html(Handlebars.templates.operation(@model))
|
||||
|
||||
if @model.responseClassSignature and @model.responseClassSignature != 'string'
|
||||
@@ -97,8 +111,6 @@ class OperationView extends Backbone.View
|
||||
@addParameter param, contentTypeModel.consumes for param in @model.parameters
|
||||
|
||||
# Render each response code
|
||||
if typeof @model.responseMessages is 'undefined'
|
||||
@model.responseMessages = []
|
||||
@addStatusCode statusCode for statusCode in @model.responseMessages
|
||||
|
||||
@
|
||||
|
||||
Reference in New Issue
Block a user