From 95fea615a9ffb5962586a8f0d0f58a46e41d49bd Mon Sep 17 00:00:00 2001 From: Tony Tam Date: Wed, 17 Jul 2013 16:02:47 -0700 Subject: [PATCH] fix for #263 --- src/main/coffeescript/SwaggerUi.coffee | 17 ++++++++++++++++- src/main/coffeescript/view/OperationView.coffee | 9 ++++++++- src/main/coffeescript/view/ParameterView.coffee | 2 +- src/main/template/param.handlebars | 1 + 4 files changed, 26 insertions(+), 3 deletions(-) diff --git a/src/main/coffeescript/SwaggerUi.coffee b/src/main/coffeescript/SwaggerUi.coffee index 4b122d96ee3..9bb40fd08ce 100644 --- a/src/main/coffeescript/SwaggerUi.coffee +++ b/src/main/coffeescript/SwaggerUi.coffee @@ -41,7 +41,12 @@ class SwaggerUi extends Backbone.Router load: -> # Initialize the API object @mainView?.clear() - @headerView.update(@options.url) + url = @options.url + if url.indexOf("http") isnt 0 + url = @buildUrl(window.location.href.toString(), url) + + @options.url = url + @headerView.update(url) @api = new SwaggerApi(@options) @api.build() @api @@ -62,6 +67,16 @@ class SwaggerUi extends Backbone.Router 400 ) + buildUrl: (base, url) -> + console.log "base is " + base + parts = base.split("/") + base = parts[0] + "//" + parts[2] + if url.indexOf("/") is 0 + base + url + else + base + "/" + url + + # Shows message on topbar of the ui showMessage: (data = '') -> $('#message-bar').removeClass 'message-fail' diff --git a/src/main/coffeescript/view/OperationView.coffee b/src/main/coffeescript/view/OperationView.coffee index 099760a7c89..4abaa76aa30 100644 --- a/src/main/coffeescript/view/OperationView.coffee +++ b/src/main/coffeescript/view/OperationView.coffee @@ -31,6 +31,13 @@ class OperationView extends Backbone.View contentTypeModel.consumes = @model.consumes contentTypeModel.produces = @model.produces + for param in @model.parameters + console.log "looking at " + param.dataType + if param.dataType.toLowerCase() == 'file' + if !contentTypeModel.consumes + console.log "set content type " + contentTypeModel.consumes = 'multipart/form-data' + responseContentTypeView = new ResponseContentTypeView({model: contentTypeModel}) $('.response-content-type', $(@el)).append responseContentTypeView.render().el @@ -74,7 +81,7 @@ class OperationView extends Backbone.View #if(o.value? && jQuery.trim(o.value).length > 0) #map[o.name] = o.value - for o in form.find(".body-textarea,.parameter") + for o in form.find("input") if(o.value? && jQuery.trim(o.value).length > 0) map[o.name] = encodeURI(o.value) diff --git a/src/main/coffeescript/view/ParameterView.coffee b/src/main/coffeescript/view/ParameterView.coffee index e31f05b8a22..f284b400d3e 100644 --- a/src/main/coffeescript/view/ParameterView.coffee +++ b/src/main/coffeescript/view/ParameterView.coffee @@ -3,7 +3,7 @@ class ParameterView extends Backbone.View render: -> @model.isBody = true if @model.paramType == 'body' - @model.isFile = true if @model.dataType == 'file' + @model.isFile = true if @model.dataType.toLowerCase() == 'file' template = @template() $(@el).html(template(@model)) diff --git a/src/main/template/param.handlebars b/src/main/template/param.handlebars index 0a65c1c599a..e77203bcea8 100644 --- a/src/main/template/param.handlebars +++ b/src/main/template/param.handlebars @@ -4,6 +4,7 @@ {{#if isBody}} {{#if isFile}} +
{{else}} {{#if defaultValue}}