Skip to content
This repository has been archived by the owner on Jan 11, 2021. It is now read-only.

Fix of a bug that happens when the user defines prototype functions for Array #729

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
342 changes: 172 additions & 170 deletions rest_framework_swagger/static/rest_framework_swagger/swagger-ui.js
Original file line number Diff line number Diff line change
Expand Up @@ -2401,15 +2401,17 @@ Resolver.prototype.resolve = function (spec, arg1, arg2, arg3) {
var sharedParameters = path.parameters || [];
var parameters = operation.parameters || [];

for (i in sharedParameters) {
// "for i in object" loops through all the enumerable properties of the object itself and those the object
// inherits from its constructor's prototype, so it is safer to iterate through the length
for (var i = 0; i < sharedParameters.length; i++) {
var parameter = sharedParameters[i];
parameters.unshift(parameter);
}
if(method !== 'parameters' && _.isObject(operation)) {
operation.parameters = operation.parameters || parameters;
}

for (i in parameters) {
for (var i = 0; i < parameters.length; i++) {
var parameter = parameters[i];
location = '/paths' + name + '/' + method + '/parameters';

Expand Down Expand Up @@ -2721,7 +2723,7 @@ Resolver.prototype.finish = function (spec, root, resolutionTable, resolvedRefs,

for (key in resolvedTo.obj) {
var abs = resolvedTo.obj[key];

if (localResolve !== true) {
// don't retain root for local definitions
abs = this.retainRoot(resolvedTo.obj[key], item.root);
Expand Down Expand Up @@ -18275,7 +18277,7 @@ Request.prototype.type = function(type){
};

/**
* Set responseType to `val`. Presently valid responseTypes are 'blob' and
* Set responseType to `val`. Presently valid responseTypes are 'blob' and
* 'arraybuffer'.
*
* Examples:
Expand Down Expand Up @@ -18988,169 +18990,169 @@ function request(RequestConstructor, method, url) {
module.exports = request;

},{}],162:[function(require,module,exports){
/**
* Expose `Emitter`.
*/
if (typeof module !== 'undefined') {
module.exports = Emitter;
}
/**
* Initialize a new `Emitter`.
*
* @api public
*/
function Emitter(obj) {
if (obj) return mixin(obj);
};
/**
* Mixin the emitter properties.
*
* @param {Object} obj
* @return {Object}
* @api private
*/
function mixin(obj) {
for (var key in Emitter.prototype) {
obj[key] = Emitter.prototype[key];
}
return obj;
}
/**
* Listen on the given `event` with `fn`.
*
* @param {String} event
* @param {Function} fn
* @return {Emitter}
* @api public
*/
Emitter.prototype.on =
Emitter.prototype.addEventListener = function(event, fn){
this._callbacks = this._callbacks || {};
(this._callbacks['$' + event] = this._callbacks['$' + event] || [])
.push(fn);
return this;
};
/**
* Adds an `event` listener that will be invoked a single
* time then automatically removed.
*
* @param {String} event
* @param {Function} fn
* @return {Emitter}
* @api public
*/
Emitter.prototype.once = function(event, fn){
function on() {
this.off(event, on);
fn.apply(this, arguments);
}
on.fn = fn;
this.on(event, on);
return this;
};
/**
* Remove the given callback for `event` or all
* registered callbacks.
*
* @param {String} event
* @param {Function} fn
* @return {Emitter}
* @api public
*/
Emitter.prototype.off =
Emitter.prototype.removeListener =
Emitter.prototype.removeAllListeners =
Emitter.prototype.removeEventListener = function(event, fn){
this._callbacks = this._callbacks || {};
// all
if (0 == arguments.length) {
this._callbacks = {};
return this;
}
// specific event
var callbacks = this._callbacks['$' + event];
if (!callbacks) return this;
// remove all handlers
if (1 == arguments.length) {
delete this._callbacks['$' + event];
return this;
}
// remove specific handler
var cb;
for (var i = 0; i < callbacks.length; i++) {
cb = callbacks[i];
if (cb === fn || cb.fn === fn) {
callbacks.splice(i, 1);
break;
}
}
return this;
};
/**
* Emit `event` with the given args.
*
* @param {String} event
* @param {Mixed} ...
* @return {Emitter}
*/
Emitter.prototype.emit = function(event){
this._callbacks = this._callbacks || {};
var args = [].slice.call(arguments, 1)
, callbacks = this._callbacks['$' + event];
if (callbacks) {
callbacks = callbacks.slice(0);
for (var i = 0, len = callbacks.length; i < len; ++i) {
callbacks[i].apply(this, args);
}
}
return this;
};
/**
* Return array of callbacks for `event`.
*
* @param {String} event
* @return {Array}
* @api public
*/
Emitter.prototype.listeners = function(event){
this._callbacks = this._callbacks || {};
return this._callbacks['$' + event] || [];
};
/**
* Check if this emitter has `event` handlers.
*
* @param {String} event
* @return {Boolean}
* @api public
*/
Emitter.prototype.hasListeners = function(event){
return !! this.listeners(event).length;
};

/**
* Expose `Emitter`.
*/

if (typeof module !== 'undefined') {
module.exports = Emitter;
}

/**
* Initialize a new `Emitter`.
*
* @api public
*/

function Emitter(obj) {
if (obj) return mixin(obj);
};

/**
* Mixin the emitter properties.
*
* @param {Object} obj
* @return {Object}
* @api private
*/

function mixin(obj) {
for (var key in Emitter.prototype) {
obj[key] = Emitter.prototype[key];
}
return obj;
}

/**
* Listen on the given `event` with `fn`.
*
* @param {String} event
* @param {Function} fn
* @return {Emitter}
* @api public
*/

Emitter.prototype.on =
Emitter.prototype.addEventListener = function(event, fn){
this._callbacks = this._callbacks || {};
(this._callbacks['$' + event] = this._callbacks['$' + event] || [])
.push(fn);
return this;
};

/**
* Adds an `event` listener that will be invoked a single
* time then automatically removed.
*
* @param {String} event
* @param {Function} fn
* @return {Emitter}
* @api public
*/

Emitter.prototype.once = function(event, fn){
function on() {
this.off(event, on);
fn.apply(this, arguments);
}

on.fn = fn;
this.on(event, on);
return this;
};

/**
* Remove the given callback for `event` or all
* registered callbacks.
*
* @param {String} event
* @param {Function} fn
* @return {Emitter}
* @api public
*/

Emitter.prototype.off =
Emitter.prototype.removeListener =
Emitter.prototype.removeAllListeners =
Emitter.prototype.removeEventListener = function(event, fn){
this._callbacks = this._callbacks || {};

// all
if (0 == arguments.length) {
this._callbacks = {};
return this;
}

// specific event
var callbacks = this._callbacks['$' + event];
if (!callbacks) return this;

// remove all handlers
if (1 == arguments.length) {
delete this._callbacks['$' + event];
return this;
}

// remove specific handler
var cb;
for (var i = 0; i < callbacks.length; i++) {
cb = callbacks[i];
if (cb === fn || cb.fn === fn) {
callbacks.splice(i, 1);
break;
}
}
return this;
};

/**
* Emit `event` with the given args.
*
* @param {String} event
* @param {Mixed} ...
* @return {Emitter}
*/

Emitter.prototype.emit = function(event){
this._callbacks = this._callbacks || {};
var args = [].slice.call(arguments, 1)
, callbacks = this._callbacks['$' + event];

if (callbacks) {
callbacks = callbacks.slice(0);
for (var i = 0, len = callbacks.length; i < len; ++i) {
callbacks[i].apply(this, args);
}
}

return this;
};

/**
* Return array of callbacks for `event`.
*
* @param {String} event
* @return {Array}
* @api public
*/

Emitter.prototype.listeners = function(event){
this._callbacks = this._callbacks || {};
return this._callbacks['$' + event] || [];
};

/**
* Check if this emitter has `event` handlers.
*
* @param {String} event
* @return {Boolean}
* @api public
*/

Emitter.prototype.hasListeners = function(event){
return !! this.listeners(event).length;
};

},{}],163:[function(require,module,exports){

Expand All @@ -19164,7 +19166,7 @@ Emitter.prototype.hasListeners = function(event){
* TODO: combatible error handling?
*/

module.exports = function(arr, fn, initial){
module.exports = function(arr, fn, initial){
var idx = 0;
var len = arr.length;
var curr = arguments.length == 3
Expand All @@ -19174,7 +19176,7 @@ module.exports = function(arr, fn, initial){
while (idx < len) {
curr = fn.call(null, curr, arr[idx], ++idx, arr);
}

return curr;
};
},{}]},{},[1])(1)
Expand Down Expand Up @@ -22608,4 +22610,4 @@ SwaggerUi.Views.StatusCodeView = Backbone.View.extend({
$('.model-signature', this.$el).append(responseModelView.render().el);
return this;
}
});}).call(this);
});}).call(this);