@@ -352,7 +352,7 @@ function program9(depth0,data) {
352
352
function program11 ( depth0 , data ) {
353
353
354
354
355
- return "\n <div class='sandbox_header'>\n <input class='submit' name='commit' type='button' value='Try it out!' />\n <a href='#' class='response_hider' style='display:none'>Hide Response</a>\n <img alt='Throbber' class='response_throbber' src='/assets/ grape_swagger_rails/throbber.gif' style='display:none' />\n </div>\n " ;
355
+ return "\n <div class='sandbox_header'>\n <input class='submit' name='commit' type='button' value='Try it out!' />\n <a href='#' class='response_hider' style='display:none'>Hide Response</a>\n <img alt='Throbber' class='response_throbber' src='<%= image_path(" grape_swagger_rails / throbber . gif ") %> ' style='display:none' />\n </div>\n ";
356
356
}
357
357
358
358
buffer += "\n <ul class='operations' >\n <li class='" ;
@@ -1281,13 +1281,24 @@ helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
1281
1281
} ;
1282
1282
1283
1283
SwaggerUi . prototype . buildUrl = function ( base , url ) {
1284
- var parts ;
1285
- console . log ( "base is " + base ) ;
1286
- parts = base . split ( "/" ) ;
1287
- base = parts [ 0 ] + "//" + parts [ 2 ] ;
1284
+ var endOfPath , parts ;
1285
+ log ( "base is " + base ) ;
1288
1286
if ( url . indexOf ( "/" ) === 0 ) {
1287
+ parts = base . split ( "/" ) ;
1288
+ base = parts [ 0 ] + "//" + parts [ 2 ] ;
1289
1289
return base + url ;
1290
1290
} else {
1291
+ endOfPath = base . length ;
1292
+ if ( base . indexOf ( "?" ) > - 1 ) {
1293
+ endOfPath = Math . min ( endOfPath , base . indexOf ( "?" ) ) ;
1294
+ }
1295
+ if ( base . indexOf ( "#" ) > - 1 ) {
1296
+ endOfPath = Math . min ( endOfPath , base . indexOf ( "#" ) ) ;
1297
+ }
1298
+ base = base . substring ( 0 , endOfPath ) ;
1299
+ if ( base . indexOf ( "/" , base . length - 1 ) !== - 1 ) {
1300
+ return base + url ;
1301
+ }
1291
1302
return base + "/" + url ;
1292
1303
}
1293
1304
} ;
@@ -1435,7 +1446,6 @@ helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
1435
1446
1436
1447
ResourceView . prototype . render = function ( ) {
1437
1448
var operation , _i , _len , _ref4 ;
1438
- console . log ( this . model . description ) ;
1439
1449
$ ( this . el ) . html ( Handlebars . templates . resource ( this . model ) ) ;
1440
1450
this . number = 0 ;
1441
1451
_ref4 = this . model . operationsArray ;
@@ -1513,7 +1523,7 @@ helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
1513
1523
type = param . type || param . dataType ;
1514
1524
if ( type . toLowerCase ( ) === 'file' ) {
1515
1525
if ( ! contentTypeModel . consumes ) {
1516
- console . log ( "set content type " ) ;
1526
+ log ( "set content type " ) ;
1517
1527
contentTypeModel . consumes = 'multipart/form-data' ;
1518
1528
}
1519
1529
}
@@ -1622,9 +1632,9 @@ helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
1622
1632
} ;
1623
1633
1624
1634
OperationView . prototype . handleFileUpload = function ( map , form ) {
1625
- var bodyParam , headerParams , o , obj , param , _i , _j , _k , _len , _len1 , _len2 , _ref5 , _ref6 , _ref7 ,
1635
+ var bodyParam , el , headerParams , o , obj , param , _i , _j , _k , _l , _len , _len1 , _len2 , _len3 , _ref5 , _ref6 , _ref7 , _ref8 ,
1626
1636
_this = this ;
1627
- console . log ( "it's a file upload" ) ;
1637
+ log ( "it's a file upload" ) ;
1628
1638
_ref5 = form . serializeArray ( ) ;
1629
1639
for ( _i = 0 , _len = _ref5 . length ; _i < _len ; _i ++ ) {
1630
1640
o = _ref5 [ _i ] ;
@@ -1648,11 +1658,13 @@ helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
1648
1658
headerParams [ param . name ] = map [ param . name ] ;
1649
1659
}
1650
1660
}
1651
- console . log ( headerParams ) ;
1652
- $ . each ( $ ( 'input[type~="file"]' ) , function ( i , el ) {
1653
- return bodyParam . append ( $ ( el ) . attr ( 'name' ) , el . files [ 0 ] ) ;
1654
- } ) ;
1655
- console . log ( bodyParam ) ;
1661
+ log ( headerParams ) ;
1662
+ _ref8 = form . find ( 'input[type~="file"]' ) ;
1663
+ for ( _l = 0 , _len3 = _ref8 . length ; _l < _len3 ; _l ++ ) {
1664
+ el = _ref8 [ _l ] ;
1665
+ bodyParam . append ( $ ( el ) . attr ( 'name' ) , el . files [ 0 ] ) ;
1666
+ }
1667
+ log ( bodyParam ) ;
1656
1668
this . invocationUrl = this . model . supportHeaderParams ( ) ? ( headerParams = this . model . getHeaderParams ( map ) , this . model . urlify ( map , false ) ) : this . model . urlify ( map , true ) ;
1657
1669
$ ( ".request_url" , $ ( this . el ) ) . html ( "<pre>" + this . invocationUrl + "</pre>" ) ;
1658
1670
obj = {
@@ -1688,7 +1700,7 @@ helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
1688
1700
o . content . data = data . responseText ;
1689
1701
o . getHeaders = function ( ) {
1690
1702
return {
1691
- "Content-Type" : data . getResponseHeader ( "Content-Type" )
1703
+ "Content-Type" : data . headers ( "Content-Type" )
1692
1704
} ;
1693
1705
} ;
1694
1706
o . request = { } ;
@@ -1813,34 +1825,34 @@ helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
1813
1825
return formatted ;
1814
1826
} ;
1815
1827
1816
- OperationView . prototype . showStatus = function ( data ) {
1828
+ OperationView . prototype . showStatus = function ( response ) {
1817
1829
var code , content , contentType , headers , pre , response_body ;
1818
- content = data . content . data ;
1819
- headers = data . getHeaders ( ) ;
1820
- contentType = headers [ "Content-Type" ] ;
1821
- if ( content === void 0 ) {
1830
+ content = response . data ;
1831
+ headers = response . headers ;
1832
+ contentType = headers [ "Content-Type" ] ? headers [ "Content-Type" ] . split ( ";" ) [ 0 ] . trim ( ) : null ;
1833
+ if ( ! content ) {
1822
1834
code = $ ( '<code />' ) . text ( "no content" ) ;
1823
1835
pre = $ ( '<pre class="json" />' ) . append ( code ) ;
1824
- } else if ( contentType . indexOf ( "application/json" ) === 0 || contentType . indexOf ( "application/hal +json" ) === 0 ) {
1825
- code = $ ( '<code />' ) . text ( JSON . stringify ( JSON . parse ( content ) , null , 2 ) ) ;
1836
+ } else if ( contentType === "application/json" || / \ +j s o n $ / . test ( contentType ) ) {
1837
+ code = $ ( '<code />' ) . text ( JSON . stringify ( JSON . parse ( content ) , null , " " ) ) ;
1826
1838
pre = $ ( '<pre class="json" />' ) . append ( code ) ;
1827
- } else if ( contentType . indexOf ( "application/xml" ) === 0 ) {
1839
+ } else if ( contentType === "application/xml" || / \+ x m l $ / . test ( contentType ) ) {
1828
1840
code = $ ( '<code />' ) . text ( this . formatXml ( content ) ) ;
1829
1841
pre = $ ( '<pre class="xml" />' ) . append ( code ) ;
1830
- } else if ( contentType . indexOf ( "text/html" ) === 0 ) {
1842
+ } else if ( contentType === "text/html" ) {
1831
1843
code = $ ( '<code />' ) . html ( content ) ;
1832
1844
pre = $ ( '<pre class="xml" />' ) . append ( code ) ;
1833
- } else if ( contentType . indexOf ( " image/" ) === 0 ) {
1834
- pre = $ ( '<img>' ) . attr ( 'src' , data . request . url ) ;
1845
+ } else if ( / ^ i m a g e \/ / . test ( contentType ) ) {
1846
+ pre = $ ( '<img>' ) . attr ( 'src' , response . url ) ;
1835
1847
} else {
1836
1848
code = $ ( '<code />' ) . text ( content ) ;
1837
1849
pre = $ ( '<pre class="json" />' ) . append ( code ) ;
1838
1850
}
1839
1851
response_body = pre ;
1840
- $ ( ".request_url" , $ ( this . el ) ) . html ( "<pre>" + data . request . url + "</pre>" ) ;
1841
- $ ( ".response_code" , $ ( this . el ) ) . html ( "<pre>" + data . status + "</pre>" ) ;
1852
+ $ ( ".request_url" , $ ( this . el ) ) . html ( "<pre>" + response . url + "</pre>" ) ;
1853
+ $ ( ".response_code" , $ ( this . el ) ) . html ( "<pre>" + response . status + "</pre>" ) ;
1842
1854
$ ( ".response_body" , $ ( this . el ) ) . html ( response_body ) ;
1843
- $ ( ".response_headers" , $ ( this . el ) ) . html ( "<pre>" + JSON . stringify ( data . getHeaders ( ) , null , " " ) . replace ( / \n / g, "<br>" ) + "</pre>" ) ;
1855
+ $ ( ".response_headers" , $ ( this . el ) ) . html ( "<pre>" + JSON . stringify ( response . headers , null , " " ) . replace ( / \n / g, "<br>" ) + "</pre>" ) ;
1844
1856
$ ( ".response" , $ ( this . el ) ) . slideDown ( ) ;
1845
1857
$ ( ".response_hider" , $ ( this . el ) ) . show ( ) ;
1846
1858
$ ( ".response_throbber" , $ ( this . el ) ) . hide ( ) ;
0 commit comments