fix for #263
This commit is contained in:
@@ -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'
|
||||
|
||||
@@ -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)
|
||||
|
||||
|
||||
@@ -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))
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
{{#if isBody}}
|
||||
{{#if isFile}}
|
||||
<input type="file" name='{{name}}'/>
|
||||
<div class="parameter-content-type" />
|
||||
{{else}}
|
||||
{{#if defaultValue}}
|
||||
<textarea class='body-textarea' name='{{name}}'>{{defaultValue}}</textarea>
|
||||
|
||||
Reference in New Issue
Block a user