Skip to content

Commit 955aa95

Browse files
committed
Merge branch 'master' of github.com:swagger-api/swagger-js
2 parents 0133f1c + d5f4f04 commit 955aa95

File tree

4 files changed

+47
-2
lines changed

4 files changed

+47
-2
lines changed

browser/swagger-client.js

Lines changed: 5 additions & 1 deletion
Large diffs are not rendered by default.

browser/swagger-client.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/http.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,11 @@ SwaggerHttp.prototype.execute = function (obj, opts) {
4040
hasJQuery = true;
4141
}
4242
}
43+
// OPTIONS support
44+
if(obj.method.toLowerCase() === 'OPTIONS' && typeof client === 'SuperagentHttpClient') {
45+
log('forcing jQuery as OPTIONS are not supported by SuperAgent');
46+
obj.useJQuery = true;
47+
}
4348
if(this.isInternetExplorer() && (obj.useJQuery === false || !hasJQuery )) {
4449
throw new Error('Unsupported configuration! JQuery is required but not available');
4550
}

test/client.js

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -305,6 +305,42 @@ describe('SwaggerClient', function () {
305305
});
306306
});
307307

308+
it('should force jQuery for options', function(done) {
309+
var spec = {
310+
swagger: '2.0',
311+
info: {
312+
description: 'This is a sample server Petstore server',
313+
version: '1.0.0',
314+
title: 'Swagger Petstore'
315+
},
316+
host: 'petstore.swagger.io',
317+
basePath: '/v2',
318+
paths: {
319+
'/pet': {
320+
options: {
321+
tags: [ 'pet' ],
322+
operationId: 'testOptions',
323+
responses: {
324+
200: {
325+
description: 'OK'
326+
}
327+
}
328+
}
329+
}
330+
}
331+
};
332+
333+
var client = new SwaggerClient({
334+
spec: spec,
335+
success: function () {
336+
var result = client.pet.testOptions({}, function (data) {
337+
expect(data.method).toEqual('OPTIONS');
338+
done();
339+
});
340+
}
341+
});
342+
});
343+
308344
it('should should use a custom http client', function(done) {
309345
var myHttpClient = {
310346
execute: function(obj) {

0 commit comments

Comments
 (0)