Skip to content

Commit fdf2f1a

Browse files
committed
fix for #243
1 parent 5b20e78 commit fdf2f1a

File tree

4 files changed

+32
-27
lines changed

4 files changed

+32
-27
lines changed

lib/swagger-client.js

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -576,8 +576,6 @@ var OperationGroup = function(tag, operation) {
576576
this.name = tag;
577577
this.operation = operation;
578578
this.operationsArray = [];
579-
580-
this.description = operation.description || "";
581579
};
582580

583581
var Operation = function(parent, scheme, operationId, httpMethod, path, args, definitions) {
@@ -742,10 +740,14 @@ Operation.prototype.getType = function (param) {
742740
str = 'long';
743741
else if(type === 'integer')
744742
str = 'integer';
745-
else if(type === 'string' && format === 'date-time')
746-
str = 'date-time';
747-
else if(type === 'string' && format === 'date')
748-
str = 'date';
743+
else if(type === 'string') {
744+
if(format === 'date-time')
745+
str = 'date-time';
746+
else if(format === 'date')
747+
str = 'date';
748+
else
749+
str = 'string';
750+
}
749751
else if(type === 'number' && format === 'float')
750752
str = 'float';
751753
else if(type === 'number' && format === 'double')
@@ -754,8 +756,6 @@ Operation.prototype.getType = function (param) {
754756
str = 'double';
755757
else if(type === 'boolean')
756758
str = 'boolean';
757-
else if(type === 'string')
758-
str = 'string';
759759
else if(type === 'array') {
760760
isArray = true;
761761
if(param.items)
@@ -1050,14 +1050,13 @@ Operation.prototype.execute = function(arg1, arg2, arg3, arg4, parent) {
10501050
if(opts.mock === true)
10511051
return obj;
10521052
else
1053-
new SwaggerHttp().execute(obj);
1053+
new SwaggerHttp().execute(obj, opts);
10541054
};
10551055

10561056
Operation.prototype.setContentTypes = function(args, opts) {
10571057
// default type
10581058
var accepts = 'application/json';
10591059
var consumes = args.parameterContentType || 'application/json';
1060-
10611060
var allDefinedParams = this.parameters;
10621061
var definedFormParams = [];
10631062
var definedFileParams = [];
@@ -2747,7 +2746,7 @@ SwaggerRequest.prototype.setHeaders = function (params, opts, operation) {
27472746
*/
27482747
var SwaggerHttp = function() {};
27492748

2750-
SwaggerHttp.prototype.execute = function(obj) {
2749+
SwaggerHttp.prototype.execute = function(obj, opts) {
27512750
if(obj && (typeof obj.useJQuery === 'boolean'))
27522751
this.useJQuery = obj.useJQuery;
27532752
else
@@ -2758,9 +2757,9 @@ SwaggerHttp.prototype.execute = function(obj) {
27582757
}
27592758

27602759
if(this.useJQuery)
2761-
return new JQueryHttpClient().execute(obj);
2760+
return new JQueryHttpClient(opts).execute(obj);
27622761
else
2763-
return new ShredHttpClient().execute(obj);
2762+
return new ShredHttpClient(opts).execute(obj);
27642763
};
27652764

27662765
SwaggerHttp.prototype.isIE8 = function() {
@@ -2868,8 +2867,8 @@ JQueryHttpClient.prototype.execute = function(obj) {
28682867
/*
28692868
* ShredHttpClient is a light-weight, node or browser HTTP client
28702869
*/
2871-
var ShredHttpClient = function(options) {
2872-
this.options = (options||{});
2870+
var ShredHttpClient = function(opts) {
2871+
this.opts = (opts||{});
28732872
this.isInitialized = false;
28742873

28752874
var identity, toString;
@@ -2880,7 +2879,7 @@ var ShredHttpClient = function(options) {
28802879
}
28812880
else
28822881
this.Shred = require("shred");
2883-
this.shred = new this.Shred(options);
2882+
this.shred = new this.Shred(opts);
28842883
};
28852884

28862885
ShredHttpClient.prototype.initShred = function () {

lib/swagger-client.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/js/swagger-a.js

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -273,8 +273,6 @@ var OperationGroup = function(tag, operation) {
273273
this.name = tag;
274274
this.operation = operation;
275275
this.operationsArray = [];
276-
277-
this.description = operation.description || "";
278276
};
279277

280278
var Operation = function(parent, scheme, operationId, httpMethod, path, args, definitions) {
@@ -439,10 +437,14 @@ Operation.prototype.getType = function (param) {
439437
str = 'long';
440438
else if(type === 'integer')
441439
str = 'integer';
442-
else if(type === 'string' && format === 'date-time')
443-
str = 'date-time';
444-
else if(type === 'string' && format === 'date')
445-
str = 'date';
440+
else if(type === 'string') {
441+
if(format === 'date-time')
442+
str = 'date-time';
443+
else if(format === 'date')
444+
str = 'date';
445+
else
446+
str = 'string';
447+
}
446448
else if(type === 'number' && format === 'float')
447449
str = 'float';
448450
else if(type === 'number' && format === 'double')
@@ -451,8 +453,6 @@ Operation.prototype.getType = function (param) {
451453
str = 'double';
452454
else if(type === 'boolean')
453455
str = 'boolean';
454-
else if(type === 'string')
455-
str = 'string';
456456
else if(type === 'array') {
457457
isArray = true;
458458
if(param.items)
@@ -754,7 +754,6 @@ Operation.prototype.setContentTypes = function(args, opts) {
754754
// default type
755755
var accepts = 'application/json';
756756
var consumes = args.parameterContentType || 'application/json';
757-
758757
var allDefinedParams = this.parameters;
759758
var definedFormParams = [];
760759
var definedFileParams = [];

test/request.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,13 @@ describe('swagger request functions', function() {
1919
done();
2020
});
2121

22+
it('gets the resource description', function() {
23+
var storeApi = sample.apisArray[1];
24+
var req = storeApi.description;
25+
26+
expect(req).toBe.undefined;
27+
});
28+
2229
it('generate a get request', function() {
2330
var petApi = sample.pet;
2431
var req = petApi.getPetById({petId: 1}, {mock: true});

0 commit comments

Comments
 (0)