Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Ihor Kaharlichenko
swagger-ui-oms
Commits
34bd474b
Commit
34bd474b
authored
Nov 29, 2013
by
Tony Tam
Browse files
fix for #288
parent
4601f627
Changes
4
Expand all
Hide whitespace changes
Inline
Side-by-side
dist/index.html
View file @
34bd474b
...
...
@@ -5,7 +5,7 @@
<link
href=
'//fonts.googleapis.com/css?family=Droid+Sans:400,700'
rel=
'stylesheet'
type=
'text/css'
/>
<link
href=
'css/highlight.default.css'
media=
'screen'
rel=
'stylesheet'
type=
'text/css'
/>
<link
href=
'css/screen.css'
media=
'screen'
rel=
'stylesheet'
type=
'text/css'
/>
<script
type=
"text/javascript"
src=
"lib/shred.bundle.js"
></script>
<script
type=
"text/javascript"
src=
"lib/shred.bundle.js"
/
></script>
<script
src=
'lib/jquery-1.8.0.min.js'
type=
'text/javascript'
></script>
<script
src=
'lib/jquery.slideto.min.js'
type=
'text/javascript'
></script>
<script
src=
'lib/jquery.wiggle.min.js'
type=
'text/javascript'
></script>
...
...
dist/swagger-ui.js
View file @
34bd474b
...
...
@@ -1470,6 +1470,8 @@ helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
return
_ref4
;
}
OperationView
.
prototype
.
invocationUrl
=
null
;
OperationView
.
prototype
.
events
=
{
'
submit .sandbox
'
:
'
submitOperation
'
,
'
click .submit
'
:
'
submitOperation
'
,
...
...
@@ -1554,7 +1556,7 @@ helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
};
OperationView
.
prototype
.
submitOperation
=
function
(
e
)
{
var
error_free
,
form
,
map
,
o
,
opts
,
val
,
_i
,
_j
,
_k
,
_len
,
_len1
,
_len2
,
_ref5
,
_ref6
,
_ref7
;
var
error_free
,
form
,
isFileUpload
,
map
,
o
,
opts
,
val
,
_i
,
_j
,
_k
,
_len
,
_len1
,
_len2
,
_ref5
,
_ref6
,
_ref7
;
if
(
e
!=
null
)
{
e
.
preventDefault
();
}
...
...
@@ -1578,12 +1580,16 @@ helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
opts
=
{
parent
:
this
};
isFileUpload
=
false
;
_ref5
=
form
.
find
(
"
input
"
);
for
(
_i
=
0
,
_len
=
_ref5
.
length
;
_i
<
_len
;
_i
++
)
{
o
=
_ref5
[
_i
];
if
((
o
.
value
!=
null
)
&&
jQuery
.
trim
(
o
.
value
).
length
>
0
)
{
map
[
o
.
name
]
=
o
.
value
;
}
if
(
o
.
type
===
"
file
"
)
{
isFileUpload
=
true
;
}
}
_ref6
=
form
.
find
(
"
textarea
"
);
for
(
_j
=
0
,
_len1
=
_ref6
.
length
;
_j
<
_len1
;
_j
++
)
{
...
...
@@ -1603,7 +1609,11 @@ helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
opts
.
responseContentType
=
$
(
"
div select[name=responseContentType]
"
,
$
(
this
.
el
)).
val
();
opts
.
requestContentType
=
$
(
"
div select[name=parameterContentType]
"
,
$
(
this
.
el
)).
val
();
$
(
"
.response_throbber
"
,
$
(
this
.
el
)).
show
();
return
this
.
model
[
"
do
"
](
map
,
opts
,
this
.
showCompleteStatus
,
this
.
showErrorStatus
,
this
);
if
(
isFileUpload
)
{
return
this
.
handleFileUpload
(
map
,
form
);
}
else
{
return
this
.
model
[
"
do
"
](
map
,
opts
,
this
.
showCompleteStatus
,
this
.
showErrorStatus
,
this
);
}
}
};
...
...
@@ -1611,6 +1621,82 @@ helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
return
parent
.
showCompleteStatus
(
response
);
};
OperationView
.
prototype
.
handleFileUpload
=
function
(
map
,
form
)
{
var
bodyParam
,
headerParams
,
o
,
obj
,
param
,
_i
,
_j
,
_k
,
_len
,
_len1
,
_len2
,
_ref5
,
_ref6
,
_ref7
,
_this
=
this
;
console
.
log
(
"
it's a file upload
"
);
_ref5
=
form
.
serializeArray
();
for
(
_i
=
0
,
_len
=
_ref5
.
length
;
_i
<
_len
;
_i
++
)
{
o
=
_ref5
[
_i
];
if
((
o
.
value
!=
null
)
&&
jQuery
.
trim
(
o
.
value
).
length
>
0
)
{
map
[
o
.
name
]
=
o
.
value
;
}
}
bodyParam
=
new
FormData
();
_ref6
=
this
.
model
.
parameters
;
for
(
_j
=
0
,
_len1
=
_ref6
.
length
;
_j
<
_len1
;
_j
++
)
{
param
=
_ref6
[
_j
];
if
(
param
.
paramType
===
'
form
'
)
{
bodyParam
.
append
(
param
.
name
,
map
[
param
.
name
]);
}
}
headerParams
=
{};
_ref7
=
this
.
model
.
parameters
;
for
(
_k
=
0
,
_len2
=
_ref7
.
length
;
_k
<
_len2
;
_k
++
)
{
param
=
_ref7
[
_k
];
if
(
param
.
paramType
===
'
header
'
)
{
headerParams
[
param
.
name
]
=
map
[
param
.
name
];
}
}
console
.
log
(
headerParams
);
$
.
each
(
$
(
'
input[type~="file"]
'
),
function
(
i
,
el
)
{
return
bodyParam
.
append
(
$
(
el
).
attr
(
'
name
'
),
el
.
files
[
0
]);
});
console
.
log
(
bodyParam
);
this
.
invocationUrl
=
this
.
model
.
supportHeaderParams
()
?
(
headerParams
=
this
.
model
.
getHeaderParams
(
map
),
this
.
model
.
urlify
(
map
,
false
))
:
this
.
model
.
urlify
(
map
,
true
);
$
(
"
.request_url
"
,
$
(
this
.
el
)).
html
(
"
<pre>
"
+
this
.
invocationUrl
+
"
</pre>
"
);
obj
=
{
type
:
this
.
model
.
method
,
url
:
this
.
invocationUrl
,
headers
:
headerParams
,
data
:
bodyParam
,
dataType
:
'
json
'
,
contentType
:
false
,
processData
:
false
,
error
:
function
(
data
,
textStatus
,
error
)
{
return
_this
.
showErrorStatus
(
_this
.
wrap
(
data
),
_this
);
},
success
:
function
(
data
)
{
return
_this
.
showResponse
(
data
,
_this
);
},
complete
:
function
(
data
)
{
return
_this
.
showCompleteStatus
(
_this
.
wrap
(
data
),
_this
);
}
};
if
(
window
.
authorizations
)
{
window
.
authorizations
.
apply
(
obj
);
}
jQuery
.
ajax
(
obj
);
return
false
;
};
OperationView
.
prototype
.
wrap
=
function
(
data
)
{
var
o
,
_this
=
this
;
o
=
{};
o
.
content
=
{};
o
.
content
.
data
=
data
.
responseText
;
o
.
getHeaders
=
function
()
{
return
{
"
Content-Type
"
:
data
.
getResponseHeader
(
"
Content-Type
"
)
};
};
o
.
request
=
{};
o
.
request
.
url
=
this
.
invocationUrl
;
o
.
status
=
data
.
status
;
return
o
;
};
OperationView
.
prototype
.
getSelectedValue
=
function
(
select
)
{
var
opt
,
options
,
_i
,
_len
,
_ref5
;
if
(
!
select
.
multiple
)
{
...
...
@@ -1744,15 +1830,17 @@ helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
}
else
if
(
contentType
.
indexOf
(
"
text/html
"
)
===
0
)
{
code
=
$
(
'
<code />
'
).
html
(
content
);
pre
=
$
(
'
<pre class="xml" />
'
).
append
(
code
);
}
else
if
(
contentType
.
indexOf
(
"
image/
"
)
===
0
)
{
pre
=
$
(
'
<img>
'
).
attr
(
'
src
'
,
data
.
request
.
url
);
}
else
{
code
=
$
(
'
<code />
'
).
text
(
content
);
pre
=
$
(
'
<pre class="json" />
'
).
append
(
code
);
}
response_body
=
pre
;
$
(
"
.request_url
"
).
html
(
"
<pre>
"
+
data
.
request
.
url
+
"
</pre>
"
);
$
(
"
.request_url
"
,
$
(
this
.
el
)
).
html
(
"
<pre>
"
+
data
.
request
.
url
+
"
</pre>
"
);
$
(
"
.response_code
"
,
$
(
this
.
el
)).
html
(
"
<pre>
"
+
data
.
status
+
"
</pre>
"
);
$
(
"
.response_body
"
,
$
(
this
.
el
)).
html
(
response_body
);
$
(
"
.response_headers
"
,
$
(
this
.
el
)).
html
(
"
<pre>
"
+
JSON
.
stringify
(
data
.
getHeaders
())
+
"
</pre>
"
);
$
(
"
.response_headers
"
,
$
(
this
.
el
)).
html
(
"
<pre>
"
+
JSON
.
stringify
(
data
.
getHeaders
()
,
null
,
"
"
).
replace
(
/
\n
/g
,
"
<br>
"
)
+
"
</pre>
"
);
$
(
"
.response
"
,
$
(
this
.
el
)).
slideDown
();
$
(
"
.response_hider
"
,
$
(
this
.
el
)).
show
();
$
(
"
.response_throbber
"
,
$
(
this
.
el
)).
hide
();
...
...
dist/swagger-ui.min.js
View file @
34bd474b
This diff is collapsed.
Click to expand it.
src/main/coffeescript/view/OperationView.coffee
View file @
34bd474b
class
OperationView
extends
Backbone
.
View
invocationUrl
:
null
events
:
{
'submit .sandbox'
:
'submitOperation'
'click .submit'
:
'submitOperation'
...
...
@@ -77,13 +79,14 @@ class OperationView extends Backbone.View
if
error_free
map
=
{}
opts
=
{
parent
:
@
}
#for o in form.serializeArray()
#if(o.value? && jQuery.trim(o.value).length > 0)
#map[o.name] = o.value
isFileUpload
=
false
for
o
in
form
.
find
(
"input"
)
if
(
o
.
value
?
&&
jQuery
.
trim
(
o
.
value
).
length
>
0
)
map
[
o
.
name
]
=
o
.
value
if
o
.
type
is
"file"
isFileUpload
=
true
for
o
in
form
.
find
(
"textarea"
)
if
(
o
.
value
?
&&
jQuery
.
trim
(
o
.
value
).
length
>
0
)
...
...
@@ -98,12 +101,85 @@ class OperationView extends Backbone.View
opts
.
requestContentType
=
$
(
"div select[name=parameterContentType]"
,
$
(
@
el
)).
val
()
$
(
".response_throbber"
,
$
(
@
el
)).
show
()
@
model
.
do
(
map
,
opts
,
@
showCompleteStatus
,
@
showErrorStatus
,
@
)
if
isFileUpload
@
handleFileUpload
map
,
form
else
@
model
.
do
(
map
,
opts
,
@
showCompleteStatus
,
@
showErrorStatus
,
@
)
success
:
(
response
,
parent
)
->
parent
.
showCompleteStatus
response
handleFileUpload
:
(
map
,
form
)
->
console
.
log
"it's a file upload"
for
o
in
form
.
serializeArray
()
if
(
o
.
value
?
&&
jQuery
.
trim
(
o
.
value
).
length
>
0
)
map
[
o
.
name
]
=
o
.
value
# requires HTML5 compatible browser
bodyParam
=
new
FormData
()
# add params
for
param
in
@
model
.
parameters
if
param
.
paramType
is
'form'
bodyParam
.
append
(
param
.
name
,
map
[
param
.
name
])
# headers in operation
headerParams
=
{}
for
param
in
@
model
.
parameters
if
param
.
paramType
is
'header'
headerParams
[
param
.
name
]
=
map
[
param
.
name
]
console
.
log
headerParams
# add files
$
.
each
$
(
'input[type~="file"]'
),
(
i
,
el
)
->
bodyParam
.
append
(
$
(
el
).
attr
(
'name'
),
el
.
files
[
0
])
console
.
log
(
bodyParam
)
@
invocationUrl
=
if
@
model
.
supportHeaderParams
()
headerParams
=
@
model
.
getHeaderParams
(
map
)
@
model
.
urlify
(
map
,
false
)
else
@
model
.
urlify
(
map
,
true
)
$
(
".request_url"
,
$
(
@
el
)).
html
"<pre>"
+
@
invocationUrl
+
"</pre>"
obj
=
type
:
@
model
.
method
url
:
@
invocationUrl
headers
:
headerParams
data
:
bodyParam
dataType
:
'json'
contentType
:
false
processData
:
false
error
:
(
data
,
textStatus
,
error
)
=>
@
showErrorStatus
(
@
wrap
(
data
),
@
)
success
:
(
data
)
=>
@
showResponse
(
data
,
@
)
complete
:
(
data
)
=>
@
showCompleteStatus
(
@
wrap
(
data
),
@
)
# apply authorizations
if
window
.
authorizations
window
.
authorizations
.
apply
obj
jQuery
.
ajax
(
obj
)
false
# end of file-upload nastiness
# wraps a jquery response as a shred response
wrap
:
(
data
)
->
o
=
{}
o
.
content
=
{}
o
.
content
.
data
=
data
.
responseText
o
.
getHeaders
=
()
=>
{
"Content-Type"
:
data
.
getResponseHeader
(
"Content-Type"
)}
o
.
request
=
{}
o
.
request
.
url
=
@
invocationUrl
o
.
status
=
data
.
status
o
getSelectedValue
:
(
select
)
->
if
!
select
.
multiple
select
.
value
...
...
@@ -225,7 +301,7 @@ class OperationView extends Backbone.View
$
(
".request_url"
,
$
(
@
el
)).
html
"<pre>"
+
data
.
request
.
url
+
"</pre>"
$
(
".response_code"
,
$
(
@
el
)).
html
"<pre>"
+
data
.
status
+
"</pre>"
$
(
".response_body"
,
$
(
@
el
)).
html
response_body
$
(
".response_headers"
,
$
(
@
el
)).
html
"<pre>"
+
JSON
.
stringify
(
data
.
getHeaders
())
+
"</pre>"
$
(
".response_headers"
,
$
(
@
el
)).
html
"<pre>"
+
JSON
.
stringify
(
data
.
getHeaders
()
,
null
,
" "
).
replace
(
/\n/g
,
"<br>"
)
+
"</pre>"
$
(
".response"
,
$
(
@
el
)).
slideDown
()
$
(
".response_hider"
,
$
(
@
el
)).
show
()
$
(
".response_throbber"
,
$
(
@
el
)).
hide
()
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment