From 52cf2ed337f44863437a8240a76ba6fd9cc78a6c Mon Sep 17 00:00:00 2001 From: Bryan Hazelbaker Date: Fri, 17 Apr 2015 14:15:40 -0700 Subject: [PATCH 1/3] Forcing old images to not be CRLF conformed due to new gitattributes file. --- .gitattributes | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitattributes b/.gitattributes index 6e42739a..cbcd3fe9 100644 --- a/.gitattributes +++ b/.gitattributes @@ -9,3 +9,5 @@ dist/**/*.woff binary dist/**/*.woff2 binary dist/**/*.png binary dist/*.html text + +src/main/html/images/*.png binary From 9688af989e7f71504312643cc79f7652cd4e7daf Mon Sep 17 00:00:00 2001 From: Vitaliy Kanev <1xamelion1@gmail.com> Date: Sat, 16 May 2015 15:42:50 +0300 Subject: [PATCH 2/3] fixed: REFACTOR handleFileUpload --- src/main/javascript/view/OperationView.js | 72 ++--------------------- 1 file changed, 5 insertions(+), 67 deletions(-) diff --git a/src/main/javascript/view/OperationView.js b/src/main/javascript/view/OperationView.js index 7fbe681c..aadd46aa 100644 --- a/src/main/javascript/view/OperationView.js +++ b/src/main/javascript/view/OperationView.js @@ -342,76 +342,14 @@ SwaggerUi.Views.OperationView = Backbone.View.extend({ parent.showCompleteStatus(response); }, - // Note: This is compiled code - // TODO: Refactor - handleFileUpload: function(map, form) { - var bodyParam, el, headerParams, l, len, len1, len2, len3, m, n, o, p, param, params, ref1, ref2, ref3, ref4; - ref1 = form.serializeArray(); - for (l = 0, len = ref1.length; l < len; l++) { - o = ref1[l]; - if ((o.value !== null) && jQuery.trim(o.value).length > 0) { - map[o.name] = o.value; - } - } - bodyParam = new FormData(); - params = 0; - ref2 = this.model.parameters; - for (m = 0, len1 = ref2.length; m < len1; m++) { - param = ref2[m]; - if (param.paramType === 'form' || param['in'] === 'formData') { - if (param.type.toLowerCase() !== 'file' && map[param.name] !== void 0) { - bodyParam.append(param.name, map[param.name]); - } - } - } - headerParams = {}; - ref3 = this.model.parameters; - for (n = 0, len2 = ref3.length; n < len2; n++) { - param = ref3[n]; - if (param.paramType === 'header') { - headerParams[param.name] = map[param.name]; - } - } - ref4 = form.find('input[type~="file"]'); - for (p = 0, len3 = ref4.length; p < len3; p++) { - el = ref4[p]; - if (typeof el.files[0] !== 'undefined') { - bodyParam.append($(el).attr('name'), el.files[0]); - params += 1; - } - } - this.invocationUrl = this.model.supportHeaderParams() ? (headerParams = this.model.getHeaderParams(map), delete headerParams['Content-Type'], this.model.urlify(map, false)) : this.model.urlify(map, true); + handleFileUpload: function(map, form,opts) { $('.request_url', $(this.el)).html('
');
     $('.request_url pre', $(this.el)).text(this.invocationUrl);
 
-    // TODO: don't use jQuery. Use SwaggerJS for handling the call.
-    var obj = {
-      type: this.model.method,
-      url: this.invocationUrl,
-      headers: headerParams,
-      data: bodyParam,
-      dataType: 'json',
-      contentType: false,
-      processData: false,
-      error: (function(_this) {
-        return function(data) {
-          return _this.showErrorStatus(_this.wrap(data), _this);
-        };
-      })(this),
-      success: (function(_this) {
-        return function(data) {
-          return _this.showResponse(data, _this);
-        };
-      })(this),
-      complete: (function(_this) {
-        return function(data) {
-          return _this.showCompleteStatus(_this.wrap(data), _this);
-        };
-      })(this)
-    };
-    jQuery.ajax(obj);
-    return false;
-    // end of file-upload nastiness
+    opts.useJQuery = true;
+    map.parameterContentType = 'multipart/form-data';
+
+    return this.model.execute(map, opts, this.showCompleteStatus, this.showErrorStatus, this);
   },
   // wraps a jquery response as a shred response
 

From 88838213c8938dbf2bfa6672fcba53113a8296b1 Mon Sep 17 00:00:00 2001
From: Vitaliy Kanev <1xamelion1@gmail.com>
Date: Sat, 16 May 2015 15:47:45 +0300
Subject: [PATCH 3/3] remove fileupload function

---
 src/main/javascript/view/OperationView.js | 18 +++++++-----------
 1 file changed, 7 insertions(+), 11 deletions(-)

diff --git a/src/main/javascript/view/OperationView.js b/src/main/javascript/view/OperationView.js
index aadd46aa..7aee6e47 100644
--- a/src/main/javascript/view/OperationView.js
+++ b/src/main/javascript/view/OperationView.js
@@ -331,7 +331,13 @@ SwaggerUi.Views.OperationView = Backbone.View.extend({
       opts.requestContentType = $('div select[name=parameterContentType]', $(this.el)).val();
       $('.response_throbber', $(this.el)).show();
       if (isFileUpload) {
-        return this.handleFileUpload(map, form);
+        $('.request_url', $(this.el)).html('
');
+        $('.request_url pre', $(this.el)).text(this.invocationUrl);
+
+        opts.useJQuery = true;
+        map.parameterContentType = 'multipart/form-data';
+
+        return this.model.execute(map, opts, this.showCompleteStatus, this.showErrorStatus, this);
       } else {
         return this.model.execute(map, opts, this.showCompleteStatus, this.showErrorStatus, this);
       }
@@ -341,16 +347,6 @@ SwaggerUi.Views.OperationView = Backbone.View.extend({
   success: function(response, parent) {
     parent.showCompleteStatus(response);
   },
-
-  handleFileUpload: function(map, form,opts) {
-    $('.request_url', $(this.el)).html('
');
-    $('.request_url pre', $(this.el)).text(this.invocationUrl);
-
-    opts.useJQuery = true;
-    map.parameterContentType = 'multipart/form-data';
-
-    return this.model.execute(map, opts, this.showCompleteStatus, this.showErrorStatus, this);
-  },
   // wraps a jquery response as a shred response
 
   wrap: function(data) {