@@ -87,6 +87,7 @@ var SwaggerApi = function(url, options) {
8787 this . authorizations = null ;
8888 this . authorizationScheme = null ;
8989 this . info = null ;
90+ this . useJQuery = false ;
9091
9192 options = ( options || { } ) ;
9293 if ( url )
@@ -103,6 +104,9 @@ var SwaggerApi = function(url, options) {
103104 if ( options . success != null )
104105 this . success = options . success ;
105106
107+ if ( typeof options . useJQuery === 'boolean' )
108+ this . useJQuery = options . useJQuery ;
109+
106110 this . failure = options . failure != null ? options . failure : function ( ) { } ;
107111 this . progress = options . progress != null ? options . progress : function ( ) { } ;
108112 if ( options . success != null )
@@ -1072,7 +1076,7 @@ SwaggerOperation.prototype.formatXml = function(xml) {
10721076var SwaggerRequest = function ( type , url , params , opts , successCallback , errorCallback , operation , execution ) {
10731077 var _this = this ;
10741078 var errors = [ ] ;
1075- this . useJQuery = ( typeof operation . useJQuery !== 'undefined' ? operation . useJQuery : null ) ;
1079+ this . useJQuery = ( typeof operation . resource . useJQuery !== 'undefined' ? operation . resource . useJQuery : null ) ;
10761080 this . type = ( type || errors . push ( "SwaggerRequest type is required (get/post/put/delete/patch/options)." ) ) ;
10771081 this . url = ( url || errors . push ( "SwaggerRequest url is required." ) ) ;
10781082 this . params = params ;
@@ -1258,9 +1262,16 @@ SwaggerHttp.prototype.isIE8 = function() {
12581262} ;
12591263
12601264/*
1261- * JQueryHttpClient lets a browser take advantage of JQuery's cross-browser magic
1265+ * JQueryHttpClient lets a browser take advantage of JQuery's cross-browser magic.
1266+ * NOTE: when jQuery is available it will export both '$' and 'jQuery' to the global space.
1267+ * Since we are using closures here we need to alias it for internal use.
12621268 */
1263- var JQueryHttpClient = function ( options ) { }
1269+ var JQueryHttpClient = function ( options ) {
1270+ "use strict" ;
1271+ if ( ! jQuery ) {
1272+ var jQuery = window . jQuery ;
1273+ }
1274+ }
12641275
12651276JQueryHttpClient . prototype . execute = function ( obj ) {
12661277 var cb = obj . on ;
@@ -1333,9 +1344,9 @@ JQueryHttpClient.prototype.execute = function(obj) {
13331344 else
13341345 return cb . response ( out ) ;
13351346 } ;
1336-
1337- $ . support . cors = true ;
1338- return $ . ajax ( obj ) ;
1347+
1348+ jQuery . support . cors = true ;
1349+ return jQuery . ajax ( obj ) ;
13391350}
13401351
13411352/*
0 commit comments