swagger-client 2.1.32 → 2.2.21

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -21,7 +21,6 @@ var Operation = module.exports = function (parent, scheme, operationId, httpMeth
21
21
  this.client = parent.options.client || null;
22
22
  this.requestInterceptor = parent.options.requestInterceptor || null;
23
23
  this.responseInterceptor = parent.options.responseInterceptor || null;
24
- this.requestAgent = parent.options.requestAgent;
25
24
  }
26
25
  this.authorizations = args.security;
27
26
  this.basePath = parent.basePath || '/';
@@ -50,8 +49,6 @@ var Operation = module.exports = function (parent, scheme, operationId, httpMeth
50
49
  this.jqueryAjaxCache = parent.jqueryAjaxCache;
51
50
  this.enableCookies = parent.enableCookies;
52
51
 
53
- var key;
54
-
55
52
  if(!this.host) {
56
53
  if(typeof window !== 'undefined') {
57
54
  this.host = window.location.host;
@@ -90,6 +87,8 @@ var Operation = module.exports = function (parent, scheme, operationId, httpMeth
90
87
 
91
88
  if (definitions) {
92
89
  // add to global models
90
+ var key;
91
+
93
92
  for (key in definitions) {
94
93
  model = new Model(key, definitions[key], this.models, parent.modelPropertyMacro);
95
94
 
@@ -103,7 +102,7 @@ var Operation = module.exports = function (parent, scheme, operationId, httpMeth
103
102
  }
104
103
 
105
104
  for (i = 0; i < this.parameters.length; i++) {
106
- var d, param = this.parameters[i];
105
+ var param = this.parameters[i];
107
106
 
108
107
  // Allow macro to set the default value
109
108
  param.default = this.parameterMacro(this, param);
@@ -111,6 +110,10 @@ var Operation = module.exports = function (parent, scheme, operationId, httpMeth
111
110
  if (param.type === 'array') {
112
111
  param.isList = true;
113
112
  param.allowMultiple = true;
113
+ // the enum can be defined at the items level
114
+ //if (param.items && param.items.enum) {
115
+ // param['enum'] = param.items.enum;
116
+ //}
114
117
  }
115
118
 
116
119
  var innerType = this.getType(param);
@@ -121,15 +124,12 @@ var Operation = module.exports = function (parent, scheme, operationId, httpMeth
121
124
  param['enum'] = [true, false]; // use actual primitives
122
125
  }
123
126
 
124
- for(key in param) {
125
- helpers.extractExtensions(key, param);
126
- }
127
127
  if(typeof param['x-example'] !== 'undefined') {
128
- d = param['x-example'];
128
+ var d = param['x-example'];
129
129
  param.default = d;
130
130
  }
131
131
  if(param['x-examples']) {
132
- d = param['x-examples'].default;
132
+ var d = param['x-examples'].default;
133
133
  if(typeof d !== 'undefined') {
134
134
  param.default = d;
135
135
  }
@@ -170,7 +170,7 @@ var Operation = module.exports = function (parent, scheme, operationId, httpMeth
170
170
  param.responseClassSignature = param.signature;
171
171
  }
172
172
 
173
- var keyname, defaultResponseCode, response, responses = this.responses;
173
+ var defaultResponseCode, response, responses = this.responses;
174
174
 
175
175
  if (responses['200']) {
176
176
  response = responses['200'];
@@ -198,30 +198,6 @@ var Operation = module.exports = function (parent, scheme, operationId, httpMeth
198
198
  defaultResponseCode = 'default';
199
199
  }
200
200
 
201
- for(keyname in responses) {
202
- helpers.extractExtensions(keyname, responses);
203
- if(typeof keyname === 'string' && keyname.indexOf('x-') === -1) {
204
- var responseObject = responses[keyname];
205
- if(typeof responseObject === 'object' && typeof responseObject.headers === 'object') {
206
- var headers = responseObject.headers;
207
- for(var headerName in headers) {
208
- var header = headers[headerName];
209
- if(typeof header === 'object') {
210
- for(var headerKey in header) {
211
- helpers.extractExtensions(headerKey, header);
212
- }
213
- }
214
- }
215
- }
216
- }
217
- }
218
-
219
- if (response) {
220
- for(keyname in response) {
221
- helpers.extractExtensions(keyname, response);
222
- }
223
- }
224
-
225
201
  if (response && response.schema) {
226
202
  var resolvedModel = this.resolveModel(response.schema, definitions);
227
203
  var successResponse;
@@ -242,7 +218,6 @@ var Operation = module.exports = function (parent, scheme, operationId, httpMeth
242
218
  }
243
219
 
244
220
  if (successResponse) {
245
- successResponse.vendorExtensions = response.vendorExtensions;
246
221
  // Attach response properties
247
222
  if (response.description) {
248
223
  successResponse.description = response.description;
@@ -491,7 +466,7 @@ Operation.prototype.getHeaderParams = function (args) {
491
466
  return headers;
492
467
  };
493
468
 
494
- Operation.prototype.urlify = function (args, maskPasswords) {
469
+ Operation.prototype.urlify = function (args) {
495
470
  var formParams = {};
496
471
  var requestUrl = this.path.replace(/#.*/, ''); // remove URL fragment
497
472
  var querystring = ''; // grab params from the args, build the querystring along the way
@@ -500,21 +475,14 @@ Operation.prototype.urlify = function (args, maskPasswords) {
500
475
  var param = this.parameters[i];
501
476
 
502
477
  if (typeof args[param.name] !== 'undefined') {
503
- var isPassword;
504
- if(param.type === 'string' && param.format === 'password' && maskPasswords) {
505
- isPassword = true;
506
- }
507
-
508
478
  if (param.in === 'path') {
509
479
  var reg = new RegExp('\{' + param.name + '\}', 'gi');
510
480
  var value = args[param.name];
511
481
 
512
482
  if (Array.isArray(value)) {
513
- value = this.encodePathCollection(param.collectionFormat, param.name, value, isPassword);
483
+ value = this.encodePathCollection(param.collectionFormat, param.name, value);
514
484
  } else {
515
- if((typeof(param['x-escape']) === 'undefined') || (param['x-escape'] === true)) {
516
- value = this.encodePathParam(value, isPassword);
517
- }
485
+ value = this.encodePathParam(value);
518
486
  }
519
487
 
520
488
  requestUrl = requestUrl.replace(reg, value);
@@ -529,36 +497,16 @@ Operation.prototype.urlify = function (args, maskPasswords) {
529
497
  var qp = args[param.name];
530
498
 
531
499
  if (Array.isArray(qp)) {
532
- querystring += this.encodeQueryCollection(param.collectionFormat, param.name, qp, isPassword);
500
+ querystring += this.encodeQueryCollection(param.collectionFormat, param.name, qp);
533
501
  } else {
534
- querystring += this.encodeQueryKey(param.name) + '=' + this.encodeQueryParam(args[param.name], isPassword);
502
+ querystring += this.encodeQueryKey(param.name) + '=' + this.encodeQueryParam(args[param.name]);
535
503
  }
536
504
  } else {
537
- querystring += this.encodeQueryKey(param.name) + '=' + this.encodeQueryParam(args[param.name], isPassword);
505
+ querystring += this.encodeQueryKey(param.name) + '=' + this.encodeQueryParam(args[param.name]);
538
506
  }
539
507
  } else if (param.in === 'formData') {
540
508
  formParams[param.name] = args[param.name];
541
509
  }
542
- } else if(param.in === 'query' && typeof args[param.name] === 'undefined' && param.allowEmptyValue === true) {
543
- if (querystring === '' && requestUrl.indexOf('?') < 0) {
544
- querystring += '?';
545
- } else {
546
- querystring += '&';
547
- }
548
-
549
- if (typeof param.collectionFormat !== 'undefined' || param.type === 'array') {
550
- var qp;
551
- var collectionFormat = param.collectionFormat || 'multi';
552
-
553
- if (Array.isArray(qp)) {
554
- querystring += this.encodeQueryCollection(collectionFormat, param.name, qp, isPassword);
555
- } else {
556
- querystring += this.encodeQueryCollection(collectionFormat, param.name, [qp], isPassword);
557
- }
558
- } else {
559
- querystring += this.encodeQueryKey(param.name) + '=' + this.encodeQueryParam('', isPassword);
560
- }
561
-
562
510
  }
563
511
  }
564
512
  var url = this.scheme + '://' + this.host;
@@ -587,23 +535,18 @@ Operation.prototype.getMissingParams = function (args) {
587
535
  };
588
536
 
589
537
  Operation.prototype.getBody = function (headers, args, opts) {
590
- var formParams = {}, hasFormParams, param, body, key, value, hasBody = false;
538
+ var formParams = {}, hasFormParams, body, key, value, hasBody = false;
591
539
 
592
540
  // look at each param and put form params in an object
593
541
  for (var i = 0; i < this.parameters.length; i++) {
594
- param = this.parameters[i];
542
+ var param = this.parameters[i];
595
543
  if (typeof args[param.name] !== 'undefined') {
596
- var isPassword;
597
- if(param.type === 'string' && param.format === 'password') {
598
- isPassword = 'password';
599
- }
600
544
  if (param.in === 'body') {
601
545
  body = args[param.name];
602
546
  } else if (param.in === 'formData') {
603
547
  formParams[param.name] = {
604
548
  param: param,
605
- value: args[param.name],
606
- password: isPassword
549
+ value: args[param.name]
607
550
  };
608
551
  hasFormParams = true;
609
552
  }
@@ -633,27 +576,22 @@ Operation.prototype.getBody = function (headers, args, opts) {
633
576
  var encoded = '';
634
577
 
635
578
  for (key in formParams) {
636
- param = formParams[key].param;
579
+ var param = formParams[key].param;
637
580
  value = formParams[key].value;
638
- var password;
639
-
640
- if(opts && opts.maskPasswords) {
641
- password = formParams[key].password;
642
- }
643
581
 
644
582
  if (typeof value !== 'undefined') {
645
583
  if (Array.isArray(value)) {
646
584
  if (encoded !== '') {
647
585
  encoded += '&';
648
586
  }
649
- encoded += this.encodeQueryCollection(param.collectionFormat, key, value, password);
587
+ encoded += this.encodeQueryCollection(param.collectionFormat, key, value);
650
588
  }
651
589
  else {
652
590
  if (encoded !== '') {
653
591
  encoded += '&';
654
592
  }
655
593
 
656
- encoded += encodeURIComponent(key) + '=' + mask(encodeURIComponent(value), password);
594
+ encoded += encodeURIComponent(key) + '=' + encodeURIComponent(value);
657
595
  }
658
596
  }
659
597
  }
@@ -667,7 +605,7 @@ Operation.prototype.getBody = function (headers, args, opts) {
667
605
  bodyParam.type = 'formData';
668
606
 
669
607
  for (key in formParams) {
670
- param = formParams[key].param;
608
+ var param = formParams[key].param;
671
609
  value = args[key];
672
610
 
673
611
  if (typeof value !== 'undefined') {
@@ -805,16 +743,14 @@ Operation.prototype.execute = function (arg1, arg2, arg3, arg4, parent) {
805
743
  error = arg4;
806
744
  }
807
745
 
808
- timeout = typeof opts.timeout !== 'undefined' ? opts.timeout : this.timeout;
746
+ timeout = typeof opts.timeout !== 'undefined'
747
+ ? opts.timeout
748
+ : this.timeout;
809
749
 
810
750
  if(this.client) {
811
751
  opts.client = this.client;
812
752
  }
813
753
 
814
- if(this.requestAgent) {
815
- opts.requestAgent = this.requestAgent;
816
- }
817
-
818
754
  // add the request interceptor from parent, if none sent from client
819
755
  if(!opts.requestInterceptor && this.requestInterceptor ) {
820
756
  opts.requestInterceptor = this.requestInterceptor ;
@@ -872,7 +808,7 @@ Operation.prototype.execute = function (arg1, arg2, arg3, arg4, parent) {
872
808
  for (attrname in contentTypeHeaders) { headers[attrname] = contentTypeHeaders[attrname]; }
873
809
 
874
810
  var body = this.getBody(contentTypeHeaders, args, opts);
875
- var url = this.urlify(args, opts.maskPasswords);
811
+ var url = this.urlify(args);
876
812
 
877
813
  if(url.indexOf('.{format}') > 0) {
878
814
  if(headers) {
@@ -896,8 +832,6 @@ Operation.prototype.execute = function (arg1, arg2, arg3, arg4, parent) {
896
832
  deferred: deferred,
897
833
  headers: headers,
898
834
  clientAuthorizations: opts.clientAuthorizations,
899
- operation: this,
900
- connectionAgent: this.connectionAgent,
901
835
  on: {
902
836
  response: function (response) {
903
837
  if (deferred) {
@@ -924,9 +858,6 @@ Operation.prototype.execute = function (arg1, arg2, arg3, arg4, parent) {
924
858
 
925
859
  this.clientAuthorizations.apply(obj, this.operation.security);
926
860
  if (opts.mock === true) {
927
- if(opts.requestInterceptor) {
928
- opts.requestInterceptor.apply(obj);
929
- }
930
861
  return obj;
931
862
  } else {
932
863
  return new SwaggerHttp().execute(obj, opts);
@@ -1057,7 +988,7 @@ Operation.prototype.matchesAccept = function(accepts) {
1057
988
  };
1058
989
 
1059
990
  Operation.prototype.asCurl = function (args1, args2) {
1060
- var opts = {mock: true, maskPasswords: true};
991
+ var opts = {mock: true};
1061
992
  if (typeof args2 === 'object') {
1062
993
  for (var argKey in args2) {
1063
994
  opts[argKey] = args2[argKey];
@@ -1124,14 +1055,14 @@ Operation.prototype.asCurl = function (args1, args2) {
1124
1055
  if (Array.isArray(paramValue)) {
1125
1056
  if(parameter.collectionFormat === 'multi') {
1126
1057
  for(var v in paramValue) {
1127
- body += '-F ' + this.encodeQueryKey(parameter.name) + '=' + mask(paramValue[v], parameter.format) + ' ';
1058
+ body += '-F ' + this.encodeQueryKey(parameter.name) + '=' + paramValue[v] + ' ';
1128
1059
  }
1129
1060
  }
1130
1061
  else {
1131
- body += '-F ' + this.encodeQueryCollection(parameter.collectionFormat, parameter.name, mask(paramValue, parameter.format)) + ' ';
1062
+ body += '-F ' + this.encodeQueryCollection(parameter.collectionFormat, parameter.name, paramValue) + ' ';
1132
1063
  }
1133
1064
  } else {
1134
- body += '-F ' + this.encodeQueryKey(parameter.name) + '=' + mask(paramValue, parameter.format) + ' ';
1065
+ body += '-F ' + this.encodeQueryKey(parameter.name) + '=' + paramValue + ' ';
1135
1066
  }
1136
1067
  }
1137
1068
  }
@@ -1162,7 +1093,7 @@ Operation.prototype.asCurl = function (args1, args2) {
1162
1093
  return 'curl ' + (results.join(' ')) + ' \'' + obj.url + '\'';
1163
1094
  };
1164
1095
 
1165
- Operation.prototype.encodePathCollection = function (type, name, value, maskPasswords) {
1096
+ Operation.prototype.encodePathCollection = function (type, name, value) {
1166
1097
  var encoded = '';
1167
1098
  var i;
1168
1099
  var separator = '';
@@ -1179,16 +1110,16 @@ Operation.prototype.encodePathCollection = function (type, name, value, maskPass
1179
1110
 
1180
1111
  for (i = 0; i < value.length; i++) {
1181
1112
  if (i === 0) {
1182
- encoded = this.encodeQueryParam(value[i], maskPasswords);
1113
+ encoded = this.encodeQueryParam(value[i]);
1183
1114
  } else {
1184
- encoded += separator + this.encodeQueryParam(value[i], maskPasswords);
1115
+ encoded += separator + this.encodeQueryParam(value[i]);
1185
1116
  }
1186
1117
  }
1187
1118
 
1188
1119
  return encoded;
1189
1120
  };
1190
1121
 
1191
- Operation.prototype.encodeQueryCollection = function (type, name, value, maskPasswords) {
1122
+ Operation.prototype.encodeQueryCollection = function (type, name, value) {
1192
1123
  var encoded = '';
1193
1124
  var i;
1194
1125
 
@@ -1197,7 +1128,7 @@ Operation.prototype.encodeQueryCollection = function (type, name, value, maskPas
1197
1128
  for (i = 0; i < value.length; i++) {
1198
1129
  if (i > 0) {encoded += '&';}
1199
1130
 
1200
- encoded += this.encodeQueryKey(name) + '=' + mask(this.encodeQueryParam(value[i]), maskPasswords);
1131
+ encoded += this.encodeQueryKey(name) + '=' + this.encodeQueryParam(value[i]);
1201
1132
  }
1202
1133
  } else {
1203
1134
  var separator = '';
@@ -1215,7 +1146,8 @@ Operation.prototype.encodeQueryCollection = function (type, name, value, maskPas
1215
1146
  if (i !== 0) {
1216
1147
  encoded += '&';
1217
1148
  }
1218
- encoded += this.encodeQueryKey(name) + '[]=' + mask(this.encodeQueryParam(value[i]), maskPasswords);
1149
+
1150
+ encoded += this.encodeQueryKey(name) + '[]=' + this.encodeQueryParam(value[i]);
1219
1151
  }
1220
1152
  }
1221
1153
 
@@ -1238,28 +1170,13 @@ Operation.prototype.encodeQueryKey = function (arg) {
1238
1170
  .replace('%5B','[').replace('%5D', ']').replace('%24', '$');
1239
1171
  };
1240
1172
 
1241
- Operation.prototype.encodeQueryParam = function (arg, maskPasswords) {
1242
- if(maskPasswords) {
1243
- return "******";
1244
- }
1245
- if(arg !== undefined && arg !== null) {
1246
- return encodeURIComponent(arg);
1247
- }
1248
- else {
1249
- return '';
1250
- }
1173
+ Operation.prototype.encodeQueryParam = function (arg) {
1174
+ return encodeURIComponent(arg);
1251
1175
  };
1252
1176
 
1253
1177
  /**
1254
1178
  * TODO revisit, might not want to leave '/'
1255
1179
  **/
1256
- Operation.prototype.encodePathParam = function (pathParam, maskPasswords) {
1257
- return encodeURIComponent(pathParam, maskPasswords);
1180
+ Operation.prototype.encodePathParam = function (pathParam) {
1181
+ return encodeURIComponent(pathParam);
1258
1182
  };
1259
-
1260
- var mask = function(value, format) {
1261
- if(typeof format === 'string' && format === 'password') {
1262
- return '******';
1263
- }
1264
- return value;
1265
- }
package/package.json CHANGED
@@ -8,7 +8,7 @@
8
8
  }
9
9
  ],
10
10
  "description": "swagger-client is a javascript client for use with swaggering APIs.",
11
- "version": "2.1.32",
11
+ "version": "2.2.21",
12
12
  "homepage": "http://swagger.io",
13
13
  "repository": {
14
14
  "type": "git",
@@ -55,7 +55,6 @@
55
55
  "gulp-istanbul": "^0.5.0",
56
56
  "gulp-jshint": "^1.9.0",
57
57
  "gulp-mocha": "^2.0.0",
58
- "gulp-sourcemaps": "^1.0.0",
59
58
  "http-server": "^0.8.0",
60
59
  "jshint-stylish": "^1.0.1",
61
60
  "karma": "^0.13.0",