swagger-client 3.13.0 → 3.13.5

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.
Files changed (40) hide show
  1. package/README.md +1 -1
  2. package/dist/swagger-client.browser.js +1439 -2075
  3. package/dist/swagger-client.browser.min.js +1 -1
  4. package/dist/swagger-client.browser.min.js.map +1 -1
  5. package/es/execute/index.js +28 -42
  6. package/es/execute/oas3/build-request.js +44 -26
  7. package/es/execute/oas3/content-serializer.js +1 -1
  8. package/es/execute/oas3/parameter-builders.js +3 -5
  9. package/es/execute/oas3/style-serializer.js +36 -43
  10. package/es/execute/swagger2/build-request.js +17 -17
  11. package/es/execute/swagger2/parameter-builders.js +1 -4
  12. package/es/helpers.js +6 -13
  13. package/es/http.js +64 -82
  14. package/es/index.js +1 -2
  15. package/es/interfaces.js +3 -6
  16. package/es/internal/form-data-monkey-patch.js +4 -7
  17. package/es/resolver.js +1 -1
  18. package/es/specmap/helpers.js +7 -14
  19. package/es/specmap/index.js +64 -75
  20. package/es/specmap/lib/all-of.js +4 -10
  21. package/es/specmap/lib/context-tree.js +4 -10
  22. package/es/specmap/lib/index.js +25 -30
  23. package/es/specmap/lib/parameters.js +3 -6
  24. package/es/specmap/lib/refs.js +20 -33
  25. package/es/subtree-resolver/index.js +2 -3
  26. package/lib/execute/index.js +3 -3
  27. package/lib/execute/oas3/build-request.js +13 -0
  28. package/lib/execute/oas3/parameter-builders.js +2 -2
  29. package/lib/execute/swagger2/build-request.js +5 -0
  30. package/lib/index.js +3 -3
  31. package/lib/interfaces.js +1 -1
  32. package/lib/resolver.js +2 -2
  33. package/lib/specmap/index.js +1 -1
  34. package/lib/specmap/lib/all-of.js +1 -1
  35. package/lib/specmap/lib/context-tree.js +1 -1
  36. package/lib/specmap/lib/index.js +3 -3
  37. package/lib/specmap/lib/parameters.js +1 -1
  38. package/lib/specmap/lib/properties.js +1 -1
  39. package/lib/subtree-resolver/index.js +1 -1
  40. package/package.json +23 -26
@@ -1,17 +1,13 @@
1
- import _sliceInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/slice";
2
1
  import _slicedToArray from "@babel/runtime-corejs3/helpers/slicedToArray";
3
- import _indexOfInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/index-of";
4
- import _mapInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/map";
5
- import _reduceInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/reduce";
6
- import _concatInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/concat";
7
- import _JSON$stringify from "@babel/runtime-corejs3/core-js-stable/json/stringify";
8
2
  import _objectSpread from "@babel/runtime-corejs3/helpers/objectSpread2";
9
3
  import _objectWithoutProperties from "@babel/runtime-corejs3/helpers/objectWithoutProperties";
10
- import _Object$keys from "@babel/runtime-corejs3/core-js-stable/object/keys";
11
- import _forEachInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/for-each";
12
- import _filterInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/filter";
13
4
  import _Object$assign from "@babel/runtime-corejs3/core-js-stable/object/assign";
14
- import _Array$isArray from "@babel/runtime-corejs3/core-js-stable/array/is-array";
5
+ import _filterInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/filter";
6
+ import _Object$keys from "@babel/runtime-corejs3/core-js-stable/object/keys";
7
+ import _JSON$stringify from "@babel/runtime-corejs3/core-js-stable/json/stringify";
8
+ import _concatInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/concat";
9
+ import _mapInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/map";
10
+ import _sliceInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/slice";
15
11
  import getIn from 'lodash/get';
16
12
  import isPlainObject from 'lodash/isPlainObject';
17
13
  import isArray from 'lodash/isArray';
@@ -26,7 +22,7 @@ import swagger2BuildRequest from './swagger2/build-request';
26
22
  import { getOperationRaw, legacyIdFromPathMethod, isOAS3 } from '../helpers';
27
23
 
28
24
  var arrayOrEmpty = function arrayOrEmpty(ar) {
29
- return _Array$isArray(ar) ? ar : [];
25
+ return Array.isArray(ar) ? ar : [];
30
26
  };
31
27
 
32
28
  var OperationNotFoundError = createError('OperationNotFoundError', function cb(message, extra, oriError) {
@@ -43,24 +39,18 @@ var findParametersWithName = function findParametersWithName(name, parameters) {
43
39
 
44
40
 
45
41
  var deduplicateParameters = function deduplicateParameters(parameters) {
46
- var _context;
47
-
48
42
  var paramsMap = {};
49
-
50
- _forEachInstanceProperty(parameters).call(parameters, function (p) {
43
+ parameters.forEach(function (p) {
51
44
  if (!paramsMap[p.in]) {
52
45
  paramsMap[p.in] = {};
53
46
  }
54
47
 
55
48
  paramsMap[p.in][p.name] = p;
56
49
  });
57
-
58
50
  var dedupedParameters = [];
59
51
 
60
- _forEachInstanceProperty(_context = _Object$keys(paramsMap)).call(_context, function (i) {
61
- var _context2;
62
-
63
- _forEachInstanceProperty(_context2 = _Object$keys(paramsMap[i])).call(_context2, function (p) {
52
+ _Object$keys(paramsMap).forEach(function (i) {
53
+ _Object$keys(paramsMap[i]).forEach(function (p) {
64
54
  dedupedParameters.push(paramsMap[i][p]);
65
55
  });
66
56
  });
@@ -109,7 +99,7 @@ export function execute(_ref) {
109
99
  } // Build a request, which can be handled by the `http.js` implementation.
110
100
 
111
101
  export function buildRequest(options) {
112
- var _context3, _context4;
102
+ var _context, _context2;
113
103
 
114
104
  var spec = options.spec,
115
105
  operationId = options.operationId,
@@ -196,13 +186,13 @@ export function buildRequest(options) {
196
186
  req.headers.accept = responseContentType;
197
187
  }
198
188
 
199
- var combinedParameters = deduplicateParameters(_concatInstanceProperty(_context3 = _concatInstanceProperty(_context4 = []).call(_context4, arrayOrEmpty(operation.parameters)) // operation parameters
200
- ).call(_context3, arrayOrEmpty(path.parameters))); // path parameters
189
+ var combinedParameters = deduplicateParameters(_concatInstanceProperty(_context = _concatInstanceProperty(_context2 = []).call(_context2, arrayOrEmpty(operation.parameters)) // operation parameters
190
+ ).call(_context, arrayOrEmpty(path.parameters))); // path parameters
201
191
  // REVIEW: OAS3: have any key names or parameter shapes changed?
202
192
  // Any new features that need to be plugged in here?
203
193
  // Add values to request
204
194
 
205
- _forEachInstanceProperty(combinedParameters).call(combinedParameters, function (parameter) {
195
+ combinedParameters.forEach(function (parameter) {
206
196
  var builder = parameterBuilders[parameter.in];
207
197
  var value;
208
198
 
@@ -213,17 +203,17 @@ export function buildRequest(options) {
213
203
  value = parameter && parameter.name && parameters[parameter.name];
214
204
 
215
205
  if (typeof value === 'undefined') {
216
- var _context5;
206
+ var _context3;
217
207
 
218
208
  // check for `name-in` formatted key
219
- value = parameter && parameter.name && parameters[_concatInstanceProperty(_context5 = "".concat(parameter.in, ".")).call(_context5, parameter.name)];
209
+ value = parameter && parameter.name && parameters[_concatInstanceProperty(_context3 = "".concat(parameter.in, ".")).call(_context3, parameter.name)];
220
210
  } else if (findParametersWithName(parameter.name, combinedParameters).length > 1) {
221
- var _context6;
211
+ var _context4;
222
212
 
223
213
  // value came from `parameters[parameter.name]`
224
214
  // check to see if this is an ambiguous parameter
225
215
  // eslint-disable-next-line no-console
226
- console.warn(_concatInstanceProperty(_context6 = "Parameter '".concat(parameter.name, "' is ambiguous because the defined spec has more than one parameter with the name: '")).call(_context6, parameter.name, "' and the passed-in parameter values did not define an 'in' value."));
216
+ console.warn(_concatInstanceProperty(_context4 = "Parameter '".concat(parameter.name, "' is ambiguous because the defined spec has more than one parameter with the name: '")).call(_context4, parameter.name, "' and the passed-in parameter values did not define an 'in' value."));
227
217
  }
228
218
 
229
219
  if (value === null) {
@@ -257,7 +247,6 @@ export function buildRequest(options) {
257
247
  }
258
248
  }); // Do version-specific tasks, then return those results.
259
249
 
260
-
261
250
  var versionSpecificOptions = _objectSpread(_objectSpread({}, options), {}, {
262
251
  operation: operation
263
252
  });
@@ -272,9 +261,7 @@ export function buildRequest(options) {
272
261
 
273
262
 
274
263
  if (req.cookies && _Object$keys(req.cookies).length) {
275
- var _context7;
276
-
277
- var cookieString = _reduceInstanceProperty(_context7 = _Object$keys(req.cookies)).call(_context7, function (prev, cookieName) {
264
+ var cookieString = _Object$keys(req.cookies).reduce(function (prev, cookieName) {
278
265
  var cookieValue = req.cookies[cookieName];
279
266
  var prefix = prev ? '&' : '';
280
267
  var stringified = cookie.serialize(cookieName, cookieValue);
@@ -324,9 +311,9 @@ function oas3BaseUrl(_ref2) {
324
311
  return srv.url;
325
312
  });
326
313
 
327
- if (_indexOfInstanceProperty(serverUrls).call(serverUrls, server) > -1) {
314
+ if (serverUrls.indexOf(server) > -1) {
328
315
  selectedServerUrl = server;
329
- selectedServerObj = servers[_indexOfInstanceProperty(serverUrls).call(serverUrls, server)];
316
+ selectedServerObj = servers[serverUrls.indexOf(server)];
330
317
  }
331
318
  }
332
319
 
@@ -339,11 +326,10 @@ function oas3BaseUrl(_ref2) {
339
326
  selectedServerObj = _servers[0];
340
327
  }
341
328
 
342
- if (_indexOfInstanceProperty(selectedServerUrl).call(selectedServerUrl, '{') > -1) {
329
+ if (selectedServerUrl.indexOf('{') > -1) {
343
330
  // do variable substitution
344
331
  var varNames = getVariableTemplateNames(selectedServerUrl);
345
-
346
- _forEachInstanceProperty(varNames).call(varNames, function (vari) {
332
+ varNames.forEach(function (vari) {
347
333
  if (selectedServerObj.variables && selectedServerObj.variables[vari]) {
348
334
  // variable is defined in server
349
335
  var variableDefinition = selectedServerObj.variables[vari];
@@ -369,9 +355,9 @@ function buildOas3UrlWithContext() {
369
355
  var res;
370
356
 
371
357
  if (computedScheme && computedHost) {
372
- var _context8;
358
+ var _context5;
373
359
 
374
- res = _concatInstanceProperty(_context8 = "".concat(computedScheme, "://")).call(_context8, computedHost + computedPath); // If last character is '/', trim it off
360
+ res = _concatInstanceProperty(_context5 = "".concat(computedScheme, "://")).call(_context5, computedHost + computedPath); // If last character is '/', trim it off
375
361
  } else {
376
362
  res = computedPath;
377
363
  }
@@ -398,17 +384,17 @@ function swagger2BaseUrl(_ref3) {
398
384
  _ref3$contextUrl = _ref3.contextUrl,
399
385
  contextUrl = _ref3$contextUrl === void 0 ? '' : _ref3$contextUrl;
400
386
  var parsedContextUrl = url.parse(contextUrl);
401
- var firstSchemeInSpec = _Array$isArray(spec.schemes) ? spec.schemes[0] : null;
387
+ var firstSchemeInSpec = Array.isArray(spec.schemes) ? spec.schemes[0] : null;
402
388
  var computedScheme = scheme || firstSchemeInSpec || stripNonAlpha(parsedContextUrl.protocol) || 'http';
403
389
  var computedHost = spec.host || parsedContextUrl.host || '';
404
390
  var computedPath = spec.basePath || '';
405
391
  var res;
406
392
 
407
393
  if (computedScheme && computedHost) {
408
- var _context9;
394
+ var _context6;
409
395
 
410
396
  // we have what we need for an absolute URL
411
- res = _concatInstanceProperty(_context9 = "".concat(computedScheme, "://")).call(_context9, computedHost + computedPath);
397
+ res = _concatInstanceProperty(_context6 = "".concat(computedScheme, "://")).call(_context6, computedHost + computedPath);
412
398
  } else {
413
399
  // if not, a relative URL will have to do
414
400
  res = computedPath;
@@ -1,13 +1,14 @@
1
- import _concatInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/concat";
2
- import _Array$isArray from "@babel/runtime-corejs3/core-js-stable/array/is-array";
3
- import _forEachInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/for-each";
4
1
  import _typeof from "@babel/runtime-corejs3/helpers/typeof";
5
- import _indexOfInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/index-of";
2
+ import _slicedToArray from "@babel/runtime-corejs3/helpers/slicedToArray";
6
3
  import _Object$keys from "@babel/runtime-corejs3/core-js-stable/object/keys";
4
+ import _filterInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/filter";
5
+ import _Object$entries from "@babel/runtime-corejs3/core-js-stable/object/entries";
6
+ import _concatInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/concat";
7
7
  // This function runs after the common function,
8
8
  // `src/execute/index.js#buildRequest`
9
9
  import assign from 'lodash/assign';
10
10
  import get from 'lodash/get';
11
+ import isPlainObject from 'lodash/isPlainObject';
11
12
  import btoa from 'btoa';
12
13
  export default function buildRequest(options, req) {
13
14
  var operation = options.operation,
@@ -26,7 +27,7 @@ export default function buildRequest(options, req) {
26
27
 
27
28
  var requestBodyMediaTypes = _Object$keys(requestBodyDef.content || {});
28
29
 
29
- var isExplicitContentTypeValid = requestContentType && _indexOfInstanceProperty(requestBodyMediaTypes).call(requestBodyMediaTypes, requestContentType) > -1; // for OAS3: set the Content-Type
30
+ var isExplicitContentTypeValid = requestContentType && requestBodyMediaTypes.indexOf(requestContentType) > -1; // for OAS3: set the Content-Type
30
31
 
31
32
  if (requestBody || attachContentTypeForEmptyPayload) {
32
33
  // does the passed requestContentType appear in the requestBody definition?
@@ -42,22 +43,42 @@ export default function buildRequest(options, req) {
42
43
  }
43
44
  } else if (requestContentType && isExplicitContentTypeValid) {
44
45
  req.headers['Content-Type'] = requestContentType;
46
+ }
47
+
48
+ if (!options.responseContentType && operation.responses) {
49
+ var _context;
50
+
51
+ var mediaTypes = _filterInstanceProperty(_context = _Object$entries(operation.responses)).call(_context, function (_ref) {
52
+ var _ref2 = _slicedToArray(_ref, 2),
53
+ key = _ref2[0],
54
+ value = _ref2[1];
55
+
56
+ var code = parseInt(key, 10);
57
+ return code >= 200 && code < 300 && isPlainObject(value.content);
58
+ }).reduce(function (acc, _ref3) {
59
+ var _ref4 = _slicedToArray(_ref3, 2),
60
+ value = _ref4[1];
61
+
62
+ return _concatInstanceProperty(acc).call(acc, _Object$keys(value.content));
63
+ }, []);
64
+
65
+ if (mediaTypes.length > 0) {
66
+ req.headers.accept = mediaTypes.join(', ');
67
+ }
45
68
  } // for OAS3: add requestBody to request
46
69
 
47
70
 
48
71
  if (requestBody) {
49
72
  if (requestContentType) {
50
- if (_indexOfInstanceProperty(requestBodyMediaTypes).call(requestBodyMediaTypes, requestContentType) > -1) {
73
+ if (requestBodyMediaTypes.indexOf(requestContentType) > -1) {
51
74
  // only attach body if the requestBody has a definition for the
52
75
  // contentType that has been explicitly set
53
76
  if (requestContentType === 'application/x-www-form-urlencoded' || requestContentType === 'multipart/form-data') {
54
77
  if (_typeof(requestBody) === 'object') {
55
- var _context;
56
-
57
78
  var encoding = (requestBodyDef.content[requestContentType] || {}).encoding || {};
58
79
  req.form = {};
59
80
 
60
- _forEachInstanceProperty(_context = _Object$keys(requestBody)).call(_context, function (k) {
81
+ _Object$keys(requestBody).forEach(function (k) {
61
82
  req.form[k] = {
62
83
  value: requestBody[k],
63
84
  encoding: encoding[k] || {}
@@ -79,13 +100,13 @@ export default function buildRequest(options, req) {
79
100
  } // Add security values, to operations - that declare their need on them
80
101
  // Adapted from the Swagger2 implementation
81
102
 
82
- export function applySecurities(_ref) {
83
- var request = _ref.request,
84
- _ref$securities = _ref.securities,
85
- securities = _ref$securities === void 0 ? {} : _ref$securities,
86
- _ref$operation = _ref.operation,
87
- operation = _ref$operation === void 0 ? {} : _ref$operation,
88
- spec = _ref.spec;
103
+ export function applySecurities(_ref5) {
104
+ var request = _ref5.request,
105
+ _ref5$securities = _ref5.securities,
106
+ securities = _ref5$securities === void 0 ? {} : _ref5$securities,
107
+ _ref5$operation = _ref5.operation,
108
+ operation = _ref5$operation === void 0 ? {} : _ref5$operation,
109
+ spec = _ref5.spec;
89
110
  var result = assign({}, request);
90
111
  var _securities$authorize = securities.authorized,
91
112
  authorized = _securities$authorize === void 0 ? {} : _securities$authorize;
@@ -95,14 +116,12 @@ export function applySecurities(_ref) {
95
116
  result.headers = result.headers || {};
96
117
  result.query = result.query || {};
97
118
 
98
- if (!_Object$keys(securities).length || !isAuthorized || !security || _Array$isArray(operation.security) && !operation.security.length) {
119
+ if (!_Object$keys(securities).length || !isAuthorized || !security || Array.isArray(operation.security) && !operation.security.length) {
99
120
  return request;
100
121
  }
101
122
 
102
- _forEachInstanceProperty(security).call(security, function (securityObj) {
103
- var _context2;
104
-
105
- _forEachInstanceProperty(_context2 = _Object$keys(securityObj)).call(_context2, function (key) {
123
+ security.forEach(function (securityObj) {
124
+ _Object$keys(securityObj).forEach(function (key) {
106
125
  var auth = authorized[key];
107
126
  var schema = securityDef[key];
108
127
 
@@ -128,11 +147,11 @@ export function applySecurities(_ref) {
128
147
  }
129
148
  } else if (type === 'http') {
130
149
  if (/^basic$/i.test(schema.scheme)) {
131
- var _context3;
150
+ var _context2;
132
151
 
133
152
  var username = value.username || '';
134
153
  var password = value.password || '';
135
- var encoded = btoa(_concatInstanceProperty(_context3 = "".concat(username, ":")).call(_context3, password));
154
+ var encoded = btoa(_concatInstanceProperty(_context2 = "".concat(username, ":")).call(_context2, password));
136
155
  result.headers.Authorization = "Basic ".concat(encoded);
137
156
  }
138
157
 
@@ -140,7 +159,7 @@ export function applySecurities(_ref) {
140
159
  result.headers.Authorization = "Bearer ".concat(value);
141
160
  }
142
161
  } else if (type === 'oauth2' || type === 'openIdConnect') {
143
- var _context4;
162
+ var _context3;
144
163
 
145
164
  var token = auth.token || {};
146
165
  var tokenName = schema['x-tokenName'] || 'access_token';
@@ -151,11 +170,10 @@ export function applySecurities(_ref) {
151
170
  tokenType = 'Bearer';
152
171
  }
153
172
 
154
- result.headers.Authorization = _concatInstanceProperty(_context4 = "".concat(tokenType, " ")).call(_context4, tokenValue);
173
+ result.headers.Authorization = _concatInstanceProperty(_context3 = "".concat(tokenType, " ")).call(_context3, tokenValue);
155
174
  }
156
175
  }
157
176
  });
158
177
  });
159
-
160
178
  return result;
161
179
  }
@@ -1,5 +1,5 @@
1
- import _JSON$stringify from "@babel/runtime-corejs3/core-js-stable/json/stringify";
2
1
  import _includesInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/includes";
2
+ import _JSON$stringify from "@babel/runtime-corejs3/core-js-stable/json/stringify";
3
3
 
4
4
  /*
5
5
  Serializer that serializes according to a media type instead of OpenAPI's
@@ -1,8 +1,6 @@
1
- import _Array$isArray from "@babel/runtime-corejs3/core-js-stable/array/is-array";
2
- import _concatInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/concat";
3
1
  import _typeof from "@babel/runtime-corejs3/helpers/typeof";
4
- import _indexOfInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/index-of";
5
2
  import _Object$keys from "@babel/runtime-corejs3/core-js-stable/object/keys";
3
+ import _concatInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/concat";
6
4
  import pick from 'lodash/pick';
7
5
  import stylize, { encodeDisallowedCharacters } from './style-serializer';
8
6
  import serialize from './content-serializer';
@@ -72,7 +70,7 @@ export function header(_ref3) {
72
70
  value = _ref3.value;
73
71
  req.headers = req.headers || {};
74
72
 
75
- if (_indexOfInstanceProperty(PARAMETER_HEADER_BLACKLIST).call(PARAMETER_HEADER_BLACKLIST, parameter.name.toLowerCase()) > -1) {
73
+ if (PARAMETER_HEADER_BLACKLIST.indexOf(parameter.name.toLowerCase()) > -1) {
76
74
  return;
77
75
  }
78
76
 
@@ -111,7 +109,7 @@ export function cookie(_ref4) {
111
109
  }
112
110
 
113
111
  if (type !== 'undefined') {
114
- var prefix = type === 'object' && !_Array$isArray(value) && parameter.explode ? '' : "".concat(parameter.name, "=");
112
+ var prefix = type === 'object' && !Array.isArray(value) && parameter.explode ? '' : "".concat(parameter.name, "=");
115
113
  req.headers.Cookie = prefix + stylize({
116
114
  key: parameter.name,
117
115
  value: value,
@@ -1,20 +1,15 @@
1
- import _Object$keys from "@babel/runtime-corejs3/core-js-stable/object/keys";
2
- import _concatInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/concat";
3
- import _reduceInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/reduce";
4
1
  import _typeof from "@babel/runtime-corejs3/helpers/typeof";
5
- import _Array$isArray from "@babel/runtime-corejs3/core-js-stable/array/is-array";
6
- import _sliceInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/slice";
7
2
  import _toConsumableArray from "@babel/runtime-corejs3/helpers/toConsumableArray";
8
3
  import _mapInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/map";
9
- import _indexOfInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/index-of";
4
+ import _sliceInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/slice";
5
+ import _concatInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/concat";
6
+ import _Object$keys from "@babel/runtime-corejs3/core-js-stable/object/keys";
10
7
 
11
8
  var _require = require('buffer'),
12
9
  Buffer = _require.Buffer;
13
10
 
14
11
  var isRfc3986Reserved = function isRfc3986Reserved(char) {
15
- var _context;
16
-
17
- return _indexOfInstanceProperty(_context = ":/?#[]@!$&'()*+,;=").call(_context, char) > -1;
12
+ return ":/?#[]@!$&'()*+,;=".indexOf(char) > -1;
18
13
  };
19
14
 
20
15
  var isRrc3986Unreserved = function isRrc3986Unreserved(char) {
@@ -22,7 +17,7 @@ var isRrc3986Unreserved = function isRrc3986Unreserved(char) {
22
17
  };
23
18
 
24
19
  export function encodeDisallowedCharacters(str) {
25
- var _context2;
20
+ var _context;
26
21
 
27
22
  var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
28
23
  escape = _ref.escape;
@@ -49,8 +44,8 @@ export function encodeDisallowedCharacters(str) {
49
44
  // code points rather than UCS-2/UTF-16 code units.
50
45
 
51
46
 
52
- return _mapInstanceProperty(_context2 = _toConsumableArray(str)).call(_context2, function (char) {
53
- var _context3, _context4;
47
+ return _mapInstanceProperty(_context = _toConsumableArray(str)).call(_context, function (char) {
48
+ var _context2, _context3;
54
49
 
55
50
  if (isRrc3986Unreserved(char)) {
56
51
  return char;
@@ -60,11 +55,11 @@ export function encodeDisallowedCharacters(str) {
60
55
  return char;
61
56
  }
62
57
 
63
- var encoded = _mapInstanceProperty(_context3 = _mapInstanceProperty(_context4 = Buffer.from(char).toJSON().data || []).call(_context4, function (byte) {
64
- var _context5;
58
+ var encoded = _mapInstanceProperty(_context2 = _mapInstanceProperty(_context3 = Buffer.from(char).toJSON().data || []).call(_context3, function (byte) {
59
+ var _context4;
65
60
 
66
- return _sliceInstanceProperty(_context5 = "0".concat(byte.toString(16).toUpperCase())).call(_context5, -2);
67
- })).call(_context3, function (encodedByte) {
61
+ return _sliceInstanceProperty(_context4 = "0".concat(byte.toString(16).toUpperCase())).call(_context4, -2);
62
+ })).call(_context2, function (encodedByte) {
68
63
  return "%".concat(encodedByte);
69
64
  }).join('');
70
65
 
@@ -74,7 +69,7 @@ export function encodeDisallowedCharacters(str) {
74
69
  export default function stylize(config) {
75
70
  var value = config.value;
76
71
 
77
- if (_Array$isArray(value)) {
72
+ if (Array.isArray(value)) {
78
73
  return encodeArray(config);
79
74
  }
80
75
 
@@ -111,20 +106,18 @@ function encodeArray(_ref2) {
111
106
  }
112
107
 
113
108
  if (style === 'matrix') {
114
- var _context6;
115
-
116
- return _reduceInstanceProperty(_context6 = _mapInstanceProperty(value).call(value, function (val) {
109
+ return _mapInstanceProperty(value).call(value, function (val) {
117
110
  return valueEncoder(val);
118
- })).call(_context6, function (prev, curr) {
119
- var _context9;
111
+ }).reduce(function (prev, curr) {
112
+ var _context7;
120
113
 
121
114
  if (!prev || explode) {
122
- var _context7, _context8;
115
+ var _context5, _context6;
123
116
 
124
- return _concatInstanceProperty(_context7 = _concatInstanceProperty(_context8 = "".concat(prev || '', ";")).call(_context8, key, "=")).call(_context7, curr);
117
+ return _concatInstanceProperty(_context5 = _concatInstanceProperty(_context6 = "".concat(prev || '', ";")).call(_context6, key, "=")).call(_context5, curr);
125
118
  }
126
119
 
127
- return _concatInstanceProperty(_context9 = "".concat(prev, ",")).call(_context9, curr);
120
+ return _concatInstanceProperty(_context7 = "".concat(prev, ",")).call(_context7, curr);
128
121
  }, '');
129
122
  }
130
123
 
@@ -170,56 +163,56 @@ function encodeObject(_ref3) {
170
163
  var valueKeys = _Object$keys(value);
171
164
 
172
165
  if (style === 'simple') {
173
- return _reduceInstanceProperty(valueKeys).call(valueKeys, function (prev, curr) {
174
- var _context10, _context11, _context12;
166
+ return valueKeys.reduce(function (prev, curr) {
167
+ var _context8, _context9, _context10;
175
168
 
176
169
  var val = valueEncoder(value[curr]);
177
170
  var middleChar = explode ? '=' : ',';
178
171
  var prefix = prev ? "".concat(prev, ",") : '';
179
- return _concatInstanceProperty(_context10 = _concatInstanceProperty(_context11 = _concatInstanceProperty(_context12 = "".concat(prefix)).call(_context12, curr)).call(_context11, middleChar)).call(_context10, val);
172
+ return _concatInstanceProperty(_context8 = _concatInstanceProperty(_context9 = _concatInstanceProperty(_context10 = "".concat(prefix)).call(_context10, curr)).call(_context9, middleChar)).call(_context8, val);
180
173
  }, '');
181
174
  }
182
175
 
183
176
  if (style === 'label') {
184
- return _reduceInstanceProperty(valueKeys).call(valueKeys, function (prev, curr) {
185
- var _context13, _context14, _context15;
177
+ return valueKeys.reduce(function (prev, curr) {
178
+ var _context11, _context12, _context13;
186
179
 
187
180
  var val = valueEncoder(value[curr]);
188
181
  var middleChar = explode ? '=' : '.';
189
182
  var prefix = prev ? "".concat(prev, ".") : '.';
190
- return _concatInstanceProperty(_context13 = _concatInstanceProperty(_context14 = _concatInstanceProperty(_context15 = "".concat(prefix)).call(_context15, curr)).call(_context14, middleChar)).call(_context13, val);
183
+ return _concatInstanceProperty(_context11 = _concatInstanceProperty(_context12 = _concatInstanceProperty(_context13 = "".concat(prefix)).call(_context13, curr)).call(_context12, middleChar)).call(_context11, val);
191
184
  }, '');
192
185
  }
193
186
 
194
187
  if (style === 'matrix' && explode) {
195
- return _reduceInstanceProperty(valueKeys).call(valueKeys, function (prev, curr) {
196
- var _context16, _context17;
188
+ return valueKeys.reduce(function (prev, curr) {
189
+ var _context14, _context15;
197
190
 
198
191
  var val = valueEncoder(value[curr]);
199
192
  var prefix = prev ? "".concat(prev, ";") : ';';
200
- return _concatInstanceProperty(_context16 = _concatInstanceProperty(_context17 = "".concat(prefix)).call(_context17, curr, "=")).call(_context16, val);
193
+ return _concatInstanceProperty(_context14 = _concatInstanceProperty(_context15 = "".concat(prefix)).call(_context15, curr, "=")).call(_context14, val);
201
194
  }, '');
202
195
  }
203
196
 
204
197
  if (style === 'matrix') {
205
198
  // no explode
206
- return _reduceInstanceProperty(valueKeys).call(valueKeys, function (prev, curr) {
207
- var _context18, _context19;
199
+ return valueKeys.reduce(function (prev, curr) {
200
+ var _context16, _context17;
208
201
 
209
202
  var val = valueEncoder(value[curr]);
210
203
  var prefix = prev ? "".concat(prev, ",") : ";".concat(key, "=");
211
- return _concatInstanceProperty(_context18 = _concatInstanceProperty(_context19 = "".concat(prefix)).call(_context19, curr, ",")).call(_context18, val);
204
+ return _concatInstanceProperty(_context16 = _concatInstanceProperty(_context17 = "".concat(prefix)).call(_context17, curr, ",")).call(_context16, val);
212
205
  }, '');
213
206
  }
214
207
 
215
208
  if (style === 'form') {
216
- return _reduceInstanceProperty(valueKeys).call(valueKeys, function (prev, curr) {
217
- var _context20, _context21, _context22, _context23;
209
+ return valueKeys.reduce(function (prev, curr) {
210
+ var _context18, _context19, _context20, _context21;
218
211
 
219
212
  var val = valueEncoder(value[curr]);
220
- var prefix = prev ? _concatInstanceProperty(_context20 = "".concat(prev)).call(_context20, explode ? '&' : ',') : '';
213
+ var prefix = prev ? _concatInstanceProperty(_context18 = "".concat(prev)).call(_context18, explode ? '&' : ',') : '';
221
214
  var separator = explode ? '=' : ',';
222
- return _concatInstanceProperty(_context21 = _concatInstanceProperty(_context22 = _concatInstanceProperty(_context23 = "".concat(prefix)).call(_context23, curr)).call(_context22, separator)).call(_context21, val);
215
+ return _concatInstanceProperty(_context19 = _concatInstanceProperty(_context20 = _concatInstanceProperty(_context21 = "".concat(prefix)).call(_context21, curr)).call(_context20, separator)).call(_context19, val);
223
216
  }, '');
224
217
  }
225
218
 
@@ -247,9 +240,9 @@ function encodePrimitive(_ref4) {
247
240
  }
248
241
 
249
242
  if (style === 'matrix') {
250
- var _context24;
243
+ var _context22;
251
244
 
252
- return _concatInstanceProperty(_context24 = ";".concat(key, "=")).call(_context24, valueEncoder(value));
245
+ return _concatInstanceProperty(_context22 = ";".concat(key, "=")).call(_context22, valueEncoder(value));
253
246
  }
254
247
 
255
248
  if (style === 'form') {
@@ -1,9 +1,7 @@
1
- import _concatInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/concat";
2
- import _forEachInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/for-each";
3
- import _Object$keys from "@babel/runtime-corejs3/core-js-stable/object/keys";
4
- import _filterInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/filter";
5
1
  import _slicedToArray from "@babel/runtime-corejs3/helpers/slicedToArray";
6
- import _Array$isArray from "@babel/runtime-corejs3/core-js-stable/array/is-array";
2
+ import _filterInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/filter";
3
+ import _Object$keys from "@babel/runtime-corejs3/core-js-stable/object/keys";
4
+ import _concatInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/concat";
7
5
  import btoa from 'btoa';
8
6
  import assign from 'lodash/assign'; // This function runs after the common function,
9
7
  // `src/execute/index.js#buildRequest`
@@ -13,6 +11,7 @@ export default function buildRequest(options, req) {
13
11
  operation = options.operation,
14
12
  securities = options.securities,
15
13
  requestContentType = options.requestContentType,
14
+ responseContentType = options.responseContentType,
16
15
  attachContentTypeForEmptyPayload = options.attachContentTypeForEmptyPayload; // Add securities, which are applicable
17
16
 
18
17
  req = applySecurities({
@@ -28,11 +27,11 @@ export default function buildRequest(options, req) {
28
27
  // all following conditionals are Swagger2 only
29
28
  if (requestContentType) {
30
29
  req.headers['Content-Type'] = requestContentType;
31
- } else if (_Array$isArray(operation.consumes)) {
30
+ } else if (Array.isArray(operation.consumes)) {
32
31
  var _operation$consumes = _slicedToArray(operation.consumes, 1);
33
32
 
34
33
  req.headers['Content-Type'] = _operation$consumes[0];
35
- } else if (_Array$isArray(spec.consumes)) {
34
+ } else if (Array.isArray(spec.consumes)) {
36
35
  var _spec$consumes = _slicedToArray(spec.consumes, 1);
37
36
 
38
37
  req.headers['Content-Type'] = _spec$consumes[0];
@@ -60,6 +59,10 @@ export default function buildRequest(options, req) {
60
59
  }
61
60
  }
62
61
 
62
+ if (!responseContentType && Array.isArray(operation.produces) && operation.produces.length > 0) {
63
+ req.headers.accept = operation.produces.join(', ');
64
+ }
65
+
63
66
  return req;
64
67
  } // Add security values, to operations - that declare their need on them
65
68
 
@@ -81,14 +84,12 @@ export function applySecurities(_ref) {
81
84
  result.headers = result.headers || {};
82
85
  result.query = result.query || {};
83
86
 
84
- if (!_Object$keys(securities).length || !isAuthorized || !security || _Array$isArray(operation.security) && !operation.security.length) {
87
+ if (!_Object$keys(securities).length || !isAuthorized || !security || Array.isArray(operation.security) && !operation.security.length) {
85
88
  return request;
86
89
  }
87
90
 
88
- _forEachInstanceProperty(security).call(security, function (securityObj) {
89
- var _context5;
90
-
91
- _forEachInstanceProperty(_context5 = _Object$keys(securityObj)).call(_context5, function (key) {
91
+ security.forEach(function (securityObj) {
92
+ _Object$keys(securityObj).forEach(function (key) {
92
93
  var auth = authorized[key];
93
94
 
94
95
  if (!auth) {
@@ -112,22 +113,21 @@ export function applySecurities(_ref) {
112
113
  if (value.header) {
113
114
  result.headers.authorization = value.header;
114
115
  } else {
115
- var _context6;
116
+ var _context5;
116
117
 
117
118
  var username = value.username || '';
118
119
  var password = value.password || '';
119
- value.base64 = btoa(_concatInstanceProperty(_context6 = "".concat(username, ":")).call(_context6, password));
120
+ value.base64 = btoa(_concatInstanceProperty(_context5 = "".concat(username, ":")).call(_context5, password));
120
121
  result.headers.authorization = "Basic ".concat(value.base64);
121
122
  }
122
123
  } else if (type === 'oauth2' && oauthToken) {
123
- var _context7;
124
+ var _context6;
124
125
 
125
126
  tokenType = !tokenType || tokenType.toLowerCase() === 'bearer' ? 'Bearer' : tokenType;
126
- result.headers.authorization = _concatInstanceProperty(_context7 = "".concat(tokenType, " ")).call(_context7, oauthToken);
127
+ result.headers.authorization = _concatInstanceProperty(_context6 = "".concat(tokenType, " ")).call(_context6, oauthToken);
127
128
  }
128
129
  }
129
130
  });
130
131
  });
131
-
132
132
  return result;
133
133
  }