swagger-client 2.1.29 → 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,19 +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
- value = this.encodePathParam(value, isPassword);
485
+ value = this.encodePathParam(value);
516
486
  }
517
487
 
518
488
  requestUrl = requestUrl.replace(reg, value);
@@ -527,12 +497,12 @@ Operation.prototype.urlify = function (args, maskPasswords) {
527
497
  var qp = args[param.name];
528
498
 
529
499
  if (Array.isArray(qp)) {
530
- querystring += this.encodeQueryCollection(param.collectionFormat, param.name, qp, isPassword);
500
+ querystring += this.encodeQueryCollection(param.collectionFormat, param.name, qp);
531
501
  } else {
532
- querystring += this.encodeQueryKey(param.name) + '=' + this.encodeQueryParam(args[param.name], isPassword);
502
+ querystring += this.encodeQueryKey(param.name) + '=' + this.encodeQueryParam(args[param.name]);
533
503
  }
534
504
  } else {
535
- querystring += this.encodeQueryKey(param.name) + '=' + this.encodeQueryParam(args[param.name], isPassword);
505
+ querystring += this.encodeQueryKey(param.name) + '=' + this.encodeQueryParam(args[param.name]);
536
506
  }
537
507
  } else if (param.in === 'formData') {
538
508
  formParams[param.name] = args[param.name];
@@ -565,23 +535,18 @@ Operation.prototype.getMissingParams = function (args) {
565
535
  };
566
536
 
567
537
  Operation.prototype.getBody = function (headers, args, opts) {
568
- var formParams = {}, hasFormParams, param, body, key, value, hasBody = false;
538
+ var formParams = {}, hasFormParams, body, key, value, hasBody = false;
569
539
 
570
540
  // look at each param and put form params in an object
571
541
  for (var i = 0; i < this.parameters.length; i++) {
572
- param = this.parameters[i];
542
+ var param = this.parameters[i];
573
543
  if (typeof args[param.name] !== 'undefined') {
574
- var isPassword;
575
- if(param.type === 'string' && param.format === 'password') {
576
- isPassword = 'password';
577
- }
578
544
  if (param.in === 'body') {
579
545
  body = args[param.name];
580
546
  } else if (param.in === 'formData') {
581
547
  formParams[param.name] = {
582
548
  param: param,
583
- value: args[param.name],
584
- password: isPassword
549
+ value: args[param.name]
585
550
  };
586
551
  hasFormParams = true;
587
552
  }
@@ -611,27 +576,22 @@ Operation.prototype.getBody = function (headers, args, opts) {
611
576
  var encoded = '';
612
577
 
613
578
  for (key in formParams) {
614
- param = formParams[key].param;
579
+ var param = formParams[key].param;
615
580
  value = formParams[key].value;
616
- var password;
617
-
618
- if(opts && opts.maskPasswords) {
619
- password = formParams[key].password;
620
- }
621
581
 
622
582
  if (typeof value !== 'undefined') {
623
583
  if (Array.isArray(value)) {
624
584
  if (encoded !== '') {
625
585
  encoded += '&';
626
586
  }
627
- encoded += this.encodeQueryCollection(param.collectionFormat, key, value, password);
587
+ encoded += this.encodeQueryCollection(param.collectionFormat, key, value);
628
588
  }
629
589
  else {
630
590
  if (encoded !== '') {
631
591
  encoded += '&';
632
592
  }
633
593
 
634
- encoded += encodeURIComponent(key) + '=' + mask(encodeURIComponent(value), password);
594
+ encoded += encodeURIComponent(key) + '=' + encodeURIComponent(value);
635
595
  }
636
596
  }
637
597
  }
@@ -645,7 +605,7 @@ Operation.prototype.getBody = function (headers, args, opts) {
645
605
  bodyParam.type = 'formData';
646
606
 
647
607
  for (key in formParams) {
648
- param = formParams[key].param;
608
+ var param = formParams[key].param;
649
609
  value = args[key];
650
610
 
651
611
  if (typeof value !== 'undefined') {
@@ -783,16 +743,14 @@ Operation.prototype.execute = function (arg1, arg2, arg3, arg4, parent) {
783
743
  error = arg4;
784
744
  }
785
745
 
786
- timeout = typeof opts.timeout !== 'undefined' ? opts.timeout : this.timeout;
746
+ timeout = typeof opts.timeout !== 'undefined'
747
+ ? opts.timeout
748
+ : this.timeout;
787
749
 
788
750
  if(this.client) {
789
751
  opts.client = this.client;
790
752
  }
791
753
 
792
- if(this.requestAgent) {
793
- opts.requestAgent = this.requestAgent;
794
- }
795
-
796
754
  // add the request interceptor from parent, if none sent from client
797
755
  if(!opts.requestInterceptor && this.requestInterceptor ) {
798
756
  opts.requestInterceptor = this.requestInterceptor ;
@@ -850,7 +808,7 @@ Operation.prototype.execute = function (arg1, arg2, arg3, arg4, parent) {
850
808
  for (attrname in contentTypeHeaders) { headers[attrname] = contentTypeHeaders[attrname]; }
851
809
 
852
810
  var body = this.getBody(contentTypeHeaders, args, opts);
853
- var url = this.urlify(args, opts.maskPasswords);
811
+ var url = this.urlify(args);
854
812
 
855
813
  if(url.indexOf('.{format}') > 0) {
856
814
  if(headers) {
@@ -874,8 +832,6 @@ Operation.prototype.execute = function (arg1, arg2, arg3, arg4, parent) {
874
832
  deferred: deferred,
875
833
  headers: headers,
876
834
  clientAuthorizations: opts.clientAuthorizations,
877
- operation: this,
878
- connectionAgent: this.connectionAgent,
879
835
  on: {
880
836
  response: function (response) {
881
837
  if (deferred) {
@@ -1032,7 +988,7 @@ Operation.prototype.matchesAccept = function(accepts) {
1032
988
  };
1033
989
 
1034
990
  Operation.prototype.asCurl = function (args1, args2) {
1035
- var opts = {mock: true, maskPasswords: true};
991
+ var opts = {mock: true};
1036
992
  if (typeof args2 === 'object') {
1037
993
  for (var argKey in args2) {
1038
994
  opts[argKey] = args2[argKey];
@@ -1099,14 +1055,14 @@ Operation.prototype.asCurl = function (args1, args2) {
1099
1055
  if (Array.isArray(paramValue)) {
1100
1056
  if(parameter.collectionFormat === 'multi') {
1101
1057
  for(var v in paramValue) {
1102
- body += '-F ' + this.encodeQueryKey(parameter.name) + '=' + mask(paramValue[v], parameter.format) + ' ';
1058
+ body += '-F ' + this.encodeQueryKey(parameter.name) + '=' + paramValue[v] + ' ';
1103
1059
  }
1104
1060
  }
1105
1061
  else {
1106
- body += '-F ' + this.encodeQueryCollection(parameter.collectionFormat, parameter.name, mask(paramValue, parameter.format)) + ' ';
1062
+ body += '-F ' + this.encodeQueryCollection(parameter.collectionFormat, parameter.name, paramValue) + ' ';
1107
1063
  }
1108
1064
  } else {
1109
- body += '-F ' + this.encodeQueryKey(parameter.name) + '=' + mask(paramValue, parameter.format) + ' ';
1065
+ body += '-F ' + this.encodeQueryKey(parameter.name) + '=' + paramValue + ' ';
1110
1066
  }
1111
1067
  }
1112
1068
  }
@@ -1137,7 +1093,7 @@ Operation.prototype.asCurl = function (args1, args2) {
1137
1093
  return 'curl ' + (results.join(' ')) + ' \'' + obj.url + '\'';
1138
1094
  };
1139
1095
 
1140
- Operation.prototype.encodePathCollection = function (type, name, value, maskPasswords) {
1096
+ Operation.prototype.encodePathCollection = function (type, name, value) {
1141
1097
  var encoded = '';
1142
1098
  var i;
1143
1099
  var separator = '';
@@ -1154,16 +1110,16 @@ Operation.prototype.encodePathCollection = function (type, name, value, maskPass
1154
1110
 
1155
1111
  for (i = 0; i < value.length; i++) {
1156
1112
  if (i === 0) {
1157
- encoded = this.encodeQueryParam(value[i], maskPasswords);
1113
+ encoded = this.encodeQueryParam(value[i]);
1158
1114
  } else {
1159
- encoded += separator + this.encodeQueryParam(value[i], maskPasswords);
1115
+ encoded += separator + this.encodeQueryParam(value[i]);
1160
1116
  }
1161
1117
  }
1162
1118
 
1163
1119
  return encoded;
1164
1120
  };
1165
1121
 
1166
- Operation.prototype.encodeQueryCollection = function (type, name, value, maskPasswords) {
1122
+ Operation.prototype.encodeQueryCollection = function (type, name, value) {
1167
1123
  var encoded = '';
1168
1124
  var i;
1169
1125
 
@@ -1172,7 +1128,7 @@ Operation.prototype.encodeQueryCollection = function (type, name, value, maskPas
1172
1128
  for (i = 0; i < value.length; i++) {
1173
1129
  if (i > 0) {encoded += '&';}
1174
1130
 
1175
- encoded += this.encodeQueryKey(name) + '=' + mask(this.encodeQueryParam(value[i]), maskPasswords);
1131
+ encoded += this.encodeQueryKey(name) + '=' + this.encodeQueryParam(value[i]);
1176
1132
  }
1177
1133
  } else {
1178
1134
  var separator = '';
@@ -1190,7 +1146,8 @@ Operation.prototype.encodeQueryCollection = function (type, name, value, maskPas
1190
1146
  if (i !== 0) {
1191
1147
  encoded += '&';
1192
1148
  }
1193
- encoded += this.encodeQueryKey(name) + '[]=' + mask(this.encodeQueryParam(value[i]), maskPasswords);
1149
+
1150
+ encoded += this.encodeQueryKey(name) + '[]=' + this.encodeQueryParam(value[i]);
1194
1151
  }
1195
1152
  }
1196
1153
 
@@ -1213,23 +1170,13 @@ Operation.prototype.encodeQueryKey = function (arg) {
1213
1170
  .replace('%5B','[').replace('%5D', ']').replace('%24', '$');
1214
1171
  };
1215
1172
 
1216
- Operation.prototype.encodeQueryParam = function (arg, maskPasswords) {
1217
- if(maskPasswords) {
1218
- return "******";
1219
- }
1173
+ Operation.prototype.encodeQueryParam = function (arg) {
1220
1174
  return encodeURIComponent(arg);
1221
1175
  };
1222
1176
 
1223
1177
  /**
1224
1178
  * TODO revisit, might not want to leave '/'
1225
1179
  **/
1226
- Operation.prototype.encodePathParam = function (pathParam, maskPasswords) {
1227
- return encodeURIComponent(pathParam, maskPasswords);
1180
+ Operation.prototype.encodePathParam = function (pathParam) {
1181
+ return encodeURIComponent(pathParam);
1228
1182
  };
1229
-
1230
- var mask = function(value, format) {
1231
- if(typeof format === 'string' && format === 'password') {
1232
- return '******';
1233
- }
1234
- return value;
1235
- }
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.29",
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",