swagger-client 3.10.8 → 3.10.12

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 (57) hide show
  1. package/README.md +10 -2
  2. package/dist/swagger-client.browser.js +24191 -0
  3. package/dist/swagger-client.browser.min.js +3 -0
  4. package/dist/swagger-client.browser.min.js.map +1 -0
  5. package/es/commonjs.js +9 -0
  6. package/es/constants.js +2 -0
  7. package/es/execute/index.js +391 -0
  8. package/es/execute/oas3/build-request.js +149 -0
  9. package/es/execute/oas3/content-serializer.js +18 -0
  10. package/es/execute/oas3/parameter-builders.js +119 -0
  11. package/es/execute/oas3/style-serializer.js +232 -0
  12. package/es/execute/swagger2/build-request.js +119 -0
  13. package/es/execute/swagger2/parameter-builders.js +78 -0
  14. package/es/helpers.js +272 -0
  15. package/es/http.js +621 -0
  16. package/es/index.js +116 -0
  17. package/es/interfaces.js +145 -0
  18. package/es/internal/form-data-monkey-patch.js +94 -0
  19. package/es/resolver.js +123 -0
  20. package/es/specmap/helpers.js +62 -0
  21. package/es/specmap/index.js +613 -0
  22. package/es/specmap/lib/all-of.js +81 -0
  23. package/es/specmap/lib/context-tree.js +111 -0
  24. package/es/specmap/lib/create-error.js +24 -0
  25. package/es/specmap/lib/index.js +391 -0
  26. package/es/specmap/lib/parameters.js +31 -0
  27. package/es/specmap/lib/properties.js +23 -0
  28. package/es/specmap/lib/refs.js +516 -0
  29. package/es/subtree-resolver/index.js +92 -0
  30. package/lib/commonjs.js +10 -0
  31. package/lib/constants.js +7 -0
  32. package/lib/execute/index.js +421 -0
  33. package/lib/execute/oas3/build-request.js +161 -0
  34. package/lib/execute/oas3/content-serializer.js +21 -0
  35. package/lib/execute/oas3/parameter-builders.js +138 -0
  36. package/lib/execute/oas3/style-serializer.js +208 -0
  37. package/lib/execute/swagger2/build-request.js +120 -0
  38. package/lib/execute/swagger2/parameter-builders.js +88 -0
  39. package/lib/helpers.js +261 -0
  40. package/lib/http.js +470 -0
  41. package/lib/index.js +142 -0
  42. package/lib/interfaces.js +159 -0
  43. package/lib/internal/form-data-monkey-patch.js +83 -0
  44. package/lib/resolver.js +125 -0
  45. package/lib/specmap/helpers.js +65 -0
  46. package/lib/specmap/index.js +446 -0
  47. package/lib/specmap/lib/all-of.js +89 -0
  48. package/lib/specmap/lib/context-tree.js +111 -0
  49. package/lib/specmap/lib/create-error.js +25 -0
  50. package/lib/specmap/lib/index.js +402 -0
  51. package/lib/specmap/lib/parameters.js +42 -0
  52. package/lib/specmap/lib/properties.js +38 -0
  53. package/lib/specmap/lib/refs.js +509 -0
  54. package/lib/subtree-resolver/index.js +55 -0
  55. package/package.json +80 -106
  56. package/browser/index.js +0 -54
  57. package/dist/index.js +0 -4372
package/dist/index.js DELETED
@@ -1,4372 +0,0 @@
1
- module.exports =
2
- /******/ (function(modules) { // webpackBootstrap
3
- /******/ // The module cache
4
- /******/ var installedModules = {};
5
- /******/
6
- /******/ // The require function
7
- /******/ function __webpack_require__(moduleId) {
8
- /******/
9
- /******/ // Check if module is in cache
10
- /******/ if(installedModules[moduleId]) {
11
- /******/ return installedModules[moduleId].exports;
12
- /******/ }
13
- /******/ // Create a new module (and put it into the cache)
14
- /******/ var module = installedModules[moduleId] = {
15
- /******/ i: moduleId,
16
- /******/ l: false,
17
- /******/ exports: {}
18
- /******/ };
19
- /******/
20
- /******/ // Execute the module function
21
- /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
22
- /******/
23
- /******/ // Flag the module as loaded
24
- /******/ module.l = true;
25
- /******/
26
- /******/ // Return the exports of the module
27
- /******/ return module.exports;
28
- /******/ }
29
- /******/
30
- /******/
31
- /******/ // expose the modules object (__webpack_modules__)
32
- /******/ __webpack_require__.m = modules;
33
- /******/
34
- /******/ // expose the module cache
35
- /******/ __webpack_require__.c = installedModules;
36
- /******/
37
- /******/ // define getter function for harmony exports
38
- /******/ __webpack_require__.d = function(exports, name, getter) {
39
- /******/ if(!__webpack_require__.o(exports, name)) {
40
- /******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
41
- /******/ }
42
- /******/ };
43
- /******/
44
- /******/ // define __esModule on exports
45
- /******/ __webpack_require__.r = function(exports) {
46
- /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
47
- /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
48
- /******/ }
49
- /******/ Object.defineProperty(exports, '__esModule', { value: true });
50
- /******/ };
51
- /******/
52
- /******/ // create a fake namespace object
53
- /******/ // mode & 1: value is a module id, require it
54
- /******/ // mode & 2: merge all properties of value into the ns
55
- /******/ // mode & 4: return value when already ns object
56
- /******/ // mode & 8|1: behave like require
57
- /******/ __webpack_require__.t = function(value, mode) {
58
- /******/ if(mode & 1) value = __webpack_require__(value);
59
- /******/ if(mode & 8) return value;
60
- /******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
61
- /******/ var ns = Object.create(null);
62
- /******/ __webpack_require__.r(ns);
63
- /******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
64
- /******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
65
- /******/ return ns;
66
- /******/ };
67
- /******/
68
- /******/ // getDefaultExport function for compatibility with non-harmony modules
69
- /******/ __webpack_require__.n = function(module) {
70
- /******/ var getter = module && module.__esModule ?
71
- /******/ function getDefault() { return module['default']; } :
72
- /******/ function getModuleExports() { return module; };
73
- /******/ __webpack_require__.d(getter, 'a', getter);
74
- /******/ return getter;
75
- /******/ };
76
- /******/
77
- /******/ // Object.prototype.hasOwnProperty.call
78
- /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
79
- /******/
80
- /******/ // __webpack_public_path__
81
- /******/ __webpack_require__.p = "";
82
- /******/
83
- /******/
84
- /******/ // Load entry module and return exports
85
- /******/ return __webpack_require__(__webpack_require__.s = 56);
86
- /******/ })
87
- /************************************************************************/
88
- /******/ ([
89
- /* 0 */
90
- /***/ (function(module, exports) {
91
-
92
- module.exports = require("@babel/runtime-corejs2/core-js/object/keys");
93
-
94
- /***/ }),
95
- /* 1 */
96
- /***/ (function(module, exports) {
97
-
98
- module.exports = require("@babel/runtime-corejs2/core-js/array/is-array");
99
-
100
- /***/ }),
101
- /* 2 */
102
- /***/ (function(module, exports) {
103
-
104
- module.exports = require("@babel/runtime-corejs2/helpers/typeof");
105
-
106
- /***/ }),
107
- /* 3 */
108
- /***/ (function(module, exports) {
109
-
110
- module.exports = require("@babel/runtime-corejs2/core-js/object/assign");
111
-
112
- /***/ }),
113
- /* 4 */
114
- /***/ (function(module, exports) {
115
-
116
- module.exports = require("@babel/runtime-corejs2/regenerator");
117
-
118
- /***/ }),
119
- /* 5 */
120
- /***/ (function(module, exports) {
121
-
122
- module.exports = require("@babel/runtime-corejs2/core-js/object/get-own-property-descriptors");
123
-
124
- /***/ }),
125
- /* 6 */
126
- /***/ (function(module, exports) {
127
-
128
- module.exports = require("@babel/runtime-corejs2/core-js/object/get-own-property-descriptor");
129
-
130
- /***/ }),
131
- /* 7 */
132
- /***/ (function(module, exports) {
133
-
134
- module.exports = require("@babel/runtime-corejs2/core-js/object/get-own-property-symbols");
135
-
136
- /***/ }),
137
- /* 8 */
138
- /***/ (function(module, exports) {
139
-
140
- module.exports = require("@babel/runtime-corejs2/helpers/defineProperty");
141
-
142
- /***/ }),
143
- /* 9 */
144
- /***/ (function(module, exports) {
145
-
146
- module.exports = require("@babel/runtime-corejs2/core-js/object/define-property");
147
-
148
- /***/ }),
149
- /* 10 */
150
- /***/ (function(module, exports) {
151
-
152
- module.exports = require("@babel/runtime-corejs2/core-js/object/define-properties");
153
-
154
- /***/ }),
155
- /* 11 */
156
- /***/ (function(module, exports) {
157
-
158
- module.exports = require("url");
159
-
160
- /***/ }),
161
- /* 12 */
162
- /***/ (function(module, exports) {
163
-
164
- module.exports = require("@babel/runtime-corejs2/core-js/json/stringify");
165
-
166
- /***/ }),
167
- /* 13 */
168
- /***/ (function(module, exports) {
169
-
170
- module.exports = require("@babel/runtime-corejs2/helpers/toConsumableArray");
171
-
172
- /***/ }),
173
- /* 14 */
174
- /***/ (function(module, exports) {
175
-
176
- module.exports = require("@babel/runtime-corejs2/core-js/promise");
177
-
178
- /***/ }),
179
- /* 15 */
180
- /***/ (function(module, exports) {
181
-
182
- module.exports = require("lodash/assign");
183
-
184
- /***/ }),
185
- /* 16 */
186
- /***/ (function(module, exports) {
187
-
188
- module.exports = require("lodash/get");
189
-
190
- /***/ }),
191
- /* 17 */
192
- /***/ (function(module, exports) {
193
-
194
- module.exports = require("@babel/runtime-corejs2/helpers/slicedToArray");
195
-
196
- /***/ }),
197
- /* 18 */
198
- /***/ (function(module, exports) {
199
-
200
- module.exports = require("@babel/runtime-corejs2/core-js/array/from");
201
-
202
- /***/ }),
203
- /* 19 */
204
- /***/ (function(module, exports) {
205
-
206
- module.exports = require("lodash/isFunction");
207
-
208
- /***/ }),
209
- /* 20 */
210
- /***/ (function(module, exports) {
211
-
212
- module.exports = require("@babel/runtime-corejs2/core-js/get-iterator");
213
-
214
- /***/ }),
215
- /* 21 */
216
- /***/ (function(module, exports) {
217
-
218
- module.exports = require("@babel/runtime-corejs2/core-js/symbol/iterator");
219
-
220
- /***/ }),
221
- /* 22 */
222
- /***/ (function(module, exports) {
223
-
224
- module.exports = require("@babel/runtime-corejs2/core-js/symbol");
225
-
226
- /***/ }),
227
- /* 23 */
228
- /***/ (function(module, exports) {
229
-
230
- module.exports = require("@babel/runtime-corejs2/helpers/asyncToGenerator");
231
-
232
- /***/ }),
233
- /* 24 */
234
- /***/ (function(module, exports) {
235
-
236
- module.exports = require("lodash/pick");
237
-
238
- /***/ }),
239
- /* 25 */
240
- /***/ (function(module, exports) {
241
-
242
- module.exports = require("@babel/runtime-corejs2/helpers/classCallCheck");
243
-
244
- /***/ }),
245
- /* 26 */
246
- /***/ (function(module, exports) {
247
-
248
- module.exports = require("@babel/runtime-corejs2/helpers/createClass");
249
-
250
- /***/ }),
251
- /* 27 */
252
- /***/ (function(module, exports) {
253
-
254
- module.exports = require("fast-json-patch");
255
-
256
- /***/ }),
257
- /* 28 */
258
- /***/ (function(module, exports) {
259
-
260
- module.exports = require("btoa");
261
-
262
- /***/ }),
263
- /* 29 */
264
- /***/ (function(module, exports) {
265
-
266
- module.exports = require("lodash/startsWith");
267
-
268
- /***/ }),
269
- /* 30 */
270
- /***/ (function(module, exports) {
271
-
272
- module.exports = require("@babel/runtime-corejs2/core-js/reflect/construct");
273
-
274
- /***/ }),
275
- /* 31 */
276
- /***/ (function(module, exports) {
277
-
278
- module.exports = require("js-yaml");
279
-
280
- /***/ }),
281
- /* 32 */
282
- /***/ (function(module, exports) {
283
-
284
- module.exports = require("qs");
285
-
286
- /***/ }),
287
- /* 33 */
288
- /***/ (function(module, exports) {
289
-
290
- module.exports = require("@babel/runtime-corejs2/helpers/getPrototypeOf");
291
-
292
- /***/ }),
293
- /* 34 */
294
- /***/ (function(module, exports) {
295
-
296
- module.exports = require("buffer");
297
-
298
- /***/ }),
299
- /* 35 */
300
- /***/ (function(module, exports) {
301
-
302
- module.exports = require("@babel/runtime-corejs2/core-js/object/create");
303
-
304
- /***/ }),
305
- /* 36 */
306
- /***/ (function(module, exports) {
307
-
308
- module.exports = require("lodash/noop");
309
-
310
- /***/ }),
311
- /* 37 */
312
- /***/ (function(module, exports) {
313
-
314
- module.exports = require("querystring-browser");
315
-
316
- /***/ }),
317
- /* 38 */
318
- /***/ (function(module, exports) {
319
-
320
- module.exports = require("lodash/isObject");
321
-
322
- /***/ }),
323
- /* 39 */
324
- /***/ (function(module, exports) {
325
-
326
- module.exports = require("@babel/runtime-corejs2/core-js/object/entries");
327
-
328
- /***/ }),
329
- /* 40 */
330
- /***/ (function(module, exports) {
331
-
332
- module.exports = require("@babel/runtime-corejs2/helpers/get");
333
-
334
- /***/ }),
335
- /* 41 */
336
- /***/ (function(module, exports) {
337
-
338
- module.exports = require("@babel/runtime-corejs2/helpers/inherits");
339
-
340
- /***/ }),
341
- /* 42 */
342
- /***/ (function(module, exports) {
343
-
344
- module.exports = require("@babel/runtime-corejs2/helpers/possibleConstructorReturn");
345
-
346
- /***/ }),
347
- /* 43 */
348
- /***/ (function(module, exports) {
349
-
350
- module.exports = require("isomorphic-form-data");
351
-
352
- /***/ }),
353
- /* 44 */
354
- /***/ (function(module, exports) {
355
-
356
- module.exports = require("utf8-bytes");
357
-
358
- /***/ }),
359
- /* 45 */
360
- /***/ (function(module, exports) {
361
-
362
- module.exports = require("utfstring");
363
-
364
- /***/ }),
365
- /* 46 */
366
- /***/ (function(module, exports) {
367
-
368
- module.exports = require("lodash/find");
369
-
370
- /***/ }),
371
- /* 47 */
372
- /***/ (function(module, exports) {
373
-
374
- module.exports = require("deep-extend");
375
-
376
- /***/ }),
377
- /* 48 */
378
- /***/ (function(module, exports) {
379
-
380
- module.exports = require("@kyleshockey/object-assign-deep");
381
-
382
- /***/ }),
383
- /* 49 */
384
- /***/ (function(module, exports) {
385
-
386
- module.exports = require("@babel/runtime-corejs2/core-js/weak-map");
387
-
388
- /***/ }),
389
- /* 50 */
390
- /***/ (function(module, exports) {
391
-
392
- module.exports = require("cross-fetch");
393
-
394
- /***/ }),
395
- /* 51 */
396
- /***/ (function(module, exports) {
397
-
398
- module.exports = require("traverse");
399
-
400
- /***/ }),
401
- /* 52 */
402
- /***/ (function(module, exports) {
403
-
404
- module.exports = require("@babel/runtime-corejs2/helpers/objectWithoutProperties");
405
-
406
- /***/ }),
407
- /* 53 */
408
- /***/ (function(module, exports) {
409
-
410
- module.exports = require("lodash/isPlainObject");
411
-
412
- /***/ }),
413
- /* 54 */
414
- /***/ (function(module, exports) {
415
-
416
- module.exports = require("lodash/isArray");
417
-
418
- /***/ }),
419
- /* 55 */
420
- /***/ (function(module, exports) {
421
-
422
- module.exports = require("cookie");
423
-
424
- /***/ }),
425
- /* 56 */
426
- /***/ (function(module, exports, __webpack_require__) {
427
-
428
- module.exports = __webpack_require__(59);
429
-
430
-
431
- /***/ }),
432
- /* 57 */
433
- /***/ (function(module, exports) {
434
-
435
- module.exports = require("cross-fetch/polyfill");
436
-
437
- /***/ }),
438
- /* 58 */
439
- /***/ (function(module, exports) {
440
-
441
- module.exports = require("encode-3986");
442
-
443
- /***/ }),
444
- /* 59 */
445
- /***/ (function(module, __webpack_exports__, __webpack_require__) {
446
-
447
- "use strict";
448
- // ESM COMPAT FLAG
449
- __webpack_require__.r(__webpack_exports__);
450
-
451
- // NAMESPACE OBJECT: ./src/execute/oas3/parameter-builders.js
452
- var oas3_parameter_builders_namespaceObject = {};
453
- __webpack_require__.r(oas3_parameter_builders_namespaceObject);
454
- __webpack_require__.d(oas3_parameter_builders_namespaceObject, "path", function() { return parameter_builders_path; });
455
- __webpack_require__.d(oas3_parameter_builders_namespaceObject, "query", function() { return parameter_builders_query; });
456
- __webpack_require__.d(oas3_parameter_builders_namespaceObject, "header", function() { return parameter_builders_header; });
457
- __webpack_require__.d(oas3_parameter_builders_namespaceObject, "cookie", function() { return cookie; });
458
-
459
- // EXTERNAL MODULE: external "@babel/runtime-corejs2/core-js/object/define-property"
460
- var define_property_ = __webpack_require__(9);
461
- var define_property_default = /*#__PURE__*/__webpack_require__.n(define_property_);
462
-
463
- // EXTERNAL MODULE: external "@babel/runtime-corejs2/core-js/object/define-properties"
464
- var define_properties_ = __webpack_require__(10);
465
- var define_properties_default = /*#__PURE__*/__webpack_require__.n(define_properties_);
466
-
467
- // EXTERNAL MODULE: external "@babel/runtime-corejs2/core-js/object/get-own-property-descriptors"
468
- var get_own_property_descriptors_ = __webpack_require__(5);
469
- var get_own_property_descriptors_default = /*#__PURE__*/__webpack_require__.n(get_own_property_descriptors_);
470
-
471
- // EXTERNAL MODULE: external "@babel/runtime-corejs2/core-js/object/get-own-property-descriptor"
472
- var get_own_property_descriptor_ = __webpack_require__(6);
473
- var get_own_property_descriptor_default = /*#__PURE__*/__webpack_require__.n(get_own_property_descriptor_);
474
-
475
- // EXTERNAL MODULE: external "@babel/runtime-corejs2/core-js/object/get-own-property-symbols"
476
- var get_own_property_symbols_ = __webpack_require__(7);
477
- var get_own_property_symbols_default = /*#__PURE__*/__webpack_require__.n(get_own_property_symbols_);
478
-
479
- // EXTERNAL MODULE: external "@babel/runtime-corejs2/core-js/object/keys"
480
- var keys_ = __webpack_require__(0);
481
- var keys_default = /*#__PURE__*/__webpack_require__.n(keys_);
482
-
483
- // EXTERNAL MODULE: external "@babel/runtime-corejs2/helpers/defineProperty"
484
- var defineProperty_ = __webpack_require__(8);
485
- var defineProperty_default = /*#__PURE__*/__webpack_require__.n(defineProperty_);
486
-
487
- // EXTERNAL MODULE: external "lodash/assign"
488
- var assign_ = __webpack_require__(15);
489
- var assign_default = /*#__PURE__*/__webpack_require__.n(assign_);
490
-
491
- // EXTERNAL MODULE: external "lodash/startsWith"
492
- var startsWith_ = __webpack_require__(29);
493
- var startsWith_default = /*#__PURE__*/__webpack_require__.n(startsWith_);
494
-
495
- // EXTERNAL MODULE: external "url"
496
- var external_url_ = __webpack_require__(11);
497
- var external_url_default = /*#__PURE__*/__webpack_require__.n(external_url_);
498
-
499
- // EXTERNAL MODULE: external "@babel/runtime-corejs2/core-js/get-iterator"
500
- var get_iterator_ = __webpack_require__(20);
501
- var get_iterator_default = /*#__PURE__*/__webpack_require__.n(get_iterator_);
502
-
503
- // EXTERNAL MODULE: external "@babel/runtime-corejs2/core-js/symbol/iterator"
504
- var iterator_ = __webpack_require__(21);
505
- var iterator_default = /*#__PURE__*/__webpack_require__.n(iterator_);
506
-
507
- // EXTERNAL MODULE: external "@babel/runtime-corejs2/core-js/symbol"
508
- var symbol_ = __webpack_require__(22);
509
- var symbol_default = /*#__PURE__*/__webpack_require__.n(symbol_);
510
-
511
- // EXTERNAL MODULE: external "@babel/runtime-corejs2/regenerator"
512
- var regenerator_ = __webpack_require__(4);
513
- var regenerator_default = /*#__PURE__*/__webpack_require__.n(regenerator_);
514
-
515
- // EXTERNAL MODULE: external "@babel/runtime-corejs2/core-js/object/entries"
516
- var entries_ = __webpack_require__(39);
517
- var entries_default = /*#__PURE__*/__webpack_require__.n(entries_);
518
-
519
- // EXTERNAL MODULE: external "@babel/runtime-corejs2/core-js/json/stringify"
520
- var stringify_ = __webpack_require__(12);
521
- var stringify_default = /*#__PURE__*/__webpack_require__.n(stringify_);
522
-
523
- // EXTERNAL MODULE: external "@babel/runtime-corejs2/core-js/array/is-array"
524
- var is_array_ = __webpack_require__(1);
525
- var is_array_default = /*#__PURE__*/__webpack_require__.n(is_array_);
526
-
527
- // EXTERNAL MODULE: external "@babel/runtime-corejs2/helpers/typeof"
528
- var typeof_ = __webpack_require__(2);
529
- var typeof_default = /*#__PURE__*/__webpack_require__.n(typeof_);
530
-
531
- // EXTERNAL MODULE: external "@babel/runtime-corejs2/helpers/slicedToArray"
532
- var slicedToArray_ = __webpack_require__(17);
533
- var slicedToArray_default = /*#__PURE__*/__webpack_require__.n(slicedToArray_);
534
-
535
- // EXTERNAL MODULE: external "@babel/runtime-corejs2/core-js/array/from"
536
- var from_ = __webpack_require__(18);
537
- var from_default = /*#__PURE__*/__webpack_require__.n(from_);
538
-
539
- // EXTERNAL MODULE: external "@babel/runtime-corejs2/helpers/asyncToGenerator"
540
- var asyncToGenerator_ = __webpack_require__(23);
541
- var asyncToGenerator_default = /*#__PURE__*/__webpack_require__.n(asyncToGenerator_);
542
-
543
- // EXTERNAL MODULE: external "cross-fetch/polyfill"
544
- var polyfill_ = __webpack_require__(57);
545
-
546
- // EXTERNAL MODULE: external "qs"
547
- var external_qs_ = __webpack_require__(32);
548
- var external_qs_default = /*#__PURE__*/__webpack_require__.n(external_qs_);
549
-
550
- // EXTERNAL MODULE: external "js-yaml"
551
- var external_js_yaml_ = __webpack_require__(31);
552
- var external_js_yaml_default = /*#__PURE__*/__webpack_require__.n(external_js_yaml_);
553
-
554
- // EXTERNAL MODULE: external "lodash/pick"
555
- var pick_ = __webpack_require__(24);
556
- var pick_default = /*#__PURE__*/__webpack_require__.n(pick_);
557
-
558
- // EXTERNAL MODULE: external "lodash/isFunction"
559
- var isFunction_ = __webpack_require__(19);
560
- var isFunction_default = /*#__PURE__*/__webpack_require__.n(isFunction_);
561
-
562
- // EXTERNAL MODULE: external "buffer"
563
- var external_buffer_ = __webpack_require__(34);
564
-
565
- // EXTERNAL MODULE: external "@babel/runtime-corejs2/core-js/reflect/construct"
566
- var construct_ = __webpack_require__(30);
567
- var construct_default = /*#__PURE__*/__webpack_require__.n(construct_);
568
-
569
- // EXTERNAL MODULE: external "@babel/runtime-corejs2/helpers/classCallCheck"
570
- var classCallCheck_ = __webpack_require__(25);
571
- var classCallCheck_default = /*#__PURE__*/__webpack_require__.n(classCallCheck_);
572
-
573
- // EXTERNAL MODULE: external "@babel/runtime-corejs2/helpers/createClass"
574
- var createClass_ = __webpack_require__(26);
575
- var createClass_default = /*#__PURE__*/__webpack_require__.n(createClass_);
576
-
577
- // EXTERNAL MODULE: external "@babel/runtime-corejs2/helpers/get"
578
- var get_ = __webpack_require__(40);
579
- var get_default = /*#__PURE__*/__webpack_require__.n(get_);
580
-
581
- // EXTERNAL MODULE: external "@babel/runtime-corejs2/helpers/inherits"
582
- var inherits_ = __webpack_require__(41);
583
- var inherits_default = /*#__PURE__*/__webpack_require__.n(inherits_);
584
-
585
- // EXTERNAL MODULE: external "@babel/runtime-corejs2/helpers/possibleConstructorReturn"
586
- var possibleConstructorReturn_ = __webpack_require__(42);
587
- var possibleConstructorReturn_default = /*#__PURE__*/__webpack_require__.n(possibleConstructorReturn_);
588
-
589
- // EXTERNAL MODULE: external "@babel/runtime-corejs2/helpers/getPrototypeOf"
590
- var getPrototypeOf_ = __webpack_require__(33);
591
- var getPrototypeOf_default = /*#__PURE__*/__webpack_require__.n(getPrototypeOf_);
592
-
593
- // EXTERNAL MODULE: external "isomorphic-form-data"
594
- var external_isomorphic_form_data_ = __webpack_require__(43);
595
- var external_isomorphic_form_data_default = /*#__PURE__*/__webpack_require__.n(external_isomorphic_form_data_);
596
-
597
- // CONCATENATED MODULE: ./src/internal/form-data-monkey-patch.js
598
- function _createSuper(Derived) {var hasNativeReflectConstruct = _isNativeReflectConstruct();return function _createSuperInternal() {var Super = getPrototypeOf_default()(Derived),result;if (hasNativeReflectConstruct) {var NewTarget = getPrototypeOf_default()(this).constructor;result = construct_default()(Super, arguments, NewTarget);} else {result = Super.apply(this, arguments);}return possibleConstructorReturn_default()(this, result);};}function _isNativeReflectConstruct() {if (typeof Reflect === "undefined" || !construct_default.a) return false;if (construct_default.a.sham) return false;if (typeof Proxy === "function") return true;try {Date.prototype.toString.call(construct_default()(Date, [], function () {}));return true;} catch (e) {return false;}}
599
-
600
-
601
- // patches FormData type by mutating it.
602
- // patch :: FormData -> PatchedFormData
603
- var form_data_monkey_patch_patch = function patch(FormData) {
604
- var createEntry = function createEntry(field, value) {return { name: field, value: value };};
605
- /** We return original type if prototype already contains one of methods we're trying to patch.
606
- * Reasoning: if one of the methods already exists, it would access data in other
607
- * property than our `_entryList`. That could potentially create nasty
608
- * hardly detectable bugs if `form-data` library implements only couple of
609
- * methods that it misses, instead of implementing all of them.
610
- * Current solution will fail the tests to let us know that form-data library
611
- * already implements some of the methods that we try to monkey-patch, and our
612
- * monkey-patch code should then compensate the library changes easily.
613
- */
614
- if (
615
- isFunction_default()(FormData.prototype.set) ||
616
- isFunction_default()(FormData.prototype.get) ||
617
- isFunction_default()(FormData.prototype.getAll) ||
618
- isFunction_default()(FormData.prototype.has))
619
- {
620
- return FormData;
621
- }var
622
- PatchedFormData = /*#__PURE__*/function (_FormData) {inherits_default()(PatchedFormData, _FormData);var _super = _createSuper(PatchedFormData);
623
- function PatchedFormData(form) {var _this;classCallCheck_default()(this, PatchedFormData);
624
- _this = _super.call(this, form);
625
- _this._entryList = [];return _this;
626
- }createClass_default()(PatchedFormData, [{ key: "append", value: function append(
627
-
628
- field, value, options) {
629
- this._entryList.push(createEntry(field, value));
630
- return get_default()(getPrototypeOf_default()(PatchedFormData.prototype), "append", this).call(this, field, value, options);
631
- } }, { key: "set", value: function set(
632
-
633
- field, value) {
634
- var newEntry = createEntry(field, value);
635
-
636
- this._entryList = this._entryList.filter(function (entry) {
637
- return entry.name !== field;
638
- });
639
-
640
- this._entryList.push(newEntry);
641
- } }, { key: "get", value: function get(
642
-
643
- field) {
644
- var foundEntry = this._entryList.find(function (entry) {
645
- return entry.name === field;
646
- });
647
-
648
- return foundEntry === undefined ? null : foundEntry;
649
- } }, { key: "getAll", value: function getAll(
650
-
651
- field) {
652
- return this._entryList.
653
- filter(function (entry) {
654
- return entry.name === field;
655
- }).
656
- map(function (entry) {
657
- return entry.value;
658
- });
659
- } }, { key: "has", value: function has(
660
-
661
- field) {
662
- return this._entryList.some(function (entry) {
663
- return entry.name === field;
664
- });
665
- } }]);return PatchedFormData;}(FormData);
666
-
667
-
668
- return PatchedFormData;
669
- };
670
-
671
- /* harmony default export */ var form_data_monkey_patch = (form_data_monkey_patch_patch(external_isomorphic_form_data_default.a));
672
- // EXTERNAL MODULE: external "encode-3986"
673
- var external_encode_3986_ = __webpack_require__(58);
674
-
675
- // EXTERNAL MODULE: external "utf8-bytes"
676
- var external_utf8_bytes_ = __webpack_require__(44);
677
- var external_utf8_bytes_default = /*#__PURE__*/__webpack_require__.n(external_utf8_bytes_);
678
-
679
- // EXTERNAL MODULE: external "utfstring"
680
- var external_utfstring_ = __webpack_require__(45);
681
-
682
- // CONCATENATED MODULE: ./src/execute/oas3/style-serializer.js
683
-
684
-
685
-
686
-
687
- var isRfc3986Reserved = function isRfc3986Reserved(char) {return ':/?#[]@!$&\'()*+,;='.indexOf(char) > -1;};
688
- var isRrc3986Unreserved = function isRrc3986Unreserved(char) {
689
- return /^[a-z0-9\-._~]+$/i.test(char);
690
- };
691
-
692
- function encodeDisallowedCharacters(str) {var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},escape = _ref.escape;var parse = arguments.length > 2 ? arguments[2] : undefined;
693
- if (typeof str === 'number') {
694
- str = str.toString();
695
- }
696
- if (typeof str !== 'string' || !str.length) {
697
- return str;
698
- }
699
-
700
- if (!escape) {
701
- return str;
702
- }
703
-
704
- if (parse) {
705
- return JSON.parse(str);
706
- }
707
-
708
- return Object(external_utfstring_["stringToCharArray"])(str).map(function (char) {
709
- if (isRrc3986Unreserved(char)) {
710
- return char;
711
- }
712
-
713
- if (isRfc3986Reserved(char) && escape === 'unsafe') {
714
- return char;
715
- }
716
-
717
- var encoded = (external_utf8_bytes_default()(char) || []).
718
- map(function (byte) {return "0".concat(byte.toString(16).toUpperCase()).slice(-2);}).
719
- map(function (encodedByte) {return "%".concat(encodedByte);}).
720
- join('');
721
-
722
- return encoded;
723
- }).join('');
724
- }
725
-
726
- function stylize(config) {var
727
- value = config.value;
728
-
729
- if (is_array_default()(value)) {
730
- return encodeArray(config);
731
- } else
732
- if (typeof_default()(value) === 'object') {
733
- return encodeObject(config);
734
- }
735
- return encodePrimitive(config);
736
- }
737
-
738
- function encodeArray(_ref2) {var key = _ref2.key,value = _ref2.value,style = _ref2.style,explode = _ref2.explode,escape = _ref2.escape;
739
- var valueEncoder = function valueEncoder(str) {return encodeDisallowedCharacters(str, {
740
- escape: escape });};
741
-
742
-
743
- if (style === 'simple') {
744
- return value.map(function (val) {return valueEncoder(val);}).join(',');
745
- }
746
-
747
- if (style === 'label') {
748
- return ".".concat(value.map(function (val) {return valueEncoder(val);}).join('.'));
749
- }
750
-
751
- if (style === 'matrix') {
752
- return value.map(function (val) {return valueEncoder(val);}).reduce(function (prev, curr) {
753
- if (!prev || explode) {
754
- return "".concat(prev || '', ";").concat(key, "=").concat(curr);
755
- }
756
- return "".concat(prev, ",").concat(curr);
757
- }, '');
758
- }
759
-
760
- if (style === 'form') {
761
- var after = explode ? "&".concat(key, "=") : ',';
762
- return value.map(function (val) {return valueEncoder(val);}).join(after);
763
- }
764
-
765
- if (style === 'spaceDelimited') {
766
- var _after = explode ? "".concat(key, "=") : '';
767
- return value.map(function (val) {return valueEncoder(val);}).join(" ".concat(_after));
768
- }
769
-
770
- if (style === 'pipeDelimited') {
771
- var _after2 = explode ? "".concat(key, "=") : '';
772
- return value.map(function (val) {return valueEncoder(val);}).join("|".concat(_after2));
773
- }
774
- }
775
-
776
- function encodeObject(_ref3) {var key = _ref3.key,value = _ref3.value,style = _ref3.style,explode = _ref3.explode,escape = _ref3.escape;
777
- var valueEncoder = function valueEncoder(str) {return encodeDisallowedCharacters(str, {
778
- escape: escape });};
779
-
780
-
781
- var valueKeys = keys_default()(value);
782
-
783
- if (style === 'simple') {
784
- return valueKeys.reduce(function (prev, curr) {
785
- var val = valueEncoder(value[curr]);
786
- var middleChar = explode ? '=' : ',';
787
- var prefix = prev ? "".concat(prev, ",") : '';
788
-
789
- return "".concat(prefix).concat(curr).concat(middleChar).concat(val);
790
- }, '');
791
- }
792
-
793
- if (style === 'label') {
794
- return valueKeys.reduce(function (prev, curr) {
795
- var val = valueEncoder(value[curr]);
796
- var middleChar = explode ? '=' : '.';
797
- var prefix = prev ? "".concat(prev, ".") : '.';
798
-
799
- return "".concat(prefix).concat(curr).concat(middleChar).concat(val);
800
- }, '');
801
- }
802
-
803
- if (style === 'matrix' && explode) {
804
- return valueKeys.reduce(function (prev, curr) {
805
- var val = valueEncoder(value[curr]);
806
- var prefix = prev ? "".concat(prev, ";") : ';';
807
-
808
- return "".concat(prefix).concat(curr, "=").concat(val);
809
- }, '');
810
- }
811
-
812
- if (style === 'matrix') {
813
- // no explode
814
- return valueKeys.reduce(function (prev, curr) {
815
- var val = valueEncoder(value[curr]);
816
- var prefix = prev ? "".concat(prev, ",") : ";".concat(key, "=");
817
-
818
- return "".concat(prefix).concat(curr, ",").concat(val);
819
- }, '');
820
- }
821
-
822
- if (style === 'form') {
823
- return valueKeys.reduce(function (prev, curr) {
824
- var val = valueEncoder(value[curr]);
825
- var prefix = prev ? "".concat(prev).concat(explode ? '&' : ',') : '';
826
- var separator = explode ? '=' : ',';
827
-
828
- return "".concat(prefix).concat(curr).concat(separator).concat(val);
829
- }, '');
830
- }
831
- }
832
-
833
- function encodePrimitive(_ref4) {var key = _ref4.key,value = _ref4.value,style = _ref4.style,escape = _ref4.escape;
834
- var valueEncoder = function valueEncoder(str) {return encodeDisallowedCharacters(str, {
835
- escape: escape });};
836
-
837
-
838
- if (style === 'simple') {
839
- return valueEncoder(value);
840
- }
841
-
842
- if (style === 'label') {
843
- return ".".concat(valueEncoder(value));
844
- }
845
-
846
- if (style === 'matrix') {
847
- return ";".concat(key, "=").concat(valueEncoder(value));
848
- }
849
-
850
- if (style === 'form') {
851
- return valueEncoder(value);
852
- }
853
-
854
- if (style === 'deepObject') {
855
- return valueEncoder(value, {}, true);
856
- }
857
- }
858
- // CONCATENATED MODULE: ./src/http.js
859
- function _createForOfIteratorHelper(o, allowArrayLike) {var it;if (typeof symbol_default.a === "undefined" || o[iterator_default.a] == null) {if (is_array_default()(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") {if (it) o = it;var i = 0;var F = function F() {};return { s: F, n: function n() {if (i >= o.length) return { done: true };return { done: false, value: o[i++] };}, e: function e(_e) {throw _e;}, f: F };}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");}var normalCompletion = true,didErr = false,err;return { s: function s() {it = get_iterator_default()(o);}, n: function n() {var step = it.next();normalCompletion = step.done;return step;}, e: function e(_e2) {didErr = true;err = _e2;}, f: function f() {try {if (!normalCompletion && it.return != null) it.return();} finally {if (didErr) throw err;}} };}function _unsupportedIterableToArray(o, minLen) {if (!o) return;if (typeof o === "string") return _arrayLikeToArray(o, minLen);var n = Object.prototype.toString.call(o).slice(8, -1);if (n === "Object" && o.constructor) n = o.constructor.name;if (n === "Map" || n === "Set") return from_default()(o);if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);}function _arrayLikeToArray(arr, len) {if (len == null || len > arr.length) len = arr.length;for (var i = 0, arr2 = new Array(len); i < len; i++) {arr2[i] = arr[i];}return arr2;} /* global fetch */
860
-
861
-
862
-
863
-
864
-
865
-
866
-
867
-
868
-
869
- // For testing
870
- var http_self = {
871
- serializeRes: serializeRes,
872
- mergeInQueryOrForm: mergeInQueryOrForm };
873
-
874
-
875
- // Handles fetch-like syntax and the case where there is only one object passed-in
876
- // (which will have the URL as a property). Also serilizes the response.
877
- function http_http(_x) {return _http.apply(this, arguments);}
878
-
879
-
880
-
881
-
882
-
883
-
884
-
885
-
886
-
887
-
888
-
889
-
890
-
891
-
892
-
893
-
894
-
895
-
896
-
897
-
898
-
899
-
900
-
901
-
902
-
903
-
904
-
905
-
906
-
907
-
908
-
909
-
910
-
911
-
912
-
913
-
914
-
915
-
916
-
917
-
918
-
919
-
920
-
921
-
922
-
923
-
924
-
925
-
926
-
927
-
928
-
929
-
930
-
931
-
932
-
933
-
934
-
935
-
936
-
937
-
938
-
939
-
940
-
941
-
942
-
943
-
944
-
945
-
946
-
947
- // exported for testing
948
- function _http() {_http = asyncToGenerator_default()( /*#__PURE__*/regenerator_default.a.mark(function _callee(url) {var request,contentType,res,error,_error,_args = arguments;return regenerator_default.a.wrap(function _callee$(_context) {while (1) {switch (_context.prev = _context.next) {case 0:request = _args.length > 1 && _args[1] !== undefined ? _args[1] : {};if (typeof_default()(url) === 'object') {request = url;url = request.url;}request.headers = request.headers || {}; // Serializes query, for convenience
949
- // Should be the last thing we do, as its hard to mutate the URL with
950
- // the search string, but much easier to manipulate the req.query object
951
- http_self.mergeInQueryOrForm(request); // Newlines in header values cause weird error messages from `window.fetch`,
952
- // so let's massage them out.
953
- // Context: https://stackoverflow.com/a/50709178
954
- if (request.headers) {keys_default()(request.headers).forEach(function (headerName) {var value = request.headers[headerName];if (typeof value === 'string') {request.headers[headerName] = value.replace(/\n+/g, ' ');}});} // Wait for the request interceptor, if it was provided
955
- // WARNING: don't put anything between this and the request firing unless
956
- // you have a good reason!
957
- if (!request.requestInterceptor) {_context.next = 12;break;}_context.next = 8;return request.requestInterceptor(request);case 8:_context.t0 = _context.sent;if (_context.t0) {_context.next = 11;break;}_context.t0 = request;case 11:request = _context.t0;case 12: // for content-type=multipart\/form-data remove content-type from request before fetch
958
- // so that correct one with `boundary` is set
959
- contentType = request.headers['content-type'] || request.headers['Content-Type'];if (/multipart\/form-data/i.test(contentType)) {delete request.headers['content-type'];delete request.headers['Content-Type'];} // eslint-disable-next-line no-undef
960
- _context.prev = 14;_context.next = 17;return (request.userFetch || fetch)(request.url, request);case 17:res = _context.sent;_context.next = 20;return http_self.serializeRes(res, url, request);case 20:res = _context.sent;if (!request.responseInterceptor) {_context.next = 28;break;}_context.next = 24;return request.responseInterceptor(res);case 24:_context.t1 = _context.sent;if (_context.t1) {_context.next = 27;break;}_context.t1 = res;case 27:res = _context.t1;case 28:_context.next = 38;break;case 30:_context.prev = 30;_context.t2 = _context["catch"](14);if (res) {_context.next = 34;break;}throw _context.t2;case 34:error = new Error(res.statusText);error.statusCode = error.status = res.status;error.responseError = _context.t2;throw error;case 38:if (res.ok) {_context.next = 43;break;}_error = new Error(res.statusText);_error.statusCode = _error.status = res.status;_error.response = res;throw _error;case 43:return _context.abrupt("return", res);case 44:case "end":return _context.stop();}}}, _callee, null, [[14, 30]]);}));return _http.apply(this, arguments);}var shouldDownloadAsText = function shouldDownloadAsText() {var contentType = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';return /(json|xml|yaml|text)\b/.test(contentType);};function parseBody(body, contentType) {if (contentType && (contentType.indexOf('application/json') === 0 || contentType.indexOf('+json') > 0)) {return JSON.parse(body);}return external_js_yaml_default.a.safeLoad(body);} // Serialize the response, returns a promise with headers and the body part of the hash
961
- function serializeRes(oriRes, url) {var _ref = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {},_ref$loadSpec = _ref.loadSpec,loadSpec = _ref$loadSpec === void 0 ? false : _ref$loadSpec;var res = { ok: oriRes.ok, url: oriRes.url || url,
962
- status: oriRes.status,
963
- statusText: oriRes.statusText,
964
- headers: serializeHeaders(oriRes.headers) };
965
-
966
- var contentType = res.headers['content-type'];
967
- var useText = loadSpec || shouldDownloadAsText(contentType);
968
- var getBody = useText ? oriRes.text : oriRes.blob || oriRes.buffer;
969
- return getBody.call(oriRes).then(function (body) {
970
- res.text = body;
971
- res.data = body;
972
- if (useText) {
973
- try {
974
- var obj = parseBody(body, contentType);
975
- res.body = obj;
976
- res.obj = obj;
977
- }
978
- catch (e) {
979
- res.parseError = e;
980
- }
981
- }
982
- return res;
983
- });
984
- }
985
-
986
- function serializeHeaderValue(value) {
987
- var isMulti = value.includes(', ');
988
-
989
- return isMulti ? value.split(', ') : value;
990
- }
991
-
992
- // Serialize headers into a hash, where mutliple-headers result in an array.
993
- //
994
- // eg: Cookie: one
995
- // Cookie: two
996
- // = { Cookie: [ "one", "two" ]
997
- function serializeHeaders() {var headers = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
998
- if (!isFunction_default()(headers.entries)) return {};
999
-
1000
- return from_default()(
1001
- headers.entries()).
1002
- reduce(function (acc, _ref2) {var _ref3 = slicedToArray_default()(_ref2, 2),header = _ref3[0],value = _ref3[1];
1003
- acc[header] = serializeHeaderValue(value);
1004
- return acc;
1005
- }, {});
1006
- }
1007
-
1008
- function isFile(obj, navigatorObj) {
1009
- if (!navigatorObj && typeof navigator !== 'undefined') {
1010
- // eslint-disable-next-line no-undef
1011
- navigatorObj = navigator;
1012
- }
1013
- if (navigatorObj && navigatorObj.product === 'ReactNative') {
1014
- if (obj && typeof_default()(obj) === 'object' && typeof obj.uri === 'string') {
1015
- return true;
1016
- }
1017
- return false;
1018
- }
1019
-
1020
- if (typeof File !== 'undefined' && obj instanceof File) {// eslint-disable-line no-undef
1021
- return true;
1022
- }
1023
- if (typeof Blob !== 'undefined' && obj instanceof Blob) {// eslint-disable-line no-undef
1024
- return true;
1025
- }
1026
- if (typeof external_buffer_["Buffer"] !== 'undefined' && obj instanceof external_buffer_["Buffer"]) {
1027
- return true;
1028
- }
1029
-
1030
- return obj !== null && typeof_default()(obj) === 'object' && typeof obj.pipe === 'function';
1031
- }
1032
-
1033
- function isArrayOfFile(obj, navigatorObj) {
1034
- return is_array_default()(obj) && obj.some(function (v) {return isFile(v, navigatorObj);});
1035
- }
1036
-
1037
- var STYLE_SEPARATORS = {
1038
- form: ',',
1039
- spaceDelimited: '%20',
1040
- pipeDelimited: '|' };
1041
-
1042
-
1043
- var SEPARATORS = {
1044
- csv: ',',
1045
- ssv: '%20',
1046
- tsv: '%09',
1047
- pipes: '|' };
1048
-
1049
-
1050
- // Formats a key-value and returns an array of key-value pairs.
1051
- //
1052
- // Return value example 1: [['color', 'blue']]
1053
- // Return value example 2: [['color', 'blue,black,brown']]
1054
- // Return value example 3: [['color', ['blue', 'black', 'brown']]]
1055
- // Return value example 4: [['color', 'R,100,G,200,B,150']]
1056
- // Return value example 5: [['R', '100'], ['G', '200'], ['B', '150']]
1057
- // Return value example 6: [['color[R]', '100'], ['color[G]', '200'], ['color[B]', '150']]
1058
- function formatKeyValue(key, input) {var skipEncoding = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;var
1059
- collectionFormat = input.collectionFormat,allowEmptyValue = input.allowEmptyValue,serializationOption = input.serializationOption,encoding = input.encoding;
1060
- // `input` can be string
1061
- var value = typeof_default()(input) === 'object' && !is_array_default()(input) ? input.value : input;
1062
- var encodeFn = skipEncoding ? function (k) {return k.toString();} : function (k) {return encodeURIComponent(k);};
1063
- var encodedKey = encodeFn(key);
1064
-
1065
- if (typeof value === 'undefined' && allowEmptyValue) {
1066
- return [[encodedKey, '']];
1067
- }
1068
-
1069
- // file
1070
- if (isFile(value) || isArrayOfFile(value)) {
1071
- return [[encodedKey, value]];
1072
- }
1073
-
1074
- // for OAS 3 Parameter Object for serialization
1075
- if (serializationOption) {
1076
- return formatKeyValueBySerializationOption(key, value, skipEncoding, serializationOption);
1077
- }
1078
-
1079
- // for OAS 3 Encoding Object
1080
- if (encoding) {
1081
- if ([typeof_default()(encoding.style), typeof_default()(encoding.explode), typeof_default()(encoding.allowReserved)].some(function (type) {return type !== 'undefined';})) {
1082
- return formatKeyValueBySerializationOption(key, value, skipEncoding, pick_default()(encoding, ['style', 'explode', 'allowReserved']));
1083
- }
1084
-
1085
- if (encoding.contentType) {
1086
- if (encoding.contentType === 'application/json') {
1087
- // If value is a string, assume value is already a JSON string
1088
- var json = typeof value === 'string' ? value : stringify_default()(value);
1089
- return [[encodedKey, encodeFn(json)]];
1090
- }
1091
- return [[encodedKey, encodeFn(value.toString())]];
1092
- }
1093
-
1094
- // Primitive
1095
- if (typeof_default()(value) !== 'object') {
1096
- return [[encodedKey, encodeFn(value)]];
1097
- }
1098
-
1099
- // Array of primitives
1100
- if (is_array_default()(value) && value.every(function (v) {return typeof_default()(v) !== 'object';})) {
1101
- return [[encodedKey, value.map(encodeFn).join(',')]];
1102
- }
1103
-
1104
- // Array or object
1105
- return [[encodedKey, encodeFn(stringify_default()(value))]];
1106
- }
1107
-
1108
- // for OAS 2 Parameter Object
1109
- // Primitive
1110
- if (typeof_default()(value) !== 'object') {
1111
- return [[encodedKey, encodeFn(value)]];
1112
- }
1113
-
1114
- // Array
1115
- if (is_array_default()(value)) {
1116
- if (collectionFormat === 'multi') {
1117
- // In case of multipart/formdata, it is used as array.
1118
- // Otherwise, the caller will convert it to a query by qs.stringify.
1119
- return [[encodedKey, value.map(encodeFn)]];
1120
- }
1121
-
1122
- return [[encodedKey, value.map(encodeFn).join(SEPARATORS[collectionFormat || 'csv'])]];
1123
- }
1124
-
1125
- // Object
1126
- return [[encodedKey, '']];
1127
- }
1128
-
1129
- function formatKeyValueBySerializationOption(key, value, skipEncoding, serializationOption) {
1130
- var style = serializationOption.style || 'form';
1131
- var explode = typeof serializationOption.explode === 'undefined' ? style === 'form' : serializationOption.explode;
1132
- // eslint-disable-next-line no-nested-ternary
1133
- var escape = skipEncoding ? false : serializationOption && serializationOption.allowReserved ? 'unsafe' : 'reserved';
1134
- var encodeFn = function encodeFn(v) {return encodeDisallowedCharacters(v, { escape: escape });};
1135
- var encodeKeyFn = skipEncoding ? function (k) {return k;} : function (k) {return encodeDisallowedCharacters(k, { escape: escape });};
1136
-
1137
- // Primitive
1138
- if (typeof_default()(value) !== 'object') {
1139
- return [[encodeKeyFn(key), encodeFn(value)]];
1140
- }
1141
-
1142
- // Array
1143
- if (is_array_default()(value)) {
1144
- if (explode) {
1145
- // In case of multipart/formdata, it is used as array.
1146
- // Otherwise, the caller will convert it to a query by qs.stringify.
1147
- return [[encodeKeyFn(key), value.map(encodeFn)]];
1148
- }
1149
- return [[encodeKeyFn(key), value.map(encodeFn).join(STYLE_SEPARATORS[style])]];
1150
- }
1151
-
1152
- // Object
1153
- if (style === 'deepObject') {
1154
- return keys_default()(value).map(function (valueKey) {return [encodeKeyFn("".concat(key, "[").concat(valueKey, "]")), encodeFn(value[valueKey])];});
1155
- }
1156
-
1157
- if (explode) {
1158
- return keys_default()(value).map(function (valueKey) {return [encodeKeyFn(valueKey), encodeFn(value[valueKey])];});
1159
- }
1160
-
1161
- return [[encodeKeyFn(key), keys_default()(value).map(function (valueKey) {return ["".concat(encodeKeyFn(valueKey), ",").concat(encodeFn(value[valueKey]))];}).join(',')]];
1162
- }
1163
-
1164
- function buildFormData(reqForm) {
1165
- /**
1166
- * Build a new FormData instance, support array as field value
1167
- * OAS2.0 - when collectionFormat is multi
1168
- * OAS3.0 - when explode of Encoding Object is true
1169
- * @param {Object} reqForm - ori req.form
1170
- * @return {FormData} - new FormData instance
1171
- */
1172
- return entries_default()(reqForm).reduce(function (formData, _ref4) {var _ref5 = slicedToArray_default()(_ref4, 2),name = _ref5[0],input = _ref5[1];var _iterator = _createForOfIteratorHelper(
1173
- formatKeyValue(name, input, true)),_step;try {for (_iterator.s(); !(_step = _iterator.n()).done;) {var _ref8 = _step.value;var _ref7 = slicedToArray_default()(_ref8, 2);var key = _ref7[0];var value = _ref7[1];
1174
- if (is_array_default()(value)) {var _iterator2 = _createForOfIteratorHelper(
1175
- value),_step2;try {for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {var v = _step2.value;
1176
- formData.append(key, v);
1177
- }} catch (err) {_iterator2.e(err);} finally {_iterator2.f();}
1178
- } else
1179
- {
1180
- formData.append(key, value);
1181
- }
1182
- }} catch (err) {_iterator.e(err);} finally {_iterator.f();}
1183
- return formData;
1184
- }, new form_data_monkey_patch());
1185
- }
1186
-
1187
- // Encodes an object using appropriate serializer.
1188
- function encodeFormOrQuery(data) {
1189
- /**
1190
- * Encode parameter names and values
1191
- * @param {Object} result - parameter names and values
1192
- * @param {string} parameterName - Parameter name
1193
- * @return {object} encoded parameter names and values
1194
- */
1195
- var encodedQuery = keys_default()(data).reduce(function (result, parameterName) {var _iterator3 = _createForOfIteratorHelper(
1196
- formatKeyValue(parameterName, data[parameterName])),_step3;try {for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {var _ref11 = _step3.value;var _ref10 = slicedToArray_default()(_ref11, 2);var key = _ref10[0];var value = _ref10[1];
1197
- result[key] = value;
1198
- }} catch (err) {_iterator3.e(err);} finally {_iterator3.f();}
1199
- return result;
1200
- }, {});
1201
- return external_qs_default.a.stringify(encodedQuery, { encode: false, indices: false }) || '';
1202
- }
1203
-
1204
- // If the request has a `query` object, merge it into the request.url, and delete the object
1205
- // If file and/or multipart, also create FormData instance
1206
- function mergeInQueryOrForm() {var req = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};var _req$url =
1207
- req.url,url = _req$url === void 0 ? '' : _req$url,query = req.query,form = req.form;
1208
- var joinSearch = function joinSearch() {for (var _len = arguments.length, strs = new Array(_len), _key = 0; _key < _len; _key++) {strs[_key] = arguments[_key];}
1209
- var search = strs.filter(function (a) {return a;}).join('&'); // Only truthy value
1210
- return search ? "?".concat(search) : ''; // Only add '?' if there is a str
1211
- };
1212
-
1213
- if (form) {
1214
- var hasFile = keys_default()(form).some(function (key) {
1215
- var value = form[key].value;
1216
- return isFile(value) || isArrayOfFile(value);
1217
- });
1218
-
1219
- var contentType = req.headers['content-type'] || req.headers['Content-Type'];
1220
-
1221
- if (hasFile || /multipart\/form-data/i.test(contentType)) {
1222
- req.body = buildFormData(req.form);
1223
- } else
1224
- {
1225
- req.body = encodeFormOrQuery(form);
1226
- }
1227
-
1228
- delete req.form;
1229
- }
1230
-
1231
- if (query) {var _url$split =
1232
- url.split('?'),_url$split2 = slicedToArray_default()(_url$split, 2),baseUrl = _url$split2[0],oriSearch = _url$split2[1];
1233
- var newStr = '';
1234
-
1235
- if (oriSearch) {
1236
- var oriQuery = external_qs_default.a.parse(oriSearch);
1237
- var keysToRemove = keys_default()(query);
1238
- keysToRemove.forEach(function (key) {return delete oriQuery[key];});
1239
- newStr = external_qs_default.a.stringify(oriQuery, { encode: true });
1240
- }
1241
-
1242
- var finalStr = joinSearch(newStr, encodeFormOrQuery(query));
1243
- req.url = baseUrl + finalStr;
1244
- delete req.query;
1245
- }
1246
- return req;
1247
- }
1248
-
1249
- // Wrap a http function ( there are otherways to do this, consider this deprecated )
1250
- function makeHttp(httpFn, preFetch, postFetch) {
1251
- postFetch = postFetch || function (a) {return a;};
1252
- preFetch = preFetch || function (a) {return a;};
1253
- return function (req) {
1254
- if (typeof req === 'string') {
1255
- req = { url: req };
1256
- }
1257
- http_self.mergeInQueryOrForm(req);
1258
- req = preFetch(req);
1259
- return postFetch(httpFn(req));
1260
- };
1261
- }
1262
- // EXTERNAL MODULE: external "@babel/runtime-corejs2/core-js/promise"
1263
- var promise_ = __webpack_require__(14);
1264
- var promise_default = /*#__PURE__*/__webpack_require__.n(promise_);
1265
-
1266
- // EXTERNAL MODULE: external "@babel/runtime-corejs2/core-js/object/create"
1267
- var create_ = __webpack_require__(35);
1268
- var create_default = /*#__PURE__*/__webpack_require__.n(create_);
1269
-
1270
- // EXTERNAL MODULE: external "@babel/runtime-corejs2/core-js/object/assign"
1271
- var object_assign_ = __webpack_require__(3);
1272
- var object_assign_default = /*#__PURE__*/__webpack_require__.n(object_assign_);
1273
-
1274
- // EXTERNAL MODULE: external "lodash/find"
1275
- var find_ = __webpack_require__(46);
1276
- var find_default = /*#__PURE__*/__webpack_require__.n(find_);
1277
-
1278
- // EXTERNAL MODULE: external "lodash/noop"
1279
- var noop_ = __webpack_require__(36);
1280
- var noop_default = /*#__PURE__*/__webpack_require__.n(noop_);
1281
-
1282
- // EXTERNAL MODULE: external "@babel/runtime-corejs2/helpers/toConsumableArray"
1283
- var toConsumableArray_ = __webpack_require__(13);
1284
- var toConsumableArray_default = /*#__PURE__*/__webpack_require__.n(toConsumableArray_);
1285
-
1286
- // EXTERNAL MODULE: external "fast-json-patch"
1287
- var external_fast_json_patch_ = __webpack_require__(27);
1288
- var external_fast_json_patch_default = /*#__PURE__*/__webpack_require__.n(external_fast_json_patch_);
1289
-
1290
- // EXTERNAL MODULE: external "deep-extend"
1291
- var external_deep_extend_ = __webpack_require__(47);
1292
- var external_deep_extend_default = /*#__PURE__*/__webpack_require__.n(external_deep_extend_);
1293
-
1294
- // EXTERNAL MODULE: external "@kyleshockey/object-assign-deep"
1295
- var object_assign_deep_ = __webpack_require__(48);
1296
- var object_assign_deep_default = /*#__PURE__*/__webpack_require__.n(object_assign_deep_);
1297
-
1298
- // CONCATENATED MODULE: ./src/specmap/lib/index.js
1299
-
1300
-
1301
-
1302
-
1303
-
1304
- /* harmony default export */ var lib = ({
1305
- add: add,
1306
- replace: replace,
1307
- remove: remove,
1308
- merge: merge,
1309
- mergeDeep: mergeDeep,
1310
- context: context,
1311
- getIn: getIn,
1312
- applyPatch: applyPatch,
1313
- parentPathMatch: parentPathMatch,
1314
- flatten: flatten,
1315
- fullyNormalizeArray: fullyNormalizeArray,
1316
- normalizeArray: lib_normalizeArray,
1317
- isPromise: isPromise,
1318
- forEachNew: forEachNew,
1319
- forEachNewPrimitive: forEachNewPrimitive,
1320
- isJsonPatch: isJsonPatch,
1321
- isContextPatch: isContextPatch,
1322
- isPatch: isPatch,
1323
- isMutation: isMutation,
1324
- isAdditiveMutation: isAdditiveMutation,
1325
- isGenerator: isGenerator,
1326
- isFunction: isFunction,
1327
- isObject: isObject,
1328
- isError: isError });
1329
-
1330
-
1331
- function applyPatch(obj, patch, opts) {
1332
- opts = opts || {};
1333
-
1334
- patch = object_assign_default()({}, patch, {
1335
- path: patch.path && normalizeJSONPath(patch.path) });
1336
-
1337
-
1338
- if (patch.op === 'merge') {
1339
- var newValue = getInByJsonPath(obj, patch.path);
1340
- object_assign_default()(newValue, patch.value);
1341
- external_fast_json_patch_default.a.applyPatch(obj, [replace(patch.path, newValue)]);
1342
- } else
1343
- if (patch.op === 'mergeDeep') {
1344
- var currentValue = getInByJsonPath(obj, patch.path);
1345
-
1346
- // Iterate the properties of the patch
1347
- for (var prop in patch.value) {
1348
- var propVal = patch.value[prop];
1349
- var isArray = is_array_default()(propVal);
1350
- if (isArray) {
1351
- // deepExtend doesn't merge arrays, so we will do it manually
1352
- var existing = currentValue[prop] || [];
1353
- currentValue[prop] = existing.concat(propVal);
1354
- } else
1355
- if (isObject(propVal) && !isArray) {
1356
- // If it's an object, iterate it's keys and merge
1357
- // if there are conflicting keys, merge deep, otherwise shallow merge
1358
- var currentObj = object_assign_default()({}, currentValue[prop]);
1359
- for (var key in propVal) {
1360
- if (Object.prototype.hasOwnProperty.call(currentObj, key)) {
1361
- // if there is a single conflicting key, just deepExtend the entire value
1362
- // and break from the loop (since all future keys are also merged)
1363
- // We do this because we can't deepExtend two primitives
1364
- // (currentObj[key] & propVal[key] may be primitives).
1365
- //
1366
- // we also deeply assign here, since we aren't in control of
1367
- // how deepExtend affects existing nested objects
1368
- currentObj = external_deep_extend_default()(object_assign_deep_default()({}, currentObj), propVal);
1369
- break;
1370
- } else
1371
- {
1372
- object_assign_default()(currentObj, defineProperty_default()({}, key, propVal[key]));
1373
- }
1374
- }
1375
- currentValue[prop] = currentObj;
1376
- } else
1377
- {
1378
- // It's a primitive, just replace existing
1379
- currentValue[prop] = propVal;
1380
- }
1381
- }
1382
- } else
1383
- if (patch.op === 'add' && patch.path === '' && isObject(patch.value)) {
1384
- // { op: 'add', path: '', value: { a: 1, b: 2 }}
1385
- // has no effect: json patch refuses to do anything.
1386
- // so let's break that patch down into a set of patches,
1387
- // one for each key in the intended root value.
1388
-
1389
- var patches = keys_default()(patch.value).
1390
- reduce(function (arr, key) {
1391
- arr.push({
1392
- op: 'add',
1393
- path: "/".concat(normalizeJSONPath(key)),
1394
- value: patch.value[key] });
1395
-
1396
- return arr;
1397
- }, []);
1398
-
1399
- external_fast_json_patch_default.a.applyPatch(obj, patches);
1400
- } else
1401
- if (patch.op === 'replace' && patch.path === '') {
1402
- var value = patch.value;
1403
-
1404
- if (opts.allowMetaPatches && patch.meta && isAdditiveMutation(patch) && (
1405
- is_array_default()(patch.value) || isObject(patch.value))) {
1406
- value = object_assign_default()({}, value, patch.meta);
1407
- }
1408
- obj = value;
1409
- } else
1410
- {
1411
- external_fast_json_patch_default.a.applyPatch(obj, [patch]);
1412
-
1413
- // Attach metadata to the resulting value.
1414
- if (opts.allowMetaPatches && patch.meta && isAdditiveMutation(patch) && (
1415
- is_array_default()(patch.value) || isObject(patch.value))) {
1416
- var _currentValue = getInByJsonPath(obj, patch.path);
1417
- var _newValue = object_assign_default()({}, _currentValue, patch.meta);
1418
- external_fast_json_patch_default.a.applyPatch(obj, [replace(patch.path, _newValue)]);
1419
- }
1420
- }
1421
-
1422
- return obj;
1423
- }
1424
-
1425
- function normalizeJSONPath(path) {
1426
- if (is_array_default()(path)) {
1427
- if (path.length < 1) {
1428
- return '';
1429
- }
1430
-
1431
- return '/' + path.map(function (item) {// eslint-disable-line prefer-template
1432
- return (item + '').replace(/~/g, '~0').replace(/\//g, '~1'); // eslint-disable-line prefer-template
1433
- }).join('/');
1434
- }
1435
-
1436
- return path;
1437
- }
1438
-
1439
-
1440
- // =========================
1441
- // JSON-Patch Wrappers
1442
- // =========================
1443
-
1444
- function add(path, value) {
1445
- return { op: 'add', path: path, value: value };
1446
- }
1447
-
1448
- function lib_get(path) {
1449
- return { op: '_get', path: path };
1450
- }
1451
-
1452
- function replace(path, value, meta) {
1453
- return { op: 'replace', path: path, value: value, meta: meta };
1454
- }
1455
-
1456
- function remove(path, value) {
1457
- return { op: 'remove', path: path };
1458
- }
1459
-
1460
- // Custom wrappers
1461
- function merge(path, value) {
1462
- return { type: 'mutation', op: 'merge', path: path, value: value };
1463
- }
1464
-
1465
- // Custom wrappers
1466
- function mergeDeep(path, value) {
1467
- return { type: 'mutation', op: 'mergeDeep', path: path, value: value };
1468
- }
1469
-
1470
- function context(path, value) {
1471
- return { type: 'context', path: path, value: value };
1472
- }
1473
-
1474
-
1475
- // =========================
1476
- // Iterators
1477
- // =========================
1478
-
1479
- function forEachNew(mutations, fn) {
1480
- try {
1481
- return forEachNewPatch(mutations, forEach, fn);
1482
- }
1483
- catch (e) {
1484
- return e;
1485
- }
1486
- }
1487
-
1488
- function forEachNewPrimitive(mutations, fn) {
1489
- try {
1490
- return forEachNewPatch(mutations, forEachPrimitive, fn);
1491
- }
1492
- catch (e) {
1493
- return e;
1494
- }
1495
- }
1496
-
1497
- function forEachNewPatch(mutations, fn, callback) {
1498
- var res = mutations.filter(isAdditiveMutation).map(function (mutation) {
1499
- return fn(mutation.value, callback, mutation.path);
1500
- }) || [];
1501
- var flat = flatten(res);
1502
- var clean = cleanArray(flat);
1503
- return clean;
1504
- }
1505
-
1506
- function forEachPrimitive(obj, fn, basePath) {
1507
- basePath = basePath || [];
1508
-
1509
- if (is_array_default()(obj)) {
1510
- return obj.map(function (val, key) {
1511
- return forEachPrimitive(val, fn, basePath.concat(key));
1512
- });
1513
- }
1514
-
1515
- if (isObject(obj)) {
1516
- return keys_default()(obj).map(function (key) {
1517
- return forEachPrimitive(obj[key], fn, basePath.concat(key));
1518
- });
1519
- }
1520
-
1521
- return fn(obj, basePath[basePath.length - 1], basePath);
1522
- }
1523
-
1524
- function forEach(obj, fn, basePath) {
1525
- basePath = basePath || [];
1526
-
1527
- var results = [];
1528
- if (basePath.length > 0) {
1529
- var newResults = fn(obj, basePath[basePath.length - 1], basePath);
1530
- if (newResults) {
1531
- results = results.concat(newResults);
1532
- }
1533
- }
1534
-
1535
- if (is_array_default()(obj)) {
1536
- var arrayResults = obj.map(function (val, key) {
1537
- return forEach(val, fn, basePath.concat(key));
1538
- });
1539
- if (arrayResults) {
1540
- results = results.concat(arrayResults);
1541
- }
1542
- } else
1543
- if (isObject(obj)) {
1544
- var moreResults = keys_default()(obj).map(function (key) {
1545
- return forEach(obj[key], fn, basePath.concat(key));
1546
- });
1547
- if (moreResults) {
1548
- results = results.concat(moreResults);
1549
- }
1550
- }
1551
-
1552
- results = flatten(results);
1553
- return results;
1554
- }
1555
-
1556
-
1557
- // =========================
1558
- // Paths
1559
- // =========================
1560
-
1561
- function parentPathMatch(path, arr) {
1562
- if (!is_array_default()(arr)) {
1563
- return false;
1564
- }
1565
-
1566
- for (var i = 0, len = arr.length; i < len; i++) {
1567
- if (arr[i] !== path[i]) {
1568
- return false;
1569
- }
1570
- }
1571
-
1572
- return true;
1573
- }
1574
-
1575
- function getIn(obj, path) {
1576
- return path.reduce(function (val, token) {
1577
- if (typeof token !== 'undefined' && val) {
1578
- return val[token];
1579
- }
1580
- return val;
1581
- }, obj);
1582
- }
1583
-
1584
- // =========================
1585
- // Array
1586
- // =========================
1587
-
1588
- function fullyNormalizeArray(arr) {
1589
- return cleanArray(flatten(lib_normalizeArray(arr)));
1590
- }
1591
-
1592
- function lib_normalizeArray(arr) {
1593
- return is_array_default()(arr) ? arr : [arr];
1594
- }
1595
-
1596
- function flatten(arr) {var _ref;
1597
- return (_ref = []).concat.apply(_ref, toConsumableArray_default()(arr.map(function (val) {
1598
- return is_array_default()(val) ? flatten(val) : val;
1599
- })));
1600
- }
1601
-
1602
- function cleanArray(arr) {
1603
- return arr.filter(function (elm) {return typeof elm !== 'undefined';});
1604
- }
1605
-
1606
-
1607
- // =========================
1608
- // Is-Thing.
1609
- // =========================
1610
-
1611
- function isObject(val) {
1612
- return val && typeof_default()(val) === 'object';
1613
- }
1614
-
1615
- function isPromise(val) {
1616
- return isObject(val) && isFunction(val.then);
1617
- }
1618
-
1619
- function isFunction(val) {
1620
- return val && typeof val === 'function';
1621
- }
1622
-
1623
- function isError(patch) {
1624
- return patch instanceof Error;
1625
- }
1626
-
1627
- function isJsonPatch(patch) {
1628
- if (isPatch(patch)) {
1629
- var op = patch.op;
1630
- return op === 'add' || op === 'remove' || op === 'replace';
1631
- }
1632
- return false;
1633
- }
1634
-
1635
- function isGenerator(thing) {
1636
- return regenerator_default.a.isGeneratorFunction(thing);
1637
- }
1638
-
1639
- function isMutation(patch) {
1640
- return isJsonPatch(patch) || isPatch(patch) && patch.type === 'mutation';
1641
- }
1642
-
1643
- function isAdditiveMutation(patch) {
1644
- return isMutation(patch) && (patch.op === 'add' || patch.op === 'replace' || patch.op === 'merge' || patch.op === 'mergeDeep');
1645
- }
1646
-
1647
- function isContextPatch(patch) {
1648
- return isPatch(patch) && patch.type === 'context';
1649
- }
1650
-
1651
- function isPatch(patch) {
1652
- return patch && typeof_default()(patch) === 'object';
1653
- }
1654
-
1655
- function getInByJsonPath(obj, jsonPath) {
1656
- try {
1657
- return external_fast_json_patch_default.a.getValueByPointer(obj, jsonPath);
1658
- }
1659
- catch (e) {
1660
- console.error(e); // eslint-disable-line no-console
1661
- return {};
1662
- }
1663
- }
1664
- // EXTERNAL MODULE: external "@babel/runtime-corejs2/core-js/weak-map"
1665
- var weak_map_ = __webpack_require__(49);
1666
- var weak_map_default = /*#__PURE__*/__webpack_require__.n(weak_map_);
1667
-
1668
- // EXTERNAL MODULE: external "cross-fetch"
1669
- var external_cross_fetch_ = __webpack_require__(50);
1670
-
1671
- // EXTERNAL MODULE: external "querystring-browser"
1672
- var external_querystring_browser_ = __webpack_require__(37);
1673
- var external_querystring_browser_default = /*#__PURE__*/__webpack_require__.n(external_querystring_browser_);
1674
-
1675
- // CONCATENATED MODULE: ./src/specmap/lib/create-error.js
1676
- function createErrorType(name, init) {
1677
- function E() {
1678
- if (!Error.captureStackTrace) {
1679
- this.stack = new Error().stack;
1680
- } else
1681
- {
1682
- Error.captureStackTrace(this, this.constructor);
1683
- }for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {args[_key] = arguments[_key];}
1684
- this.message = args[0];
1685
- init && init.apply(this, args);
1686
- }
1687
-
1688
- E.prototype = new Error();
1689
- E.prototype.name = name;
1690
- E.prototype.constructor = E;
1691
-
1692
- return E;
1693
- }
1694
- // EXTERNAL MODULE: external "traverse"
1695
- var external_traverse_ = __webpack_require__(51);
1696
- var external_traverse_default = /*#__PURE__*/__webpack_require__.n(external_traverse_);
1697
-
1698
- // CONCATENATED MODULE: ./src/specmap/helpers.js
1699
-
1700
-
1701
-
1702
- // This will match if the direct parent's key exactly matches an item.
1703
- var freelyNamedKeyParents = [
1704
- 'properties'];
1705
-
1706
-
1707
- // This will match if the grandparent's key exactly matches an item.
1708
- // NOTE that this is for finding non-free paths!
1709
- var nonFreelyNamedKeyGrandparents = [
1710
- 'properties'];
1711
-
1712
-
1713
- // This will match if the joined parent path exactly matches an item.
1714
- //
1715
- // This is mostly useful for filtering out root-level reusable item names,
1716
- // for example `["definitions", "$ref"]`
1717
- var freelyNamedPaths = [
1718
- // Swagger 2.0
1719
- 'definitions',
1720
- 'parameters',
1721
- 'responses',
1722
- 'securityDefinitions',
1723
-
1724
- // OpenAPI 3.0
1725
- 'components/schemas',
1726
- 'components/responses',
1727
- 'components/parameters',
1728
- 'components/securitySchemes'];
1729
-
1730
-
1731
- // This will match if any of these items are substrings of the joined
1732
- // parent path.
1733
- //
1734
- // Warning! These are powerful. Beware of edge cases.
1735
- var freelyNamedAncestors = [
1736
- 'schema/example',
1737
- 'items/example'];
1738
-
1739
-
1740
- function isFreelyNamed(parentPath) {
1741
- var parentKey = parentPath[parentPath.length - 1];
1742
- var grandparentKey = parentPath[parentPath.length - 2];
1743
- var parentStr = parentPath.join('/');
1744
-
1745
- return (
1746
- // eslint-disable-next-line max-len
1747
- freelyNamedKeyParents.indexOf(parentKey) > -1 && nonFreelyNamedKeyGrandparents.indexOf(grandparentKey) === -1 ||
1748
- freelyNamedPaths.indexOf(parentStr) > -1 ||
1749
- freelyNamedAncestors.some(function (el) {return parentStr.indexOf(el) > -1;}));
1750
-
1751
- }
1752
-
1753
- function generateAbsoluteRefPatches(obj, basePath)
1754
-
1755
-
1756
-
1757
- {var _ref = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {},specmap = _ref.specmap,_ref$getBaseUrlForNod = _ref.getBaseUrlForNodePath,getBaseUrlForNodePath = _ref$getBaseUrlForNod === void 0 ? function (path) {return specmap.getContext([].concat(toConsumableArray_default()(basePath), toConsumableArray_default()(path))).baseDoc;} : _ref$getBaseUrlForNod,_ref$targetKeys = _ref.targetKeys,targetKeys = _ref$targetKeys === void 0 ? ['$ref', '$$ref'] : _ref$targetKeys;
1758
- var patches = [];
1759
-
1760
- external_traverse_default()(obj).forEach(function () {
1761
- if (targetKeys.indexOf(this.key) > -1) {
1762
- var nodePath = this.path; // this node's path, relative to `obj`
1763
- var fullPath = basePath.concat(this.path);
1764
-
1765
- var absolutifiedRefValue = absolutifyPointer(this.node, getBaseUrlForNodePath(nodePath));
1766
-
1767
- patches.push(specmap.replace(fullPath, absolutifiedRefValue));
1768
- }
1769
- });
1770
-
1771
- return patches;
1772
- }
1773
-
1774
- function absolutifyPointer(pointer, baseUrl) {var _pointer$split =
1775
- pointer.split('#'),_pointer$split2 = slicedToArray_default()(_pointer$split, 2),urlPart = _pointer$split2[0],fragmentPart = _pointer$split2[1];
1776
- var newRefUrlPart = external_url_default.a.resolve(urlPart || '', baseUrl || '');
1777
-
1778
- return fragmentPart ? "".concat(newRefUrlPart, "#").concat(fragmentPart) : newRefUrlPart;
1779
- }
1780
- // CONCATENATED MODULE: ./src/constants.js
1781
- var ACCEPT_HEADER_VALUE_FOR_DOCUMENTS = 'application/json, application/yaml';
1782
- // CONCATENATED MODULE: ./src/specmap/lib/refs.js
1783
-
1784
-
1785
-
1786
-
1787
-
1788
-
1789
-
1790
-
1791
-
1792
- var ABSOLUTE_URL_REGEXP = new RegExp('^([a-z]+://|//)', 'i');
1793
-
1794
- var JSONRefError = createErrorType('JSONRefError', function (message, extra, oriError) {
1795
- this.originalError = oriError;
1796
- object_assign_default()(this, extra || {});
1797
- });
1798
-
1799
- var docCache = {};
1800
- var specmapRefs = new weak_map_default.a();
1801
-
1802
- var skipResolutionTestFns = [
1803
- function (path) {return (
1804
- // OpenAPI 3.0 Response Media Type Example
1805
- // ["paths", *, *, "responses", *, "content", *, "example"]
1806
- path[0] === 'paths' &&
1807
- path[3] === 'responses' &&
1808
- path[5] === 'content' &&
1809
- path[7] === 'example');},
1810
-
1811
- function (path) {return (
1812
- // OpenAPI 3.0 Request Body Media Type Example
1813
- // ["paths", *, *, "responses", *, "content", *, "example"]
1814
- path[0] === 'paths' &&
1815
- path[3] === 'requestBody' &&
1816
- path[4] === 'content' &&
1817
- path[6] === 'example');}];
1818
-
1819
-
1820
-
1821
- var shouldSkipResolution = function shouldSkipResolution(path) {return skipResolutionTestFns.some(function (fn) {return fn(path);});};
1822
-
1823
- // =========================
1824
- // Core
1825
- // =========================
1826
-
1827
- /**
1828
- * This plugin resolves the JSON pointers.
1829
- * A major part of this plugin deals with cyclic references via 2 mechanisms.
1830
- * 1. If a pointer was already resolved before in this path, halt.
1831
- * 2. If the patch value points to one of the ancestors in this path, halt.
1832
- *
1833
- * Note that either one of these mechanism is sufficient, both must be in place.
1834
- * For examples:
1835
- *
1836
- * Given the following spec, #1 alone is insufficient because after the 2nd
1837
- * application, there will be a cyclic object reference.
1838
- * a.b.c: $ref-d
1839
- * d.e.f: $ref-a (per #1, safe to return patch as no immediate cycle)
1840
- *
1841
- * Given the following spec, #2 alone is insufficient because although there will
1842
- * never be any cyclic object reference, the plugin will keep producing patches.
1843
- * a: $ref-b
1844
- * b: $ref-a
1845
- */
1846
- var refs_plugin = {
1847
- key: '$ref',
1848
- plugin: function plugin(ref, key, fullPath, specmap) {
1849
- var specmapInstance = specmap.getInstance();
1850
- var parent = fullPath.slice(0, -1);
1851
-
1852
- if (isFreelyNamed(parent) || shouldSkipResolution(parent)) {
1853
- return;
1854
- }
1855
-
1856
- var baseDoc = specmap.getContext(fullPath).baseDoc;
1857
- if (typeof ref !== 'string') {
1858
- return new JSONRefError('$ref: must be a string (JSON-Ref)', {
1859
- $ref: ref,
1860
- baseDoc: baseDoc,
1861
- fullPath: fullPath });
1862
-
1863
- }
1864
-
1865
- var splitString = split(ref);
1866
- var refPath = splitString[0];
1867
- var pointer = splitString[1] || '';
1868
-
1869
- var basePath;
1870
- try {
1871
- basePath = baseDoc || refPath ? absoluteify(refPath, baseDoc) : null;
1872
- }
1873
- catch (e) {
1874
- return wrapError(e, {
1875
- pointer: pointer,
1876
- $ref: ref,
1877
- basePath: basePath,
1878
- fullPath: fullPath });
1879
-
1880
- }
1881
-
1882
- var promOrVal;
1883
- var tokens;
1884
-
1885
- if (pointerAlreadyInPath(pointer, basePath, parent, specmap)) {
1886
- // Cyclic reference!
1887
- // if `useCircularStructures` is not set, just leave the reference
1888
- // unresolved, but absolutify it so that we don't leave an invalid $ref
1889
- // path in the content
1890
- if (!specmapInstance.useCircularStructures) {
1891
- var _absolutifiedRef = absolutifyPointer(ref, basePath);
1892
-
1893
- if (ref === _absolutifiedRef) {
1894
- // avoids endless looping
1895
- // without this, the ref plugin never stops seeing this $ref
1896
- return null;
1897
- }
1898
- return lib.replace(fullPath, _absolutifiedRef);
1899
- }
1900
- }
1901
-
1902
- if (basePath == null) {
1903
- tokens = jsonPointerToArray(pointer);
1904
- promOrVal = specmap.get(tokens);
1905
-
1906
- if (typeof promOrVal === 'undefined') {
1907
- promOrVal = new JSONRefError("Could not resolve reference: ".concat(ref), {
1908
- pointer: pointer,
1909
- $ref: ref,
1910
- baseDoc: baseDoc,
1911
- fullPath: fullPath });
1912
-
1913
- }
1914
- } else
1915
- {
1916
- promOrVal = extractFromDoc(basePath, pointer);
1917
- if (promOrVal.__value != null) {
1918
- promOrVal = promOrVal.__value;
1919
- } else
1920
- {
1921
- promOrVal = promOrVal.catch(function (e) {
1922
- throw wrapError(e, {
1923
- pointer: pointer,
1924
- $ref: ref,
1925
- baseDoc: baseDoc,
1926
- fullPath: fullPath });
1927
-
1928
- });
1929
- }
1930
- }
1931
-
1932
- if (promOrVal instanceof Error) {
1933
- return [lib.remove(fullPath), promOrVal];
1934
- }
1935
-
1936
- var absolutifiedRef = absolutifyPointer(ref, basePath);
1937
-
1938
- var patch = lib.replace(parent, promOrVal, { $$ref: absolutifiedRef });
1939
- if (basePath && basePath !== baseDoc) {
1940
- return [patch, lib.context(parent, { baseDoc: basePath })];
1941
- }
1942
-
1943
- try {
1944
- // prevents circular values from being constructed, unless we specifically
1945
- // want that to happen
1946
- if (!patchValueAlreadyInPath(specmap.state, patch) || specmapInstance.useCircularStructures) {
1947
- return patch;
1948
- }
1949
- }
1950
- catch (e) {
1951
- // if we're catching here, path traversal failed, so we should
1952
- // ditch without sending any patches back up.
1953
- //
1954
- // this is a narrow fix for the larger problem of patches being queued
1955
- // and then having the state they were generated against be modified
1956
- // before they are applied.
1957
- //
1958
- // TODO: re-engineer specmap patch/state management to avoid this
1959
- return null;
1960
- }
1961
- } };
1962
-
1963
-
1964
-
1965
- var mod = object_assign_default()(refs_plugin, {
1966
- docCache: docCache,
1967
- absoluteify: absoluteify,
1968
- clearCache: clearCache,
1969
- JSONRefError: JSONRefError,
1970
- wrapError: wrapError,
1971
- getDoc: getDoc,
1972
- split: split,
1973
- extractFromDoc: extractFromDoc,
1974
- fetchJSON: fetchJSON,
1975
- extract: extract,
1976
- jsonPointerToArray: jsonPointerToArray,
1977
- unescapeJsonPointerToken: unescapeJsonPointerToken });
1978
-
1979
-
1980
- /* harmony default export */ var refs = (mod);
1981
-
1982
-
1983
- // =========================
1984
- // Utilities
1985
- // =========================
1986
-
1987
- /**
1988
- * Resolves a path and its base to an abolute URL.
1989
- * @api public
1990
- */
1991
- function absoluteify(path, basePath) {
1992
- if (!ABSOLUTE_URL_REGEXP.test(path)) {
1993
- if (!basePath) {
1994
- throw new JSONRefError("Tried to resolve a relative URL, without having a basePath. path: '".concat(path, "' basePath: '").concat(basePath, "'"));
1995
- }
1996
- return external_url_default.a.resolve(basePath, path);
1997
- }
1998
- return path;
1999
- }
2000
-
2001
- /**
2002
- * Wraps an error as JSONRefError.
2003
- * @param {Error} e the error.
2004
- * @param {Object} extra (optional) optional data.
2005
- * @return {Error} an instance of JSONRefError.
2006
- * @api public
2007
- */
2008
- function wrapError(e, extra) {
2009
- var message;
2010
-
2011
- if (e && e.response && e.response.body) {
2012
- message = "".concat(e.response.body.code, " ").concat(e.response.body.message);
2013
- } else
2014
- {
2015
- message = e.message;
2016
- }
2017
-
2018
- return new JSONRefError("Could not resolve reference: ".concat(message), extra, e);
2019
- }
2020
-
2021
- /**
2022
- * Splits a pointer by the hash delimiter.
2023
- * @api public
2024
- */
2025
- function split(ref) {
2026
- return (ref + '').split('#'); // eslint-disable-line prefer-template
2027
- }
2028
-
2029
- /**
2030
- * Extracts a pointer from its document.
2031
- * @param {String} docPath the absolute document URL.
2032
- * @param {String} pointer the pointer whose value is to be extracted.
2033
- * @return {Promise} a promise of the pointer value.
2034
- * @api public
2035
- */
2036
- function extractFromDoc(docPath, pointer) {
2037
- var doc = docCache[docPath];
2038
- if (doc && !lib.isPromise(doc)) {
2039
- // If doc is already available, return __value together with the promise.
2040
- // __value is for special handling in cycle check:
2041
- // pointerAlreadyInPath() won't work if patch.value is a promise,
2042
- // thus when that promise is finally resolved, cycle might happen (because
2043
- // `spec` and `docCache[basePath]` refer to the exact same object).
2044
- // See test "should resolve a cyclic spec when baseDoc is specified".
2045
- try {
2046
- var v = extract(pointer, doc);
2047
- return object_assign_default()(promise_default.a.resolve(v), { __value: v });
2048
- }
2049
- catch (e) {
2050
- return promise_default.a.reject(e);
2051
- }
2052
- }
2053
-
2054
- return getDoc(docPath).then(function (_doc) {return extract(pointer, _doc);});
2055
- }
2056
-
2057
- /**
2058
- * Clears all document caches.
2059
- * @param {String} item (optional) the name of the cache item to be cleared.
2060
- * @api public
2061
- */
2062
- function clearCache(item) {
2063
- if (typeof item !== 'undefined') {
2064
- delete docCache[item];
2065
- } else
2066
- {
2067
- keys_default()(docCache).forEach(function (key) {
2068
- delete docCache[key];
2069
- });
2070
- }
2071
- }
2072
-
2073
- /**
2074
- * Fetches and caches a document.
2075
- * @param {String} docPath the absolute URL of the document.
2076
- * @return {Promise} a promise of the document content.
2077
- * @api public
2078
- */
2079
- function getDoc(docPath) {
2080
- var val = docCache[docPath];
2081
- if (val) {
2082
- return lib.isPromise(val) ? val : promise_default.a.resolve(val);
2083
- }
2084
-
2085
- // NOTE: we need to use `mod.fetchJSON` in order to be able to overwrite it.
2086
- // Any tips on how to make this cleaner, please ping!
2087
- docCache[docPath] = mod.fetchJSON(docPath).then(function (doc) {
2088
- docCache[docPath] = doc;
2089
- return doc;
2090
- });
2091
- return docCache[docPath];
2092
- }
2093
-
2094
- /**
2095
- * Fetches a document.
2096
- * @param {String} docPath the absolute URL of the document.
2097
- * @return {Promise} a promise of the document content.
2098
- * @api public
2099
- */
2100
- function fetchJSON(docPath) {
2101
- return Object(external_cross_fetch_["fetch"])(docPath, { headers: { Accept: ACCEPT_HEADER_VALUE_FOR_DOCUMENTS }, loadSpec: true }).
2102
- then(function (res) {return res.text();}).
2103
- then(function (text) {return external_js_yaml_default.a.safeLoad(text);});
2104
- }
2105
-
2106
- /**
2107
- * Extracts a pointer from an object.
2108
- * @param {String[]} pointer the JSON pointer.
2109
- * @param {Object} obj an object whose value is to be extracted.
2110
- * @return {Object} the value to be extracted.
2111
- * @api public
2112
- */
2113
- function extract(pointer, obj) {
2114
- var tokens = jsonPointerToArray(pointer);
2115
- if (tokens.length < 1) {
2116
- return obj;
2117
- }
2118
-
2119
- var val = lib.getIn(obj, tokens);
2120
- if (typeof val === 'undefined') {
2121
- throw new JSONRefError("Could not resolve pointer: ".concat(pointer, " does not exist in document"), { pointer: pointer });
2122
- }
2123
- return val;
2124
- }
2125
-
2126
- /**
2127
- * Converts a JSON pointer to array.
2128
- * @api public
2129
- */
2130
- function jsonPointerToArray(pointer) {
2131
- if (typeof pointer !== 'string') {
2132
- throw new TypeError("Expected a string, got a ".concat(typeof_default()(pointer)));
2133
- }
2134
-
2135
- if (pointer[0] === '/') {
2136
- pointer = pointer.substr(1);
2137
- }
2138
-
2139
- if (pointer === '') {
2140
- return [];
2141
- }
2142
-
2143
- return pointer.split('/').map(unescapeJsonPointerToken);
2144
- }
2145
-
2146
- /**
2147
- * Unescapes a JSON pointer.
2148
- * @api public
2149
- */
2150
- function unescapeJsonPointerToken(token) {
2151
- if (typeof token !== 'string') {
2152
- return token;
2153
- }
2154
- return external_querystring_browser_default.a.unescape(token.replace(/~1/g, '/').replace(/~0/g, '~'));
2155
- }
2156
-
2157
- /**
2158
- * Escapes a JSON pointer.
2159
- * @api public
2160
- */
2161
- function escapeJsonPointerToken(token) {
2162
- return external_querystring_browser_default.a.escape(token.replace(/~/g, '~0').replace(/\//g, '~1'));
2163
- }
2164
-
2165
- function arrayToJsonPointer(arr) {
2166
- if (arr.length === 0) {
2167
- return '';
2168
- }
2169
-
2170
- return "/".concat(arr.map(escapeJsonPointerToken).join('/'));
2171
- }
2172
-
2173
- var pointerBoundaryChar = function pointerBoundaryChar(c) {return !c || c === '/' || c === '#';};
2174
-
2175
- function pointerIsAParent(pointer, parentPointer) {
2176
- if (pointerBoundaryChar(parentPointer)) {
2177
- // This is the root of the document, so its naturally a parent
2178
- return true;
2179
- }
2180
- var nextChar = pointer.charAt(parentPointer.length);
2181
- var lastParentChar = parentPointer.slice(-1);
2182
-
2183
- return pointer.indexOf(parentPointer) === 0 && (
2184
- !nextChar || nextChar === '/' || nextChar === '#') &&
2185
- lastParentChar !== '#';
2186
- }
2187
-
2188
-
2189
- // =========================
2190
- // Private
2191
- // =========================
2192
-
2193
- /**
2194
- * Checks if this pointer points back to one or more pointers along the path.
2195
- */
2196
- function pointerAlreadyInPath(pointer, basePath, parent, specmap) {
2197
- var refs = specmapRefs.get(specmap);
2198
- if (!refs) {
2199
- // Stores all resolved references of a specmap instance.
2200
- // Schema: path -> pointer (path's $ref value).
2201
- refs = {};
2202
- specmapRefs.set(specmap, refs);
2203
- }
2204
-
2205
- var parentPointer = arrayToJsonPointer(parent);
2206
- var fullyQualifiedPointer = "".concat(basePath || '<specmap-base>', "#").concat(pointer);
2207
-
2208
- // dirty hack to strip `allof/[index]` from the path, in order to avoid cases
2209
- // where we get false negatives because:
2210
- // - we resolve a path, then
2211
- // - allOf plugin collapsed `allOf/[index]` out of the path, then
2212
- // - we try to work on a child $ref within that collapsed path.
2213
- //
2214
- // because of the path collapse, we lose track of it in our specmapRefs hash
2215
- // solution: always throw the allOf constructs out of paths we store
2216
- // TODO: solve this with a global register, or by writing more metadata in
2217
- // either allOf or refs plugin
2218
- var safeParentPointer = parentPointer.replace(/allOf\/\d+\/?/g, '');
2219
-
2220
- // Case 1: direct cycle, e.g. a.b.c.$ref: '/a.b'
2221
- // Detect by checking that the parent path doesn't start with pointer.
2222
- // This only applies if the pointer is internal, i.e. basePath === rootPath (could be null)
2223
- var rootDoc = specmap.contextTree.get([]).baseDoc;
2224
- if (basePath == rootDoc && pointerIsAParent(safeParentPointer, pointer)) {// eslint-disable-line
2225
- return true;
2226
- }
2227
-
2228
-
2229
- // Case 2: indirect cycle
2230
- // ex1: a.$ref: '/b' & b.c.$ref: '/b/c'
2231
- // ex2: a.$ref: '/b/c' & b.c.$ref: '/b'
2232
- // Detect by retrieving all the $refs along the path of parent
2233
- // and checking if any starts with pointer or vice versa.
2234
- var currPath = '';
2235
- var hasIndirectCycle = parent.some(function (token) {
2236
- currPath = "".concat(currPath, "/").concat(escapeJsonPointerToken(token));
2237
- return refs[currPath] && refs[currPath].some(function (ref) {
2238
- return (
2239
- pointerIsAParent(ref, fullyQualifiedPointer) ||
2240
- pointerIsAParent(fullyQualifiedPointer, ref));
2241
-
2242
- });
2243
- });
2244
- if (hasIndirectCycle) {
2245
- return true;
2246
- }
2247
-
2248
- // No cycle, this ref will be resolved, so stores it now for future detection.
2249
- // No need to store if has cycle, as parent path is a dead-end and won't be checked again.
2250
-
2251
- refs[safeParentPointer] = (refs[safeParentPointer] || []).concat(fullyQualifiedPointer);
2252
- }
2253
-
2254
- /**
2255
- * Checks if the value of this patch ends up pointing to an ancestor along the path.
2256
- */
2257
- function patchValueAlreadyInPath(root, patch) {
2258
- var ancestors = [root];
2259
- patch.path.reduce(function (parent, p) {
2260
- ancestors.push(parent[p]);
2261
- return parent[p];
2262
- }, root);
2263
- return pointToAncestor(patch.value);
2264
-
2265
- function pointToAncestor(obj) {
2266
- return lib.isObject(obj) && (ancestors.indexOf(obj) >= 0 || keys_default()(obj).some(function (k) {
2267
- return pointToAncestor(obj[k]);
2268
- }));
2269
- }
2270
- }
2271
- // CONCATENATED MODULE: ./src/specmap/lib/all-of.js
2272
-
2273
-
2274
- /* harmony default export */ var all_of = ({
2275
- key: 'allOf',
2276
- plugin: function plugin(val, key, fullPath, specmap, patch) {
2277
- // Ignore replace patches created by $ref because the changes will
2278
- // occur in the original "add" patch and we don't want this plugin
2279
- // to redundantly processes those "relace" patches.
2280
- if (patch.meta && patch.meta.$$ref) {
2281
- return;
2282
- }
2283
-
2284
- var parent = fullPath.slice(0, -1);
2285
- if (isFreelyNamed(parent)) {
2286
- return;
2287
- }
2288
-
2289
- if (!is_array_default()(val)) {
2290
- var err = new TypeError('allOf must be an array');
2291
- err.fullPath = fullPath; // This is an array
2292
- return err;
2293
- }
2294
-
2295
-
2296
- var alreadyAddError = false;
2297
-
2298
- // Find the original definition from the `patch.value` object
2299
- // Remove the `allOf` property so it doesn't get added to the result of the `allOf` plugin
2300
- var originalDefinitionObj = patch.value;
2301
- parent.forEach(function (part) {
2302
- if (!originalDefinitionObj) return; // bail out if we've lost sight of our target
2303
- originalDefinitionObj = originalDefinitionObj[part];
2304
- });
2305
- originalDefinitionObj = object_assign_default()({}, originalDefinitionObj);
2306
- delete originalDefinitionObj.allOf;
2307
-
2308
- var patches = [];
2309
-
2310
- // remove existing content
2311
- patches.push(specmap.replace(parent, {}));
2312
-
2313
- val.forEach(function (toMerge, i) {
2314
- if (!specmap.isObject(toMerge)) {
2315
- if (alreadyAddError) {
2316
- return null;
2317
- }
2318
- alreadyAddError = true;
2319
-
2320
- var _err = new TypeError('Elements in allOf must be objects');
2321
- _err.fullPath = fullPath; // This is an array
2322
- return patches.push(_err);
2323
- }
2324
-
2325
- // Deeply merge the member's contents onto the parent location
2326
- patches.push(specmap.mergeDeep(parent, toMerge));
2327
-
2328
- // Generate patches that migrate $ref values based on ContextTree information
2329
-
2330
- // remove ["allOf"], which will not be present when these patches are applied
2331
- var collapsedFullPath = fullPath.slice(0, -1);
2332
-
2333
- var absoluteRefPatches = generateAbsoluteRefPatches(toMerge, collapsedFullPath, {
2334
- getBaseUrlForNodePath: function getBaseUrlForNodePath(nodePath) {
2335
- return specmap.getContext([].concat(toConsumableArray_default()(fullPath), [i], toConsumableArray_default()(nodePath))).baseDoc;
2336
- },
2337
- specmap: specmap });
2338
-
2339
-
2340
- patches.push.apply(patches, toConsumableArray_default()(absoluteRefPatches));
2341
- });
2342
-
2343
- // Merge back the values from the original definition
2344
- patches.push(specmap.mergeDeep(parent, originalDefinitionObj));
2345
-
2346
- // If there was not an original $$ref value, make sure to remove
2347
- // any $$ref value that may exist from the result of `allOf` merges
2348
- if (!originalDefinitionObj.$$ref) {
2349
- patches.push(specmap.remove([].concat(parent, '$$ref')));
2350
- }
2351
-
2352
- return patches;
2353
- } });
2354
- // CONCATENATED MODULE: ./src/specmap/lib/parameters.js
2355
-
2356
-
2357
- /* harmony default export */ var lib_parameters = ({
2358
- key: 'parameters',
2359
- plugin: function plugin(parameters, key, fullPath, specmap, patch) {
2360
- if (is_array_default()(parameters) && parameters.length) {
2361
- var val = object_assign_default()([], parameters);
2362
- var opPath = fullPath.slice(0, -1);
2363
- var op = object_assign_default()({}, lib.getIn(specmap.spec, opPath));
2364
-
2365
- parameters.forEach(function (param, i) {
2366
- try {
2367
- val[i].default = specmap.parameterMacro(op, param);
2368
- }
2369
- catch (e) {
2370
- var err = new Error(e);
2371
- err.fullPath = fullPath;
2372
- return err;
2373
- }
2374
- });
2375
-
2376
- return lib.replace(fullPath, val);
2377
- }
2378
-
2379
- return lib.replace(fullPath, parameters);
2380
- } });
2381
- // CONCATENATED MODULE: ./src/specmap/lib/properties.js
2382
-
2383
-
2384
- /* harmony default export */ var lib_properties = ({
2385
- key: 'properties',
2386
- plugin: function plugin(properties, key, fullPath, specmap) {
2387
- var val = object_assign_default()({}, properties);
2388
-
2389
- for (var k in properties) {
2390
- try {
2391
- val[k].default = specmap.modelPropertyMacro(val[k]);
2392
- }
2393
- catch (e) {
2394
- var err = new Error(e);
2395
- err.fullPath = fullPath; // This is an array
2396
- return err;
2397
- }
2398
- }
2399
-
2400
- var patch = lib.replace(fullPath, val);
2401
-
2402
- return patch;
2403
- } });
2404
- // CONCATENATED MODULE: ./src/specmap/lib/context-tree.js
2405
- function ownKeys(object, enumerableOnly) {var keys = keys_default()(object);if (get_own_property_symbols_default.a) {var symbols = get_own_property_symbols_default()(object);if (enumerableOnly) symbols = symbols.filter(function (sym) {return get_own_property_descriptor_default()(object, sym).enumerable;});keys.push.apply(keys, symbols);}return keys;}function _objectSpread(target) {for (var i = 1; i < arguments.length; i++) {var source = arguments[i] != null ? arguments[i] : {};if (i % 2) {ownKeys(Object(source), true).forEach(function (key) {defineProperty_default()(target, key, source[key]);});} else if (get_own_property_descriptors_default.a) {define_properties_default()(target, get_own_property_descriptors_default()(source));} else {ownKeys(Object(source)).forEach(function (key) {define_property_default()(target, key, get_own_property_descriptor_default()(source, key));});}}return target;}var context_tree_ContextTree = /*#__PURE__*/function () {
2406
- function ContextTree(value) {classCallCheck_default()(this, ContextTree);
2407
- this.root = createNode(value || {});
2408
- }createClass_default()(ContextTree, [{ key: "set", value: function set(
2409
-
2410
- path, value) {
2411
- var parent = this.getParent(path, true);
2412
- if (!parent) {
2413
- updateNode(this.root, value, null);
2414
- return;
2415
- }
2416
-
2417
- var key = path[path.length - 1];
2418
- var children = parent.children;
2419
- if (children[key]) {
2420
- updateNode(children[key], value, parent);
2421
- return;
2422
- }
2423
-
2424
- children[key] = createNode(value, parent);
2425
- }
2426
-
2427
- // Get the "best" node (node or nearest parent) and return its value.
2428
- }, { key: "get", value: function get(path) {
2429
- path = path || [];
2430
-
2431
- if (path.length < 1) {
2432
- return this.root.value;
2433
- }
2434
-
2435
- var branch = this.root;
2436
- var child;
2437
- var token;
2438
- for (var i = 0; i < path.length; i++) {
2439
- token = path[i];
2440
- child = branch.children;
2441
- if (!child[token]) {
2442
- break;
2443
- }
2444
- branch = child[token];
2445
- }
2446
-
2447
- return branch && branch.protoValue;
2448
- } }, { key: "getParent", value: function getParent(
2449
-
2450
- path, ensureExists) {
2451
- if (!path || path.length < 1) {
2452
- return null;
2453
- }
2454
-
2455
- if (path.length < 2) {
2456
- return this.root;
2457
- }
2458
-
2459
- return path.slice(0, -1).reduce(function (branch, token) {
2460
- if (!branch) {
2461
- return branch;
2462
- }
2463
-
2464
- var children = branch.children;
2465
-
2466
- if (!children[token] && ensureExists) {
2467
- children[token] = createNode(null, branch);
2468
- }
2469
-
2470
- return children[token];
2471
- }, this.root);
2472
- } }]);return ContextTree;}();
2473
-
2474
-
2475
- // =========================
2476
- // Utilities
2477
- // =========================
2478
-
2479
- function createNode(value, parent) {
2480
- return updateNode({ children: {} }, value, parent);
2481
- }
2482
-
2483
- function updateNode(node, value, parent) {
2484
- node.value = value || {};
2485
- node.protoValue = parent ? _objectSpread(_objectSpread({},
2486
- parent.protoValue), node.value) :
2487
- node.value;
2488
-
2489
- keys_default()(node.children).forEach(function (prop) {
2490
- var child = node.children[prop];
2491
- node.children[prop] = updateNode(child, child.value, node);
2492
- });
2493
-
2494
- return node;
2495
- }
2496
- // CONCATENATED MODULE: ./src/specmap/index.js
2497
- function specmap_createForOfIteratorHelper(o, allowArrayLike) {var it;if (typeof symbol_default.a === "undefined" || o[iterator_default.a] == null) {if (is_array_default()(o) || (it = specmap_unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") {if (it) o = it;var i = 0;var F = function F() {};return { s: F, n: function n() {if (i >= o.length) return { done: true };return { done: false, value: o[i++] };}, e: function e(_e) {throw _e;}, f: F };}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");}var normalCompletion = true,didErr = false,err;return { s: function s() {it = get_iterator_default()(o);}, n: function n() {var step = it.next();normalCompletion = step.done;return step;}, e: function e(_e2) {didErr = true;err = _e2;}, f: function f() {try {if (!normalCompletion && it.return != null) it.return();} finally {if (didErr) throw err;}} };}function specmap_unsupportedIterableToArray(o, minLen) {if (!o) return;if (typeof o === "string") return specmap_arrayLikeToArray(o, minLen);var n = Object.prototype.toString.call(o).slice(8, -1);if (n === "Object" && o.constructor) n = o.constructor.name;if (n === "Map" || n === "Set") return from_default()(o);if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return specmap_arrayLikeToArray(o, minLen);}function specmap_arrayLikeToArray(arr, len) {if (len == null || len > arr.length) len = arr.length;for (var i = 0, arr2 = new Array(len); i < len; i++) {arr2[i] = arr[i];}return arr2;}
2498
-
2499
-
2500
-
2501
-
2502
-
2503
-
2504
-
2505
-
2506
-
2507
- var HARD_LIMIT = 100;var
2508
-
2509
- specmap_SpecMap = /*#__PURE__*/function () {
2510
- function SpecMap(opts) {var _this = this;classCallCheck_default()(this, SpecMap);
2511
- object_assign_default()(this, {
2512
- spec: '',
2513
- debugLevel: 'info',
2514
- plugins: [],
2515
- pluginHistory: {},
2516
- errors: [],
2517
- mutations: [],
2518
- promisedPatches: [],
2519
- state: {},
2520
- patches: [],
2521
- context: {},
2522
- contextTree: new context_tree_ContextTree(),
2523
- showDebug: false,
2524
- allPatches: [], // only populated if showDebug is true
2525
- pluginProp: 'specMap',
2526
- libMethods: object_assign_default()(create_default()(this), lib, {
2527
- getInstance: function getInstance() {return _this;} }),
2528
-
2529
- allowMetaPatches: false },
2530
- opts);
2531
-
2532
- // Lib methods bound
2533
- this.get = this._get.bind(this);
2534
- this.getContext = this._getContext.bind(this);
2535
- this.hasRun = this._hasRun.bind(this);
2536
-
2537
- this.wrappedPlugins = this.plugins.
2538
- map(this.wrapPlugin.bind(this)).
2539
- filter(lib.isFunction);
2540
-
2541
- // Initial patch(s)
2542
- this.patches.push(lib.add([], this.spec));
2543
- this.patches.push(lib.context([], this.context));
2544
- this.updatePatches(this.patches);
2545
- }createClass_default()(SpecMap, [{ key: "debug", value: function debug(
2546
-
2547
- level) {
2548
- if (this.debugLevel === level) {var _console;for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {args[_key - 1] = arguments[_key];}
2549
- (_console = console).log.apply(_console, args); // eslint-disable-line no-console
2550
- }
2551
- } }, { key: "verbose", value: function verbose(
2552
-
2553
- header) {
2554
- if (this.debugLevel === 'verbose') {var _console2;for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {args[_key2 - 1] = arguments[_key2];}
2555
- (_console2 = console).log.apply(_console2, ["[".concat(header, "] ")].concat(args)); // eslint-disable-line no-console
2556
- }
2557
- } }, { key: "wrapPlugin", value: function wrapPlugin(
2558
-
2559
- plugin, name) {
2560
- var pathDiscriminator = this.pathDiscriminator;
2561
- var ctx = null;
2562
- var fn;
2563
-
2564
- if (plugin[this.pluginProp]) {
2565
- ctx = plugin;
2566
- fn = plugin[this.pluginProp];
2567
- } else
2568
- if (lib.isFunction(plugin)) {
2569
- fn = plugin;
2570
- } else
2571
- if (lib.isObject(plugin)) {
2572
- fn = createKeyBasedPlugin(plugin);
2573
- }
2574
-
2575
- return object_assign_default()(fn.bind(ctx), {
2576
- pluginName: plugin.name || name,
2577
- isGenerator: lib.isGenerator(fn) });
2578
-
2579
-
2580
- // Expected plugin interface: {key: string, plugin: fn*}
2581
- // This traverses depth-first and immediately applies yielded patches.
2582
- // This strategy should work well for most plugins (including the built-ins).
2583
- // We might consider making this (traversing & application) configurable later.
2584
- function createKeyBasedPlugin(pluginObj) {
2585
- var isSubPath = function isSubPath(path, tested) {
2586
- if (!is_array_default()(path)) {
2587
- return true;
2588
- }
2589
-
2590
- return path.every(function (val, i) {
2591
- return val === tested[i];
2592
- });
2593
- };
2594
-
2595
- return /*#__PURE__*/regenerator_default.a.mark(function _callee(patches, specmap) {var _marked, refCache, _iterator, _step, patch,
2596
-
2597
-
2598
-
2599
-
2600
-
2601
-
2602
- traverse;return regenerator_default.a.wrap(function _callee$(_context2) {while (1) {switch (_context2.prev = _context2.next) {case 0:traverse = function _traverse(obj, path, patch) {var parentIndex, parent, indexOfFirstProperties, isRootProperties, traversed, _i, _Object$keys, key, val, updatedPath, isObj, objRef, isWithinPathDiscriminator;return regenerator_default.a.wrap(function traverse$(_context) {while (1) {switch (_context.prev = _context.next) {case 0:if (
2603
- lib.isObject(obj)) {_context.next = 6;break;}if (!(
2604
- pluginObj.key === path[path.length - 1])) {_context.next = 4;break;}_context.next = 4;
2605
- return pluginObj.plugin(obj, pluginObj.key, path, specmap);case 4:_context.next = 30;break;case 6:
2606
-
2607
-
2608
-
2609
- parentIndex = path.length - 1;
2610
- parent = path[parentIndex];
2611
- indexOfFirstProperties = path.indexOf('properties');
2612
- isRootProperties = parent === 'properties' && parentIndex === indexOfFirstProperties;
2613
- traversed = specmap.allowMetaPatches && refCache[obj.$$ref];_i = 0, _Object$keys =
2614
-
2615
- keys_default()(obj);case 12:if (!(_i < _Object$keys.length)) {_context.next = 30;break;}key = _Object$keys[_i];
2616
- val = obj[key];
2617
- updatedPath = path.concat(key);
2618
- isObj = lib.isObject(val);
2619
- objRef = obj.$$ref;if (
2620
-
2621
- traversed) {_context.next = 22;break;}if (!
2622
- isObj) {_context.next = 22;break;}
2623
- // Only store the ref if it exists
2624
- if (specmap.allowMetaPatches && objRef) {
2625
- refCache[objRef] = true;
2626
- }
2627
- return _context.delegateYield(traverse(val, updatedPath, patch), "t0", 22);case 22:if (!(
2628
-
2629
-
2630
-
2631
- !isRootProperties && key === pluginObj.key)) {_context.next = 27;break;}
2632
- isWithinPathDiscriminator = isSubPath(pathDiscriminator, path);if (!(
2633
- !pathDiscriminator || isWithinPathDiscriminator)) {_context.next = 27;break;}_context.next = 27;
2634
- return pluginObj.plugin(val, key, updatedPath, specmap, patch);case 27:_i++;_context.next = 12;break;case 30:case "end":return _context.stop();}}}, _marked);};_marked = /*#__PURE__*/regenerator_default.a.mark(traverse);refCache = {};_iterator = specmap_createForOfIteratorHelper(patches.filter(lib.isAdditiveMutation));_context2.prev = 4;_iterator.s();case 6:if ((_step = _iterator.n()).done) {_context2.next = 11;break;}patch = _step.value;return _context2.delegateYield(traverse(patch.value, patch.path, patch), "t0", 9);case 9:_context2.next = 6;break;case 11:_context2.next = 16;break;case 13:_context2.prev = 13;_context2.t1 = _context2["catch"](4);_iterator.e(_context2.t1);case 16:_context2.prev = 16;_iterator.f();return _context2.finish(16);case 19:case "end":return _context2.stop();}}}, _callee, null, [[4, 13, 16, 19]]);});
2635
-
2636
-
2637
-
2638
-
2639
-
2640
-
2641
- }
2642
- } }, { key: "nextPlugin", value: function nextPlugin()
2643
-
2644
- {var _this2 = this;
2645
- // Array.prototype.find doesn't work in IE 11 :(
2646
- return find_default()(this.wrappedPlugins, function (plugin) {
2647
- var mutations = _this2.getMutationsForPlugin(plugin);
2648
- return mutations.length > 0;
2649
- });
2650
- } }, { key: "nextPromisedPatch", value: function nextPromisedPatch()
2651
-
2652
- {
2653
- if (this.promisedPatches.length > 0) {
2654
- return promise_default.a.race(this.promisedPatches.map(function (patch) {return patch.value;}));
2655
- }
2656
- } }, { key: "getPluginHistory", value: function getPluginHistory(
2657
-
2658
- plugin) {
2659
- var name = this.getPluginName(plugin);
2660
- return this.pluginHistory[name] || [];
2661
- } }, { key: "getPluginRunCount", value: function getPluginRunCount(
2662
-
2663
- plugin) {
2664
- return this.getPluginHistory(plugin).length;
2665
- } }, { key: "getPluginHistoryTip", value: function getPluginHistoryTip(
2666
-
2667
- plugin) {
2668
- var history = this.getPluginHistory(plugin);
2669
- var val = history && history[history.length - 1];
2670
- return val || {};
2671
- } }, { key: "getPluginMutationIndex", value: function getPluginMutationIndex(
2672
-
2673
- plugin) {
2674
- var mi = this.getPluginHistoryTip(plugin).mutationIndex;
2675
- return typeof mi !== 'number' ? -1 : mi;
2676
- } }, { key: "getPluginName", value: function getPluginName(
2677
-
2678
- plugin) {
2679
- return plugin.pluginName;
2680
- } }, { key: "updatePluginHistory", value: function updatePluginHistory(
2681
-
2682
- plugin, val) {
2683
- var name = this.getPluginName(plugin);
2684
- var history = this.pluginHistory[name] = this.pluginHistory[name] || [];
2685
- history.push(val);
2686
- } }, { key: "updatePatches", value: function updatePatches(
2687
-
2688
- patches, plugin) {var _this3 = this;
2689
- lib.normalizeArray(patches).forEach(function (patch) {
2690
- if (patch instanceof Error) {
2691
- _this3.errors.push(patch);
2692
- return;
2693
- }
2694
-
2695
- try {
2696
- if (!lib.isObject(patch)) {
2697
- _this3.debug('updatePatches', 'Got a non-object patch', patch);
2698
- return;
2699
- }
2700
-
2701
- if (_this3.showDebug) {
2702
- _this3.allPatches.push(patch);
2703
- }
2704
-
2705
- if (lib.isPromise(patch.value)) {
2706
- _this3.promisedPatches.push(patch);
2707
- _this3.promisedPatchThen(patch);
2708
- return;
2709
- }
2710
-
2711
- if (lib.isContextPatch(patch)) {
2712
- _this3.setContext(patch.path, patch.value);
2713
- return;
2714
- }
2715
-
2716
- if (lib.isMutation(patch)) {
2717
- _this3.updateMutations(patch);
2718
- return;
2719
- }
2720
- }
2721
- catch (e) {
2722
- console.error(e); // eslint-disable-line no-console
2723
- _this3.errors.push(e);
2724
- }
2725
- });
2726
- } }, { key: "updateMutations", value: function updateMutations(
2727
-
2728
- patch) {
2729
- if (typeof_default()(patch.value) === 'object' && !is_array_default()(patch.value) && this.allowMetaPatches) {
2730
- patch.value = object_assign_default()({}, patch.value);
2731
- }
2732
-
2733
- var result = lib.applyPatch(this.state, patch, { allowMetaPatches: this.allowMetaPatches });
2734
- if (result) {
2735
- this.mutations.push(patch);
2736
- this.state = result;
2737
- }
2738
- } }, { key: "removePromisedPatch", value: function removePromisedPatch(
2739
-
2740
- patch) {
2741
- var index = this.promisedPatches.indexOf(patch);
2742
- if (index < 0) {
2743
- this.debug('Tried to remove a promisedPatch that isn\'t there!');
2744
- return;
2745
- }
2746
- this.promisedPatches.splice(index, 1);
2747
- } }, { key: "promisedPatchThen", value: function promisedPatchThen(
2748
-
2749
- patch) {var _this4 = this;
2750
- var value = patch.value = patch.value.
2751
- then(function (val) {
2752
- var promisedPatch = object_assign_default()({}, patch, { value: val });
2753
- _this4.removePromisedPatch(patch);
2754
- _this4.updatePatches(promisedPatch);
2755
- }).
2756
- catch(function (e) {
2757
- _this4.removePromisedPatch(patch);
2758
- _this4.updatePatches(e);
2759
- });
2760
- return value;
2761
- } }, { key: "getMutations", value: function getMutations(
2762
-
2763
- from, to) {
2764
- from = from || 0;
2765
- if (typeof to !== 'number') {
2766
- to = this.mutations.length;
2767
- }
2768
- return this.mutations.slice(from, to);
2769
- } }, { key: "getCurrentMutations", value: function getCurrentMutations()
2770
-
2771
- {
2772
- return this.getMutationsForPlugin(this.getCurrentPlugin());
2773
- } }, { key: "getMutationsForPlugin", value: function getMutationsForPlugin(
2774
-
2775
- plugin) {
2776
- var tip = this.getPluginMutationIndex(plugin);
2777
- return this.getMutations(tip + 1);
2778
- } }, { key: "getCurrentPlugin", value: function getCurrentPlugin()
2779
-
2780
- {
2781
- return this.currentPlugin;
2782
- } }, { key: "getPatchesOfType", value: function getPatchesOfType(
2783
-
2784
- patches, fn) {
2785
- return patches.filter(fn);
2786
- } }, { key: "getLib", value: function getLib()
2787
-
2788
- {
2789
- return this.libMethods;
2790
- } }, { key: "_get", value: function _get(
2791
-
2792
- path) {
2793
- return lib.getIn(this.state, path);
2794
- } }, { key: "_getContext", value: function _getContext(
2795
-
2796
- path) {
2797
- return this.contextTree.get(path);
2798
- } }, { key: "setContext", value: function setContext(
2799
-
2800
- path, value) {
2801
- return this.contextTree.set(path, value);
2802
- } }, { key: "_hasRun", value: function _hasRun(
2803
-
2804
- count) {
2805
- var times = this.getPluginRunCount(this.getCurrentPlugin());
2806
- return times > (count || 0);
2807
- } }, { key: "_clone", value: function _clone(
2808
-
2809
- obj) {
2810
- // For debugging only
2811
- return JSON.parse(stringify_default()(obj));
2812
- } }, { key: "dispatch", value: function dispatch()
2813
-
2814
- {var _this5 = this;
2815
- var that = this;
2816
- var plugin = this.nextPlugin();
2817
-
2818
- if (!plugin) {
2819
- var nextPromise = this.nextPromisedPatch();
2820
- if (nextPromise) {
2821
- return nextPromise.
2822
- then(function () {return _this5.dispatch();}).
2823
- catch(function () {return _this5.dispatch();});
2824
- }
2825
-
2826
- // We're done!
2827
- var result = { spec: this.state, errors: this.errors };
2828
- if (this.showDebug) {
2829
- result.patches = this.allPatches;
2830
- }
2831
- return promise_default.a.resolve(result);
2832
- }
2833
-
2834
- // Makes sure plugin isn't running an endless loop
2835
- that.pluginCount = that.pluginCount || {};
2836
- that.pluginCount[plugin] = (that.pluginCount[plugin] || 0) + 1;
2837
- if (that.pluginCount[plugin] > HARD_LIMIT) {
2838
- return promise_default.a.resolve({
2839
- spec: that.state,
2840
- errors: that.errors.concat(new Error("We've reached a hard limit of ".concat(HARD_LIMIT, " plugin runs"))) });
2841
-
2842
- }
2843
-
2844
- // A different plugin runs, wait for all promises to resolve, then retry
2845
- if (plugin !== this.currentPlugin && this.promisedPatches.length) {
2846
- var promises = this.promisedPatches.map(function (p) {return p.value;});
2847
-
2848
- // Waits for all to settle instead of Promise.all which stops on rejection
2849
- return promise_default.a.all(promises.map(function (promise) {
2850
- return promise.then(noop_default.a, noop_default.a);
2851
- })).then(function () {return _this5.dispatch();});
2852
- }
2853
-
2854
- // Ok, run the plugin
2855
- return executePlugin();
2856
-
2857
- function executePlugin() {
2858
- that.currentPlugin = plugin;
2859
- var mutations = that.getCurrentMutations();
2860
- var lastMutationIndex = that.mutations.length - 1;
2861
-
2862
- try {
2863
- if (plugin.isGenerator) {var _iterator2 = specmap_createForOfIteratorHelper(
2864
- plugin(mutations, that.getLib())),_step2;try {for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {var yieldedPatches = _step2.value;
2865
- updatePatches(yieldedPatches);
2866
- }} catch (err) {_iterator2.e(err);} finally {_iterator2.f();}
2867
- } else
2868
- {
2869
- var newPatches = plugin(mutations, that.getLib());
2870
- updatePatches(newPatches);
2871
- }
2872
- }
2873
- catch (e) {
2874
- console.error(e); // eslint-disable-line no-console
2875
- updatePatches([object_assign_default()(create_default()(e), { plugin: plugin })]);
2876
- } finally
2877
- {
2878
- that.updatePluginHistory(plugin, { mutationIndex: lastMutationIndex });
2879
- }
2880
-
2881
- return that.dispatch();
2882
- }
2883
-
2884
- function updatePatches(patches) {
2885
- if (patches) {
2886
- patches = lib.fullyNormalizeArray(patches);
2887
- that.updatePatches(patches, plugin);
2888
- }
2889
- }
2890
- } }]);return SpecMap;}();
2891
-
2892
-
2893
- function mapSpec(opts) {
2894
- return new specmap_SpecMap(opts).dispatch();
2895
- }
2896
-
2897
- var plugins = { refs: refs, allOf: all_of, parameters: lib_parameters, properties: lib_properties };
2898
-
2899
- // EXTERNAL MODULE: external "lodash/isObject"
2900
- var isObject_ = __webpack_require__(38);
2901
- var isObject_default = /*#__PURE__*/__webpack_require__.n(isObject_);
2902
-
2903
- // CONCATENATED MODULE: ./src/helpers.js
2904
- function helpers_createForOfIteratorHelper(o, allowArrayLike) {var it;if (typeof symbol_default.a === "undefined" || o[iterator_default.a] == null) {if (is_array_default()(o) || (it = helpers_unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") {if (it) o = it;var i = 0;var F = function F() {};return { s: F, n: function n() {if (i >= o.length) return { done: true };return { done: false, value: o[i++] };}, e: function e(_e) {throw _e;}, f: F };}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");}var normalCompletion = true,didErr = false,err;return { s: function s() {it = get_iterator_default()(o);}, n: function n() {var step = it.next();normalCompletion = step.done;return step;}, e: function e(_e2) {didErr = true;err = _e2;}, f: function f() {try {if (!normalCompletion && it.return != null) it.return();} finally {if (didErr) throw err;}} };}function helpers_unsupportedIterableToArray(o, minLen) {if (!o) return;if (typeof o === "string") return helpers_arrayLikeToArray(o, minLen);var n = Object.prototype.toString.call(o).slice(8, -1);if (n === "Object" && o.constructor) n = o.constructor.name;if (n === "Map" || n === "Set") return from_default()(o);if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return helpers_arrayLikeToArray(o, minLen);}function helpers_arrayLikeToArray(arr, len) {if (len == null || len > arr.length) len = arr.length;for (var i = 0, arr2 = new Array(len); i < len; i++) {arr2[i] = arr[i];}return arr2;}
2905
-
2906
-
2907
- var toLower = function toLower(str) {return String.prototype.toLowerCase.call(str);};
2908
- var escapeString = function escapeString(str) {
2909
- return str.replace(/[^\w]/gi, '_');
2910
- };
2911
-
2912
- // Spec version detection
2913
- function isOAS3(spec) {
2914
- var oasVersion = spec.openapi;
2915
- if (!oasVersion) {
2916
- return false;
2917
- }
2918
-
2919
- return startsWith_default()(oasVersion, '3');
2920
- }
2921
-
2922
- function isSwagger2(spec) {
2923
- var swaggerVersion = spec.swagger;
2924
- if (!swaggerVersion) {
2925
- return false;
2926
- }
2927
-
2928
- return startsWith_default()(swaggerVersion, '2');
2929
- }
2930
-
2931
- // Strategy for determining operationId
2932
- function opId(operation, pathName) {var method = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '';var _ref = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {},v2OperationIdCompatibilityMode = _ref.v2OperationIdCompatibilityMode;
2933
- if (!operation || typeof_default()(operation) !== 'object') {
2934
- return null;
2935
- }
2936
- var idWithoutWhitespace = (operation.operationId || '').replace(/\s/g, '');
2937
- if (idWithoutWhitespace.length) {
2938
- return escapeString(operation.operationId);
2939
- }
2940
- return idFromPathMethod(pathName, method, { v2OperationIdCompatibilityMode: v2OperationIdCompatibilityMode });
2941
- }
2942
-
2943
-
2944
- // Create a generated operationId from pathName + method
2945
- function idFromPathMethod(pathName, method) {var _ref2 = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {},v2OperationIdCompatibilityMode = _ref2.v2OperationIdCompatibilityMode;
2946
- if (v2OperationIdCompatibilityMode) {
2947
- var res = "".concat(method.toLowerCase(), "_").concat(pathName).
2948
- replace(/[\s!@#$%^&*()_+=[{\]};:<>|./?,\\'""-]/g, '_');
2949
-
2950
- res = res || "".concat(pathName.substring(1), "_").concat(method);
2951
-
2952
- return res.
2953
- replace(/((_){2,})/g, '_').
2954
- replace(/^(_)*/g, '').
2955
- replace(/([_])*$/g, '');
2956
- }
2957
- return "".concat(toLower(method)).concat(escapeString(pathName));
2958
- }
2959
-
2960
- function legacyIdFromPathMethod(pathName, method) {
2961
- return "".concat(toLower(method), "-").concat(pathName);
2962
- }
2963
-
2964
- // Get the operation, based on operationId ( just return the object, no inheritence )
2965
- function getOperationRaw(spec, id) {
2966
- if (!spec || !spec.paths) {
2967
- return null;
2968
- }
2969
-
2970
-
2971
- return findOperation(spec, function (_ref3) {var pathName = _ref3.pathName,method = _ref3.method,operation = _ref3.operation;
2972
- if (!operation || typeof_default()(operation) !== 'object') {
2973
- return false;
2974
- }
2975
-
2976
- var rawOperationId = operation.operationId; // straight from the source
2977
- var operationId = opId(operation, pathName, method);
2978
- var legacyOperationId = legacyIdFromPathMethod(pathName, method);
2979
-
2980
- return [operationId, legacyOperationId, rawOperationId].
2981
- some(function (val) {return val && val === id;});
2982
- });
2983
- }
2984
-
2985
- // Will stop iterating over the operations and return the operationObj
2986
- // as soon as predicate returns true
2987
- function findOperation(spec, predicate) {
2988
- return eachOperation(spec, predicate, true) || null;
2989
- }
2990
-
2991
- // iterate over each operation, and fire a callback with details
2992
- // `find=true` will stop iterating, when the cb returns truthy
2993
- function eachOperation(spec, cb, find) {
2994
- if (!spec || typeof_default()(spec) !== 'object' || !spec.paths || typeof_default()(spec.paths) !== 'object') {
2995
- return null;
2996
- }var
2997
-
2998
- paths = spec.paths;
2999
-
3000
- // Iterate over the spec, collecting operations
3001
- for (var pathName in paths) {
3002
- for (var method in paths[pathName]) {
3003
- if (method.toUpperCase() === 'PARAMETERS') {
3004
- continue;
3005
- }
3006
- var operation = paths[pathName][method];
3007
- if (!operation || typeof_default()(operation) !== 'object') {
3008
- continue;
3009
- }
3010
-
3011
- var operationObj = {
3012
- spec: spec,
3013
- pathName: pathName,
3014
- method: method.toUpperCase(),
3015
- operation: operation };
3016
-
3017
- var cbValue = cb(operationObj);
3018
-
3019
- if (find && cbValue) {
3020
- return operationObj;
3021
- }
3022
- }
3023
- }
3024
- }
3025
-
3026
- // REVIEW: OAS3: identify normalization steps that need changes
3027
- // ...maybe create `normalizeOAS3`?
3028
-
3029
- function normalizeSwagger(parsedSpec) {var
3030
- spec = parsedSpec.spec;var
3031
- paths = spec.paths;
3032
- var map = {};
3033
-
3034
- if (!paths || spec.$$normalized) {
3035
- return parsedSpec;
3036
- }
3037
-
3038
- for (var pathName in paths) {
3039
- var path = paths[pathName];
3040
-
3041
- if (!isObject_default()(path)) {
3042
- continue;
3043
- }
3044
-
3045
- var pathParameters = path.parameters;var _loop = function _loop(
3046
-
3047
- method) {
3048
- var operation = path[method];
3049
- if (!isObject_default()(operation)) {
3050
- return "continue";
3051
- }
3052
-
3053
- var oid = opId(operation, pathName, method);
3054
-
3055
- if (oid) {
3056
- if (map[oid]) {
3057
- map[oid].push(operation);
3058
- } else
3059
- {
3060
- map[oid] = [operation];
3061
- }
3062
-
3063
- var opList = map[oid];
3064
- if (opList.length > 1) {
3065
- opList.forEach(function (o, i) {
3066
- o.__originalOperationId = o.__originalOperationId || o.operationId;
3067
- o.operationId = "".concat(oid).concat(i + 1);
3068
- });
3069
- } else
3070
- if (typeof operation.operationId !== 'undefined') {
3071
- // Ensure we always add the normalized operation ID if one already exists
3072
- // ( potentially different, given that we normalize our IDs)
3073
- // ... _back_ to the spec. Otherwise, they might not line up
3074
- var obj = opList[0];
3075
- obj.__originalOperationId = obj.__originalOperationId || operation.operationId;
3076
- obj.operationId = oid;
3077
- }
3078
- }
3079
-
3080
- if (method !== 'parameters') {
3081
- // Add inherited consumes, produces, parameters, securities
3082
- var inheritsList = [];
3083
- var toBeInherit = {};
3084
-
3085
- // Global-levels
3086
- for (var key in spec) {
3087
- if (key === 'produces' || key === 'consumes' || key === 'security') {
3088
- toBeInherit[key] = spec[key];
3089
- inheritsList.push(toBeInherit);
3090
- }
3091
- }
3092
-
3093
- // Path-levels
3094
- if (pathParameters) {
3095
- toBeInherit.parameters = pathParameters;
3096
- inheritsList.push(toBeInherit);
3097
- }
3098
-
3099
- if (inheritsList.length) {var _iterator = helpers_createForOfIteratorHelper(
3100
- inheritsList),_step;try {for (_iterator.s(); !(_step = _iterator.n()).done;) {var inherits = _step.value;
3101
- for (var inheritName in inherits) {
3102
- if (!operation[inheritName]) {
3103
- operation[inheritName] = inherits[inheritName];
3104
- } else
3105
- if (inheritName === 'parameters') {var _iterator2 = helpers_createForOfIteratorHelper(
3106
- inherits[inheritName]),_step2;try {var _loop2 = function _loop2() {var param = _step2.value;
3107
- var exists = operation[inheritName].some(function (opParam) {
3108
- return opParam.name && opParam.name === param.name ||
3109
- opParam.$ref && opParam.$ref === param.$ref ||
3110
- opParam.$$ref && opParam.$$ref === param.$$ref ||
3111
- opParam === param;
3112
- });
3113
-
3114
- if (!exists) {
3115
- operation[inheritName].push(param);
3116
- }};for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {_loop2();
3117
- }} catch (err) {_iterator2.e(err);} finally {_iterator2.f();}
3118
- }
3119
- }
3120
- }} catch (err) {_iterator.e(err);} finally {_iterator.f();}
3121
- }
3122
- }};for (var method in path) {var _ret = _loop(method);if (_ret === "continue") continue;
3123
- }
3124
- }
3125
-
3126
- spec.$$normalized = true;
3127
-
3128
- return parsedSpec;
3129
- }
3130
- // CONCATENATED MODULE: ./src/resolver.js
3131
-
3132
-
3133
-
3134
-
3135
-
3136
- function makeFetchJSON(http) {var opts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};var
3137
- requestInterceptor = opts.requestInterceptor,responseInterceptor = opts.responseInterceptor;
3138
- // Set credentials with 'http.withCredentials' value
3139
- var credentials = http.withCredentials ? 'include' : 'same-origin';
3140
- return function (docPath) {
3141
- return http({
3142
- url: docPath,
3143
- loadSpec: true,
3144
- requestInterceptor: requestInterceptor,
3145
- responseInterceptor: responseInterceptor,
3146
- headers: {
3147
- Accept: ACCEPT_HEADER_VALUE_FOR_DOCUMENTS },
3148
-
3149
- credentials: credentials }).
3150
-
3151
- then(function (res) {
3152
- return res.body;
3153
- });
3154
- };
3155
- }
3156
-
3157
- // Wipe out the http cache
3158
- function resolver_clearCache() {
3159
- plugins.refs.clearCache();
3160
- }
3161
-
3162
- function resolve(obj) {var
3163
-
3164
- fetch =
3165
-
3166
-
3167
- obj.fetch,spec = obj.spec,url = obj.url,mode = obj.mode,_obj$allowMetaPatches = obj.allowMetaPatches,allowMetaPatches = _obj$allowMetaPatches === void 0 ? true : _obj$allowMetaPatches,pathDiscriminator = obj.pathDiscriminator,modelPropertyMacro = obj.modelPropertyMacro,parameterMacro = obj.parameterMacro,requestInterceptor = obj.requestInterceptor,responseInterceptor = obj.responseInterceptor,skipNormalization = obj.skipNormalization,useCircularStructures = obj.useCircularStructures;var
3168
-
3169
- http = obj.http,baseDoc = obj.baseDoc;
3170
-
3171
- // @TODO Swagger-UI uses baseDoc instead of url, this is to allow both
3172
- // need to fix and pick one.
3173
- baseDoc = baseDoc || url;
3174
-
3175
- // Provide a default fetch implementation
3176
- // TODO fetch should be removed, and http used instead
3177
- http = fetch || http || http_http;
3178
-
3179
- if (!spec) {
3180
- return makeFetchJSON(http, { requestInterceptor: requestInterceptor, responseInterceptor: responseInterceptor })(baseDoc).then(doResolve);
3181
- }
3182
-
3183
- return doResolve(spec);
3184
-
3185
- function doResolve(_spec) {
3186
- if (baseDoc) {
3187
- plugins.refs.docCache[baseDoc] = _spec;
3188
- }
3189
-
3190
- // Build a json-fetcher ( ie: give it a URL and get json out )
3191
- plugins.refs.fetchJSON = makeFetchJSON(http, { requestInterceptor: requestInterceptor, responseInterceptor: responseInterceptor });
3192
-
3193
- var plugs = [plugins.refs];
3194
-
3195
- if (typeof parameterMacro === 'function') {
3196
- plugs.push(plugins.parameters);
3197
- }
3198
-
3199
- if (typeof modelPropertyMacro === 'function') {
3200
- plugs.push(plugins.properties);
3201
- }
3202
-
3203
- if (mode !== 'strict') {
3204
- plugs.push(plugins.allOf);
3205
- }
3206
-
3207
- // mapSpec is where the hard work happens, see https://github.com/swagger-api/specmap for more details
3208
- return mapSpec({
3209
- spec: _spec,
3210
- context: { baseDoc: baseDoc },
3211
- plugins: plugs,
3212
- allowMetaPatches: allowMetaPatches, // allows adding .meta patches, which include adding `$$ref`s to the spec
3213
- pathDiscriminator: pathDiscriminator, // for lazy resolution
3214
- parameterMacro: parameterMacro,
3215
- modelPropertyMacro: modelPropertyMacro,
3216
- useCircularStructures: useCircularStructures }).
3217
- then(skipNormalization ? /*#__PURE__*/function () {var _ref = asyncToGenerator_default()( /*#__PURE__*/regenerator_default.a.mark(function _callee(a) {return regenerator_default.a.wrap(function _callee$(_context) {while (1) {switch (_context.prev = _context.next) {case 0:return _context.abrupt("return", a);case 1:case "end":return _context.stop();}}}, _callee);}));return function (_x) {return _ref.apply(this, arguments);};}() : normalizeSwagger);
3218
- }
3219
- }
3220
- // EXTERNAL MODULE: external "lodash/get"
3221
- var external_lodash_get_ = __webpack_require__(16);
3222
- var external_lodash_get_default = /*#__PURE__*/__webpack_require__.n(external_lodash_get_);
3223
-
3224
- // CONCATENATED MODULE: ./src/subtree-resolver/index.js
3225
- function subtree_resolver_ownKeys(object, enumerableOnly) {var keys = keys_default()(object);if (get_own_property_symbols_default.a) {var symbols = get_own_property_symbols_default()(object);if (enumerableOnly) symbols = symbols.filter(function (sym) {return get_own_property_descriptor_default()(object, sym).enumerable;});keys.push.apply(keys, symbols);}return keys;}function subtree_resolver_objectSpread(target) {for (var i = 1; i < arguments.length; i++) {var source = arguments[i] != null ? arguments[i] : {};if (i % 2) {subtree_resolver_ownKeys(Object(source), true).forEach(function (key) {defineProperty_default()(target, key, source[key]);});} else if (get_own_property_descriptors_default.a) {define_properties_default()(target, get_own_property_descriptors_default()(source));} else {subtree_resolver_ownKeys(Object(source)).forEach(function (key) {define_property_default()(target, key, get_own_property_descriptor_default()(source, key));});}}return target;} // The subtree resolver is a higher-level interface that allows you to
3226
- // get the same result that you would from `Swagger.resolve`, but focuses on
3227
- // a subtree of your object.
3228
- //
3229
- // It makes several assumptions that allow you to think less about what resolve,
3230
- // specmap, and normalizeSwagger are doing: if this is not suitable for you,
3231
- // you can emulate `resolveSubtree`'s behavior by talking to the traditional
3232
- // resolver directly.
3233
- //
3234
- // By providing a top-level `obj` and a `path` to resolve within, the subtree
3235
- // at `path` will be resolved and normalized in the context of your top-level
3236
- // `obj`. You'll get the resolved subtree you're interest in as a return value
3237
- // (or, you can use `returnEntireTree` to get everything back).
3238
- //
3239
- // This is useful for cases where resolving your entire object is unnecessary
3240
- // and/or non-performant; we use this interface for lazily resolving operations
3241
- // and models in Swagger-UI, which allows us to handle larger definitions.
3242
- //
3243
- // It's likely that Swagger-Client will rely entirely on lazy resolving in
3244
- // future versions.
3245
- //
3246
- // TODO: move the remarks above into project documentation
3247
-
3248
-
3249
-
3250
-
3251
-
3252
-
3253
- function resolveSubtree(_x, _x2) {return _resolveSubtree.apply(this, arguments);}function _resolveSubtree() {_resolveSubtree = asyncToGenerator_default()( /*#__PURE__*/regenerator_default.a.mark(function _callee(obj, path) {var opts,returnEntireTree,baseDoc,requestInterceptor,responseInterceptor,parameterMacro,modelPropertyMacro,useCircularStructures,resolveOptions,_normalizeSwagger,normalized,result,_args = arguments;return regenerator_default.a.wrap(function _callee$(_context) {while (1) {switch (_context.prev = _context.next) {case 0:opts = _args.length > 2 && _args[2] !== undefined ? _args[2] : {};
3254
-
3255
- returnEntireTree =
3256
-
3257
-
3258
-
3259
-
3260
-
3261
-
3262
- opts.returnEntireTree, baseDoc = opts.baseDoc, requestInterceptor = opts.requestInterceptor, responseInterceptor = opts.responseInterceptor, parameterMacro = opts.parameterMacro, modelPropertyMacro = opts.modelPropertyMacro, useCircularStructures = opts.useCircularStructures;
3263
-
3264
- resolveOptions = {
3265
- pathDiscriminator: path,
3266
- baseDoc: baseDoc,
3267
- requestInterceptor: requestInterceptor,
3268
- responseInterceptor: responseInterceptor,
3269
- parameterMacro: parameterMacro,
3270
- modelPropertyMacro: modelPropertyMacro,
3271
- useCircularStructures: useCircularStructures };_normalizeSwagger =
3272
-
3273
-
3274
- normalizeSwagger({
3275
- spec: obj }), normalized = _normalizeSwagger.spec;_context.next = 6;return (
3276
-
3277
-
3278
- resolve(subtree_resolver_objectSpread(subtree_resolver_objectSpread({},
3279
- resolveOptions), {}, {
3280
- spec: normalized,
3281
- allowMetaPatches: true,
3282
- skipNormalization: true })));case 6:result = _context.sent;
3283
-
3284
-
3285
- if (!returnEntireTree && is_array_default()(path) && path.length) {
3286
- result.spec = external_lodash_get_default()(result.spec, path) || null;
3287
- }return _context.abrupt("return",
3288
-
3289
- result);case 9:case "end":return _context.stop();}}}, _callee);}));return _resolveSubtree.apply(this, arguments);}
3290
- // CONCATENATED MODULE: ./src/interfaces.js
3291
- function interfaces_ownKeys(object, enumerableOnly) {var keys = keys_default()(object);if (get_own_property_symbols_default.a) {var symbols = get_own_property_symbols_default()(object);if (enumerableOnly) symbols = symbols.filter(function (sym) {return get_own_property_descriptor_default()(object, sym).enumerable;});keys.push.apply(keys, symbols);}return keys;}function interfaces_objectSpread(target) {for (var i = 1; i < arguments.length; i++) {var source = arguments[i] != null ? arguments[i] : {};if (i % 2) {interfaces_ownKeys(Object(source), true).forEach(function (key) {defineProperty_default()(target, key, source[key]);});} else if (get_own_property_descriptors_default.a) {define_properties_default()(target, get_own_property_descriptors_default()(source));} else {interfaces_ownKeys(Object(source)).forEach(function (key) {define_property_default()(target, key, get_own_property_descriptor_default()(source, key));});}}return target;}
3292
-
3293
-
3294
- var nullFn = function nullFn() {return null;};
3295
-
3296
- var interfaces_normalizeArray = function normalizeArray(arg) {
3297
- return is_array_default()(arg) ? arg : [arg];
3298
- };
3299
-
3300
- // To allow stubbing of functions
3301
- var interfaces_self = {
3302
- mapTagOperations: mapTagOperations,
3303
- makeExecute: makeExecute };
3304
-
3305
-
3306
- // Make an execute, bound to arguments defined in mapTagOperation's callback (cb)
3307
- function makeExecute() {var swaggerJs = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
3308
- return function (_ref) {var pathName = _ref.pathName,method = _ref.method,operationId = _ref.operationId;return function (parameters) {var opts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
3309
- return swaggerJs.execute(interfaces_objectSpread(interfaces_objectSpread({
3310
- spec: swaggerJs.spec },
3311
- pick_default()(swaggerJs, 'requestInterceptor', 'responseInterceptor', 'userFetch')), {}, {
3312
- pathName: pathName,
3313
- method: method,
3314
- parameters: parameters,
3315
- operationId: operationId },
3316
- opts));
3317
-
3318
- };};
3319
- }
3320
-
3321
- // Creates an interface with tags+operations = execute
3322
- // The shape
3323
- // { apis: { [tag]: { operations: [operation]: { execute }}}}
3324
- // NOTE: this is mostly for compatibility
3325
- function makeApisTagOperationsOperationExecute() {var swaggerJs = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
3326
- // { apis: tag: operations: execute }
3327
- var cb = interfaces_self.makeExecute(swaggerJs);
3328
- var tagOperations = interfaces_self.mapTagOperations({
3329
- v2OperationIdCompatibilityMode: swaggerJs.v2OperationIdCompatibilityMode,
3330
- spec: swaggerJs.spec,
3331
- cb: cb });
3332
-
3333
-
3334
- var apis = {};
3335
- for (var tag in tagOperations) {
3336
- apis[tag] = {
3337
- operations: {} };
3338
-
3339
- for (var op in tagOperations[tag]) {
3340
- apis[tag].operations[op] = { execute: tagOperations[tag][op] };
3341
- }
3342
- }
3343
-
3344
- return { apis: apis };
3345
- }
3346
-
3347
- // .apis[tag][operationId]:ExecuteFunction interface
3348
- function makeApisTagOperation() {var swaggerJs = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
3349
- var cb = interfaces_self.makeExecute(swaggerJs);
3350
- return {
3351
- apis: interfaces_self.mapTagOperations({
3352
- v2OperationIdCompatibilityMode: swaggerJs.v2OperationIdCompatibilityMode,
3353
- spec: swaggerJs.spec,
3354
- cb: cb }) };
3355
-
3356
-
3357
- }
3358
-
3359
- /**
3360
- * Iterates over a spec, creating a hash of {[tag]: { [operationId], ... }, ...}
3361
- * with the value of calling `cb`.
3362
- *
3363
- * `spec` is a OAI v2.0 compliant specification object
3364
- * `cb` is called with ({ spec, operation, path, method })
3365
- * `defaultTag` will house all non-tagged operations
3366
- *
3367
- */
3368
- function mapTagOperations(_ref2) {var spec = _ref2.spec,_ref2$cb = _ref2.cb,cb = _ref2$cb === void 0 ? nullFn : _ref2$cb,_ref2$defaultTag = _ref2.defaultTag,defaultTag = _ref2$defaultTag === void 0 ? 'default' : _ref2$defaultTag,v2OperationIdCompatibilityMode = _ref2.v2OperationIdCompatibilityMode;
3369
- var operationIdCounter = {};
3370
- var tagOperations = {}; // Will house all tags + operations
3371
- eachOperation(spec, function (_ref3) {var pathName = _ref3.pathName,method = _ref3.method,operation = _ref3.operation;
3372
- var tags = operation.tags ? interfaces_normalizeArray(operation.tags) : [defaultTag];
3373
-
3374
- tags.forEach(function (tag) {
3375
- if (typeof tag !== 'string') {
3376
- return;
3377
- }
3378
- var tagObj = tagOperations[tag] = tagOperations[tag] || {};
3379
- var id = opId(operation, pathName, method, { v2OperationIdCompatibilityMode: v2OperationIdCompatibilityMode });
3380
- var cbResult = cb({ spec: spec, pathName: pathName, method: method, operation: operation, operationId: id });
3381
-
3382
- if (operationIdCounter[id]) {
3383
- operationIdCounter[id]++;
3384
- tagObj["".concat(id).concat(operationIdCounter[id])] = cbResult;
3385
- } else
3386
- if (typeof tagObj[id] !== 'undefined') {
3387
- // Bump counter ( for this operationId )
3388
- var originalCounterValue = operationIdCounter[id] || 1;
3389
- operationIdCounter[id] = originalCounterValue + 1;
3390
- // Append _x to the operationId
3391
- tagObj["".concat(id).concat(operationIdCounter[id])] = cbResult;
3392
-
3393
- // Rename the first operationId
3394
- var temp = tagObj[id];
3395
- delete tagObj[id];
3396
- tagObj["".concat(id).concat(originalCounterValue)] = temp;
3397
- } else
3398
- {
3399
- // Assign callback result ( usually a bound function )
3400
- tagObj[id] = cbResult;
3401
- }
3402
- });
3403
- });
3404
-
3405
- return tagOperations;
3406
- }
3407
- // EXTERNAL MODULE: external "@babel/runtime-corejs2/helpers/objectWithoutProperties"
3408
- var objectWithoutProperties_ = __webpack_require__(52);
3409
- var objectWithoutProperties_default = /*#__PURE__*/__webpack_require__.n(objectWithoutProperties_);
3410
-
3411
- // EXTERNAL MODULE: external "lodash/isPlainObject"
3412
- var isPlainObject_ = __webpack_require__(53);
3413
- var isPlainObject_default = /*#__PURE__*/__webpack_require__.n(isPlainObject_);
3414
-
3415
- // EXTERNAL MODULE: external "lodash/isArray"
3416
- var isArray_ = __webpack_require__(54);
3417
- var isArray_default = /*#__PURE__*/__webpack_require__.n(isArray_);
3418
-
3419
- // EXTERNAL MODULE: external "btoa"
3420
- var external_btoa_ = __webpack_require__(28);
3421
- var external_btoa_default = /*#__PURE__*/__webpack_require__.n(external_btoa_);
3422
-
3423
- // EXTERNAL MODULE: external "cookie"
3424
- var external_cookie_ = __webpack_require__(55);
3425
- var external_cookie_default = /*#__PURE__*/__webpack_require__.n(external_cookie_);
3426
-
3427
- // CONCATENATED MODULE: ./src/execute/swagger2/parameter-builders.js
3428
- // These functions will update the request.
3429
- // They'll be given {req, value, paramter, spec, operation}.
3430
-
3431
-
3432
- /* harmony default export */ var parameter_builders = ({
3433
- body: bodyBuilder,
3434
- header: headerBuilder,
3435
- query: queryBuilder,
3436
- path: pathBuilder,
3437
- formData: formDataBuilder });
3438
-
3439
-
3440
-
3441
- // Add the body to the request
3442
- function bodyBuilder(_ref) {var req = _ref.req,value = _ref.value;
3443
- req.body = value;
3444
- }
3445
-
3446
- // Add a form data object.
3447
- function formDataBuilder(_ref2) {var req = _ref2.req,value = _ref2.value,parameter = _ref2.parameter;
3448
- if (value || parameter.allowEmptyValue) {
3449
- req.form = req.form || {};
3450
- req.form[parameter.name] = {
3451
- value: value,
3452
- allowEmptyValue: parameter.allowEmptyValue,
3453
- collectionFormat: parameter.collectionFormat };
3454
-
3455
- }
3456
- }
3457
-
3458
- // Add a header to the request
3459
- function headerBuilder(_ref3) {var req = _ref3.req,parameter = _ref3.parameter,value = _ref3.value;
3460
- req.headers = req.headers || {};
3461
- if (typeof value !== 'undefined') {
3462
- req.headers[parameter.name] = value;
3463
- }
3464
- }
3465
-
3466
- // Replace path paramters, with values ( ie: the URL )
3467
- function pathBuilder(_ref4) {var req = _ref4.req,value = _ref4.value,parameter = _ref4.parameter;
3468
- req.url = req.url.split("{".concat(parameter.name, "}")).join(encodeURIComponent(value));
3469
- }
3470
-
3471
- // Add a query to the `query` object, which will later be stringified into the URL's search
3472
- function queryBuilder(_ref5) {var req = _ref5.req,value = _ref5.value,parameter = _ref5.parameter;
3473
- req.query = req.query || {};
3474
-
3475
- if (value === false && parameter.type === 'boolean') {
3476
- value = 'false';
3477
- }
3478
-
3479
- if (value === 0 && ['number', 'integer'].indexOf(parameter.type) > -1) {
3480
- value = '0';
3481
- }
3482
-
3483
- if (value) {
3484
- req.query[parameter.name] = {
3485
- collectionFormat: parameter.collectionFormat,
3486
- value: value };
3487
-
3488
- } else
3489
- if (parameter.allowEmptyValue && value !== undefined) {
3490
- var paramName = parameter.name;
3491
- req.query[paramName] = req.query[paramName] || {};
3492
- req.query[paramName].allowEmptyValue = true;
3493
- }
3494
- }
3495
- // CONCATENATED MODULE: ./src/execute/oas3/content-serializer.js
3496
- /*
3497
- Serializer that serializes according to a media type instead of OpenAPI's
3498
- `style` + `explode` constructs.
3499
- */
3500
-
3501
- function serialize(value, mediaType) {
3502
- if (mediaType.includes('application/json')) {
3503
- if (typeof value === 'string') {
3504
- // Assume the user has a JSON string
3505
- return value;
3506
- }
3507
- return stringify_default()(value);
3508
- }
3509
-
3510
- return value.toString();
3511
- }
3512
- // CONCATENATED MODULE: ./src/execute/oas3/parameter-builders.js
3513
-
3514
-
3515
-
3516
-
3517
- function parameter_builders_path(_ref) {var req = _ref.req,value = _ref.value,parameter = _ref.parameter;var
3518
- name = parameter.name,style = parameter.style,explode = parameter.explode,content = parameter.content;
3519
-
3520
- if (content) {
3521
- var effectiveMediaType = keys_default()(content)[0];
3522
-
3523
- req.url = req.url.split("{".concat(name, "}")).join(
3524
- encodeDisallowedCharacters(
3525
- serialize(value, effectiveMediaType),
3526
- { escape: true }));
3527
-
3528
-
3529
- return;
3530
- }
3531
-
3532
- var styledValue = stylize({
3533
- key: parameter.name,
3534
- value: value,
3535
- style: style || 'simple',
3536
- explode: explode || false,
3537
- escape: true });
3538
-
3539
-
3540
- req.url = req.url.split("{".concat(name, "}")).join(styledValue);
3541
- }
3542
-
3543
- function parameter_builders_query(_ref2) {var req = _ref2.req,value = _ref2.value,parameter = _ref2.parameter;
3544
- req.query = req.query || {};
3545
-
3546
- if (parameter.content) {
3547
- var effectiveMediaType = keys_default()(parameter.content)[0];
3548
-
3549
- req.query[parameter.name] = serialize(value, effectiveMediaType);
3550
- return;
3551
- }
3552
-
3553
- if (value === false) {
3554
- value = 'false';
3555
- }
3556
-
3557
- if (value === 0) {
3558
- value = '0';
3559
- }
3560
-
3561
- if (value) {
3562
- req.query[parameter.name] = {
3563
- value: value,
3564
- serializationOption: pick_default()(parameter, ['style', 'explode', 'allowReserved']) };
3565
-
3566
- } else
3567
- if (parameter.allowEmptyValue && value !== undefined) {
3568
- var paramName = parameter.name;
3569
- req.query[paramName] = req.query[paramName] || {};
3570
- req.query[paramName].allowEmptyValue = true;
3571
- }
3572
- }
3573
-
3574
- var PARAMETER_HEADER_BLACKLIST = [
3575
- 'accept',
3576
- 'authorization',
3577
- 'content-type'];
3578
-
3579
-
3580
- function parameter_builders_header(_ref3) {var req = _ref3.req,parameter = _ref3.parameter,value = _ref3.value;
3581
- req.headers = req.headers || {};
3582
-
3583
- if (PARAMETER_HEADER_BLACKLIST.indexOf(parameter.name.toLowerCase()) > -1) {
3584
- return;
3585
- }
3586
-
3587
- if (parameter.content) {
3588
- var effectiveMediaType = keys_default()(parameter.content)[0];
3589
-
3590
- req.headers[parameter.name] = serialize(value, effectiveMediaType);
3591
- return;
3592
- }
3593
-
3594
- if (typeof value !== 'undefined') {
3595
- req.headers[parameter.name] = stylize({
3596
- key: parameter.name,
3597
- value: value,
3598
- style: parameter.style || 'simple',
3599
- explode: typeof parameter.explode === 'undefined' ? false : parameter.explode,
3600
- escape: false });
3601
-
3602
- }
3603
- }
3604
-
3605
- function cookie(_ref4) {var req = _ref4.req,parameter = _ref4.parameter,value = _ref4.value;
3606
- req.headers = req.headers || {};
3607
- var type = typeof_default()(value);
3608
-
3609
- if (parameter.content) {
3610
- var effectiveMediaType = keys_default()(parameter.content)[0];
3611
-
3612
- req.headers.Cookie = "".concat(parameter.name, "=").concat(serialize(value, effectiveMediaType));
3613
- return;
3614
- }
3615
-
3616
- if (type !== 'undefined') {
3617
- var prefix =
3618
- type === 'object' &&
3619
- !is_array_default()(value) &&
3620
- parameter.explode ?
3621
- '' : "".concat(parameter.name, "=");
3622
-
3623
- req.headers.Cookie = prefix + stylize({
3624
- key: parameter.name,
3625
- value: value,
3626
- escape: false,
3627
- style: parameter.style || 'form',
3628
- explode: typeof parameter.explode === 'undefined' ? false : parameter.explode });
3629
-
3630
- }
3631
- }
3632
- // CONCATENATED MODULE: ./src/execute/oas3/build-request.js
3633
- // This function runs after the common function,
3634
- // `src/execute/index.js#buildRequest`
3635
-
3636
-
3637
-
3638
-
3639
- /* harmony default export */ var build_request = (function (options, req) {var
3640
-
3641
- operation =
3642
-
3643
-
3644
-
3645
-
3646
- options.operation,requestBody = options.requestBody,securities = options.securities,spec = options.spec,attachContentTypeForEmptyPayload = options.attachContentTypeForEmptyPayload;var
3647
-
3648
-
3649
- requestContentType =
3650
- options.requestContentType;
3651
-
3652
- req = applySecurities({ request: req, securities: securities, operation: operation, spec: spec });
3653
-
3654
- var requestBodyDef = operation.requestBody || {};
3655
- var requestBodyMediaTypes = keys_default()(requestBodyDef.content || {});
3656
- var isExplicitContentTypeValid = requestContentType &&
3657
- requestBodyMediaTypes.indexOf(requestContentType) > -1;
3658
-
3659
- // for OAS3: set the Content-Type
3660
- if (requestBody || attachContentTypeForEmptyPayload) {
3661
- // does the passed requestContentType appear in the requestBody definition?
3662
-
3663
- if (requestContentType && isExplicitContentTypeValid) {
3664
- req.headers['Content-Type'] = requestContentType;
3665
- } else
3666
- if (!requestContentType) {
3667
- var firstMediaType = requestBodyMediaTypes[0];
3668
- if (firstMediaType) {
3669
- req.headers['Content-Type'] = firstMediaType;
3670
- requestContentType = firstMediaType;
3671
- }
3672
- }
3673
- } else
3674
- if (requestContentType && isExplicitContentTypeValid) {
3675
- req.headers['Content-Type'] = requestContentType;
3676
- }
3677
-
3678
- // for OAS3: add requestBody to request
3679
- if (requestBody) {
3680
- if (requestContentType) {
3681
- if (requestBodyMediaTypes.indexOf(requestContentType) > -1) {
3682
- // only attach body if the requestBody has a definition for the
3683
- // contentType that has been explicitly set
3684
- if (requestContentType === 'application/x-www-form-urlencoded' || requestContentType === 'multipart/form-data') {
3685
- if (typeof_default()(requestBody) === 'object') {
3686
- var encoding = (requestBodyDef.content[requestContentType] || {}).encoding || {};
3687
-
3688
- req.form = {};
3689
- keys_default()(requestBody).forEach(function (k) {
3690
- req.form[k] = {
3691
- value: requestBody[k],
3692
- encoding: encoding[k] || {} };
3693
-
3694
- });
3695
- } else
3696
- {
3697
- req.form = requestBody;
3698
- }
3699
- } else
3700
- {
3701
- req.body = requestBody;
3702
- }
3703
- }
3704
- } else
3705
- {
3706
- req.body = requestBody;
3707
- }
3708
- }
3709
-
3710
- return req;
3711
- });
3712
-
3713
- // Add security values, to operations - that declare their need on them
3714
- // Adapted from the Swagger2 implementation
3715
- function applySecurities(_ref) {var request = _ref.request,_ref$securities = _ref.securities,securities = _ref$securities === void 0 ? {} : _ref$securities,_ref$operation = _ref.operation,operation = _ref$operation === void 0 ? {} : _ref$operation,spec = _ref.spec;
3716
- var result = assign_default()({}, request);var _securities$authorize =
3717
- securities.authorized,authorized = _securities$authorize === void 0 ? {} : _securities$authorize;
3718
- var security = operation.security || spec.security || [];
3719
- var isAuthorized = authorized && !!keys_default()(authorized).length;
3720
- var securityDef = external_lodash_get_default()(spec, ['components', 'securitySchemes']) || {};
3721
-
3722
- result.headers = result.headers || {};
3723
- result.query = result.query || {};
3724
-
3725
- if (!keys_default()(securities).length || !isAuthorized || !security ||
3726
- is_array_default()(operation.security) && !operation.security.length) {
3727
- return request;
3728
- }
3729
-
3730
- security.forEach(function (securityObj, index) {
3731
- for (var key in securityObj) {
3732
- var auth = authorized[key];
3733
- var schema = securityDef[key];
3734
-
3735
- if (!auth) {
3736
- continue;
3737
- }
3738
-
3739
- var value = auth.value || auth;var
3740
- type = schema.type;
3741
-
3742
- if (auth) {
3743
- if (type === 'apiKey') {
3744
- if (schema.in === 'query') {
3745
- result.query[schema.name] = value;
3746
- }
3747
- if (schema.in === 'header') {
3748
- result.headers[schema.name] = value;
3749
- }
3750
- if (schema.in === 'cookie') {
3751
- result.cookies[schema.name] = value;
3752
- }
3753
- } else
3754
- if (type === 'http') {
3755
- if (/^basic$/i.test(schema.scheme)) {
3756
- var username = value.username || '';
3757
- var password = value.password || '';
3758
- var encoded = external_btoa_default()("".concat(username, ":").concat(password));
3759
- result.headers.Authorization = "Basic ".concat(encoded);
3760
- }
3761
-
3762
- if (/^bearer$/i.test(schema.scheme)) {
3763
- result.headers.Authorization = "Bearer ".concat(value);
3764
- }
3765
- } else
3766
- if (type === 'oauth2') {
3767
- var token = auth.token || {};
3768
- var tokenName = schema['x-tokenName'] || 'access_token';
3769
- var tokenValue = token[tokenName];
3770
- var tokenType = token.token_type;
3771
-
3772
- if (!tokenType || tokenType.toLowerCase() === 'bearer') {
3773
- tokenType = 'Bearer';
3774
- }
3775
-
3776
- result.headers.Authorization = "".concat(tokenType, " ").concat(tokenValue);
3777
- }
3778
- }
3779
- }
3780
- });
3781
-
3782
- return result;
3783
- }
3784
- // CONCATENATED MODULE: ./src/execute/swagger2/build-request.js
3785
- // This function runs after the common function,
3786
- // `src/execute/index.js#buildRequest`
3787
-
3788
-
3789
-
3790
-
3791
-
3792
-
3793
- /* harmony default export */ var swagger2_build_request = (function (options, req) {var
3794
-
3795
- spec =
3796
-
3797
-
3798
-
3799
-
3800
- options.spec,operation = options.operation,securities = options.securities,requestContentType = options.requestContentType,attachContentTypeForEmptyPayload = options.attachContentTypeForEmptyPayload;
3801
- // Add securities, which are applicable
3802
- req = build_request_applySecurities({ request: req, securities: securities, operation: operation, spec: spec });
3803
-
3804
- if (req.body || req.form || attachContentTypeForEmptyPayload) {
3805
- // all following conditionals are Swagger2 only
3806
- if (requestContentType) {
3807
- req.headers['Content-Type'] = requestContentType;
3808
- } else
3809
- if (is_array_default()(operation.consumes)) {
3810
- req.headers['Content-Type'] = operation.consumes[0];
3811
- } else
3812
- if (is_array_default()(spec.consumes)) {
3813
- req.headers['Content-Type'] = spec.consumes[0];
3814
- } else
3815
- if (operation.parameters && operation.parameters.filter(function (p) {return p.type === 'file';}).length) {
3816
- req.headers['Content-Type'] = 'multipart/form-data';
3817
- } else
3818
- if (operation.parameters && operation.parameters.filter(function (p) {return p.in === 'formData';}).length) {
3819
- req.headers['Content-Type'] = 'application/x-www-form-urlencoded';
3820
- }
3821
- } else
3822
- if (requestContentType) {
3823
- var isBodyParamPresent = operation.parameters && operation.parameters.filter(function (p) {return p.in === 'body';}).length > 0;
3824
- var isFormDataParamPresent = operation.parameters && operation.parameters.filter(function (p) {return p.in === 'formData';}).length > 0;
3825
- if (isBodyParamPresent || isFormDataParamPresent) {
3826
- req.headers['Content-Type'] = requestContentType;
3827
- }
3828
- }
3829
-
3830
- return req;
3831
- });
3832
-
3833
- // Add security values, to operations - that declare their need on them
3834
- function build_request_applySecurities(_ref) {var request = _ref.request,_ref$securities = _ref.securities,securities = _ref$securities === void 0 ? {} : _ref$securities,_ref$operation = _ref.operation,operation = _ref$operation === void 0 ? {} : _ref$operation,spec = _ref.spec;
3835
- var result = assign_default()({}, request);var _securities$authorize =
3836
- securities.authorized,authorized = _securities$authorize === void 0 ? {} : _securities$authorize,_securities$specSecur = securities.specSecurity,specSecurity = _securities$specSecur === void 0 ? [] : _securities$specSecur;
3837
- var security = operation.security || specSecurity;
3838
- var isAuthorized = authorized && !!keys_default()(authorized).length;
3839
- var securityDef = spec.securityDefinitions;
3840
-
3841
- result.headers = result.headers || {};
3842
- result.query = result.query || {};
3843
-
3844
- if (!keys_default()(securities).length || !isAuthorized || !security ||
3845
- is_array_default()(operation.security) && !operation.security.length) {
3846
- return request;
3847
- }
3848
-
3849
- security.forEach(function (securityObj, index) {
3850
- for (var key in securityObj) {
3851
- var auth = authorized[key];
3852
- if (!auth) {
3853
- continue;
3854
- }
3855
-
3856
- var token = auth.token;
3857
- var value = auth.value || auth;
3858
- var schema = securityDef[key];var
3859
- type = schema.type;
3860
- var tokenName = schema['x-tokenName'] || 'access_token';
3861
- var oauthToken = token && token[tokenName];
3862
- var tokenType = token && token.token_type;
3863
-
3864
- if (auth) {
3865
- if (type === 'apiKey') {
3866
- var inType = schema.in === 'query' ? 'query' : 'headers';
3867
- result[inType] = result[inType] || {};
3868
- result[inType][schema.name] = value;
3869
- } else
3870
- if (type === 'basic') {
3871
- if (value.header) {
3872
- result.headers.authorization = value.header;
3873
- } else
3874
- {
3875
- var username = value.username || '';
3876
- var password = value.password || '';
3877
- value.base64 = external_btoa_default()("".concat(username, ":").concat(password));
3878
- result.headers.authorization = "Basic ".concat(value.base64);
3879
- }
3880
- } else
3881
- if (type === 'oauth2' && oauthToken) {
3882
- tokenType = !tokenType || tokenType.toLowerCase() === 'bearer' ? 'Bearer' : tokenType;
3883
- result.headers.authorization = "".concat(tokenType, " ").concat(oauthToken);
3884
- }
3885
- }
3886
- }
3887
- });
3888
-
3889
- return result;
3890
- }
3891
- // CONCATENATED MODULE: ./src/execute/index.js
3892
- function execute_ownKeys(object, enumerableOnly) {var keys = keys_default()(object);if (get_own_property_symbols_default.a) {var symbols = get_own_property_symbols_default()(object);if (enumerableOnly) symbols = symbols.filter(function (sym) {return get_own_property_descriptor_default()(object, sym).enumerable;});keys.push.apply(keys, symbols);}return keys;}function execute_objectSpread(target) {for (var i = 1; i < arguments.length; i++) {var source = arguments[i] != null ? arguments[i] : {};if (i % 2) {execute_ownKeys(Object(source), true).forEach(function (key) {defineProperty_default()(target, key, source[key]);});} else if (get_own_property_descriptors_default.a) {define_properties_default()(target, get_own_property_descriptors_default()(source));} else {execute_ownKeys(Object(source)).forEach(function (key) {define_property_default()(target, key, get_own_property_descriptor_default()(source, key));});}}return target;}
3893
-
3894
-
3895
-
3896
-
3897
-
3898
-
3899
-
3900
-
3901
-
3902
-
3903
-
3904
-
3905
-
3906
-
3907
-
3908
- var execute_arrayOrEmpty = function arrayOrEmpty(ar) {
3909
- return is_array_default()(ar) ? ar : [];
3910
- };
3911
-
3912
- var OperationNotFoundError = createErrorType('OperationNotFoundError', function (message, extra, oriError) {
3913
- this.originalError = oriError;
3914
- object_assign_default()(this, extra || {});
3915
- });
3916
-
3917
- var findParametersWithName = function findParametersWithName(name, parameters) {
3918
- return parameters.filter(function (p) {return p.name === name;});
3919
- };
3920
-
3921
- // removes parameters that have duplicate 'in' and 'name' properties
3922
- var execute_deduplicateParameters = function deduplicateParameters(parameters) {
3923
- var paramsMap = {};
3924
- parameters.forEach(function (p) {
3925
- if (!paramsMap[p.in]) {
3926
- paramsMap[p.in] = {};
3927
- }
3928
- paramsMap[p.in][p.name] = p;
3929
- });
3930
-
3931
- var dedupedParameters = [];
3932
- keys_default()(paramsMap).forEach(function (i) {
3933
- keys_default()(paramsMap[i]).forEach(function (p) {
3934
- dedupedParameters.push(paramsMap[i][p]);
3935
- });
3936
- });
3937
- return dedupedParameters;
3938
- };
3939
-
3940
- // For stubbing in tests
3941
- var execute_self = {
3942
- buildRequest: buildRequest };
3943
-
3944
-
3945
- // Execute request, with the given operationId and parameters
3946
- // pathName/method or operationId is optional
3947
- function execute(_ref)
3948
-
3949
-
3950
-
3951
-
3952
-
3953
-
3954
-
3955
-
3956
-
3957
- {var userHttp = _ref.http,fetch = _ref.fetch,spec = _ref.spec,operationId = _ref.operationId,pathName = _ref.pathName,method = _ref.method,parameters = _ref.parameters,securities = _ref.securities,extras = objectWithoutProperties_default()(_ref, ["http", "fetch", "spec", "operationId", "pathName", "method", "parameters", "securities"]);
3958
- // Provide default fetch implementation
3959
- var http = userHttp || fetch || http_http; // Default to _our_ http
3960
-
3961
- if (pathName && method && !operationId) {
3962
- operationId = legacyIdFromPathMethod(pathName, method);
3963
- }
3964
-
3965
- var request = execute_self.buildRequest(execute_objectSpread({ spec: spec, operationId: operationId, parameters: parameters, securities: securities, http: http }, extras));
3966
-
3967
- if (request.body && (isPlainObject_default()(request.body) || isArray_default()(request.body))) {
3968
- request.body = stringify_default()(request.body);
3969
- }
3970
-
3971
- // Build request and execute it
3972
- return http(request);
3973
- }
3974
-
3975
- // Build a request, which can be handled by the `http.js` implementation.
3976
- function buildRequest(options) {var
3977
-
3978
- spec =
3979
-
3980
-
3981
-
3982
-
3983
-
3984
-
3985
-
3986
-
3987
-
3988
-
3989
-
3990
-
3991
-
3992
- options.spec,operationId = options.operationId,securities = options.securities,requestContentType = options.requestContentType,responseContentType = options.responseContentType,scheme = options.scheme,requestInterceptor = options.requestInterceptor,responseInterceptor = options.responseInterceptor,contextUrl = options.contextUrl,userFetch = options.userFetch,requestBody = options.requestBody,server = options.server,serverVariables = options.serverVariables,http = options.http;var
3993
-
3994
-
3995
- parameters =
3996
-
3997
- options.parameters,parameterBuilders = options.parameterBuilders;
3998
-
3999
- var specIsOAS3 = isOAS3(spec);
4000
- if (!parameterBuilders) {
4001
- // user did not provide custom parameter builders
4002
- if (specIsOAS3) {
4003
- parameterBuilders = oas3_parameter_builders_namespaceObject;
4004
- } else
4005
- {
4006
- parameterBuilders = parameter_builders;
4007
- }
4008
- }
4009
-
4010
- // Set credentials with 'http.withCredentials' value
4011
- var credentials = http && http.withCredentials ? 'include' : 'same-origin';
4012
-
4013
- // Base Template
4014
- var req = {
4015
- url: '',
4016
- credentials: credentials,
4017
- headers: {},
4018
- cookies: {} };
4019
-
4020
-
4021
- if (requestInterceptor) {
4022
- req.requestInterceptor = requestInterceptor;
4023
- }
4024
- if (responseInterceptor) {
4025
- req.responseInterceptor = responseInterceptor;
4026
- }
4027
- if (userFetch) {
4028
- req.userFetch = userFetch;
4029
- }
4030
-
4031
- var operationRaw = getOperationRaw(spec, operationId);
4032
- if (!operationRaw) {
4033
- throw new OperationNotFoundError("Operation ".concat(operationId, " not found"));
4034
- }var _operationRaw$operati =
4035
-
4036
- operationRaw.operation,operation = _operationRaw$operati === void 0 ? {} : _operationRaw$operati,method = operationRaw.method,pathName = operationRaw.pathName;
4037
-
4038
- req.url += execute_baseUrl({ spec: spec, scheme: scheme, contextUrl: contextUrl, server: server, serverVariables: serverVariables, pathName: pathName, method: method });
4039
-
4040
- // Mostly for testing
4041
- if (!operationId) {
4042
- // Not removing req.cookies causes testing issues and would
4043
- // change our interface, so we're always sure to remove it.
4044
- // See the same statement lower down in this function for
4045
- // more context.
4046
- delete req.cookies;
4047
- return req;
4048
- }
4049
-
4050
- req.url += pathName; // Have not yet replaced the path parameters
4051
- req.method = "".concat(method).toUpperCase();
4052
-
4053
- parameters = parameters || {};
4054
- var path = spec.paths[pathName] || {};
4055
-
4056
- if (responseContentType) {
4057
- req.headers.accept = responseContentType;
4058
- }
4059
-
4060
- var combinedParameters = execute_deduplicateParameters([].
4061
- concat(execute_arrayOrEmpty(operation.parameters)) // operation parameters
4062
- .concat(execute_arrayOrEmpty(path.parameters)) // path parameters
4063
- );
4064
-
4065
- // REVIEW: OAS3: have any key names or parameter shapes changed?
4066
- // Any new features that need to be plugged in here?
4067
-
4068
-
4069
- // Add values to request
4070
- combinedParameters.forEach(function (parameter) {
4071
- var builder = parameterBuilders[parameter.in];
4072
- var value;
4073
-
4074
- if (parameter.in === 'body' && parameter.schema && parameter.schema.properties) {
4075
- value = parameters;
4076
- }
4077
-
4078
- value = parameter && parameter.name && parameters[parameter.name];
4079
-
4080
- if (typeof value === 'undefined') {
4081
- // check for `name-in` formatted key
4082
- value = parameter && parameter.name && parameters["".concat(parameter.in, ".").concat(parameter.name)];
4083
- } else
4084
- if (findParametersWithName(parameter.name, combinedParameters).length > 1) {
4085
- // value came from `parameters[parameter.name]`
4086
- // check to see if this is an ambiguous parameter
4087
- // eslint-disable-next-line no-console
4088
- console.warn("Parameter '".concat(parameter.name, "' is ambiguous because the defined spec has more than one parameter with the name: '").concat(parameter.name, "' and the passed-in parameter values did not define an 'in' value."));
4089
- }
4090
-
4091
- if (value === null) {
4092
- return;
4093
- }
4094
-
4095
- if (typeof parameter.default !== 'undefined' && typeof value === 'undefined') {
4096
- value = parameter.default;
4097
- }
4098
-
4099
- if (typeof value === 'undefined' && parameter.required && !parameter.allowEmptyValue) {
4100
- throw new Error("Required parameter ".concat(parameter.name, " is not provided"));
4101
- }
4102
-
4103
- if (specIsOAS3 && parameter.schema && parameter.schema.type === 'object' && typeof value === 'string') {
4104
- try {
4105
- value = JSON.parse(value);
4106
- }
4107
- catch (e) {
4108
- throw new Error('Could not parse object parameter value string as JSON');
4109
- }
4110
- }
4111
-
4112
- if (builder) {
4113
- builder({ req: req, parameter: parameter, value: value, operation: operation, spec: spec });
4114
- }
4115
- });
4116
-
4117
- // Do version-specific tasks, then return those results.
4118
- var versionSpecificOptions = execute_objectSpread(execute_objectSpread({}, options), {}, { operation: operation });
4119
-
4120
- if (specIsOAS3) {
4121
- req = build_request(versionSpecificOptions, req);
4122
- } else
4123
- {
4124
- // If not OAS3, then treat as Swagger2.
4125
- req = swagger2_build_request(versionSpecificOptions, req);
4126
- }
4127
-
4128
-
4129
- // If the cookie convenience object exists in our request,
4130
- // serialize its content and then delete the cookie object.
4131
- if (req.cookies && keys_default()(req.cookies).length) {
4132
- var cookieString = keys_default()(req.cookies).reduce(function (prev, cookieName) {
4133
- var cookieValue = req.cookies[cookieName];
4134
- var prefix = prev ? '&' : '';
4135
- var stringified = external_cookie_default.a.serialize(cookieName, cookieValue);
4136
- return prev + prefix + stringified;
4137
- }, '');
4138
- req.headers.Cookie = cookieString;
4139
- }
4140
-
4141
- if (req.cookies) {
4142
- // even if no cookies were defined, we need to remove
4143
- // the cookies key from our request, or many many legacy
4144
- // tests will break.
4145
- delete req.cookies;
4146
- }
4147
-
4148
- // Will add the query object into the URL, if it exists
4149
- // ... will also create a FormData instance, if multipart/form-data (eg: a file)
4150
- mergeInQueryOrForm(req);
4151
-
4152
- return req;
4153
- }
4154
-
4155
- var stripNonAlpha = function stripNonAlpha(str) {return str ? str.replace(/\W/g, '') : null;};
4156
-
4157
- // be careful when modifying this! it is a publicly-exposed method.
4158
- function execute_baseUrl(obj) {
4159
- var specIsOAS3 = isOAS3(obj.spec);
4160
-
4161
- return specIsOAS3 ? oas3BaseUrl(obj) : swagger2BaseUrl(obj);
4162
- }
4163
-
4164
- function oas3BaseUrl(_ref2) {var spec = _ref2.spec,pathName = _ref2.pathName,method = _ref2.method,server = _ref2.server,contextUrl = _ref2.contextUrl,_ref2$serverVariables = _ref2.serverVariables,serverVariables = _ref2$serverVariables === void 0 ? {} : _ref2$serverVariables;
4165
- var servers =
4166
- external_lodash_get_default()(spec, ['paths', pathName, (method || '').toLowerCase(), 'servers']) ||
4167
- external_lodash_get_default()(spec, ['paths', pathName, 'servers']) ||
4168
- external_lodash_get_default()(spec, ['servers']);
4169
-
4170
- var selectedServerUrl = '';
4171
- var selectedServerObj = null;
4172
-
4173
- if (server && servers && servers.length) {
4174
- var serverUrls = servers.map(function (srv) {return srv.url;});
4175
-
4176
- if (serverUrls.indexOf(server) > -1) {
4177
- selectedServerUrl = server;
4178
- selectedServerObj = servers[serverUrls.indexOf(server)];
4179
- }
4180
- }
4181
-
4182
- if (!selectedServerUrl && servers && servers.length) {
4183
- // default to the first server if we don't have one by now
4184
- selectedServerUrl = servers[0].url;
4185
- selectedServerObj = servers[0];
4186
- }
4187
-
4188
- if (selectedServerUrl.indexOf('{') > -1) {
4189
- // do variable substitution
4190
- var varNames = getVariableTemplateNames(selectedServerUrl);
4191
- varNames.forEach(function (vari) {
4192
- if (selectedServerObj.variables && selectedServerObj.variables[vari]) {
4193
- // variable is defined in server
4194
- var variableDefinition = selectedServerObj.variables[vari];
4195
- var variableValue = serverVariables[vari] || variableDefinition.default;
4196
-
4197
- var re = new RegExp("{".concat(vari, "}"), 'g');
4198
- selectedServerUrl = selectedServerUrl.replace(re, variableValue);
4199
- }
4200
- });
4201
- }
4202
-
4203
- return buildOas3UrlWithContext(selectedServerUrl, contextUrl);
4204
- }
4205
-
4206
- function buildOas3UrlWithContext() {var ourUrl = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';var contextUrl = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
4207
- var parsedUrl = external_url_default.a.parse(ourUrl);
4208
- var parsedContextUrl = external_url_default.a.parse(contextUrl);
4209
-
4210
- var computedScheme = stripNonAlpha(parsedUrl.protocol) || stripNonAlpha(parsedContextUrl.protocol) || '';
4211
- var computedHost = parsedUrl.host || parsedContextUrl.host;
4212
- var computedPath = parsedUrl.pathname || '';
4213
- var res;
4214
-
4215
- if (computedScheme && computedHost) {
4216
- res = "".concat(computedScheme, "://").concat(computedHost + computedPath);
4217
-
4218
- // If last character is '/', trim it off
4219
- } else
4220
- {
4221
- res = computedPath;
4222
- }
4223
-
4224
- return res[res.length - 1] === '/' ? res.slice(0, -1) : res;
4225
- }
4226
-
4227
- function getVariableTemplateNames(str) {
4228
- var results = [];
4229
- var re = /{([^}]+)}/g;
4230
- var text;
4231
-
4232
- // eslint-disable-next-line no-cond-assign
4233
- while (text = re.exec(str)) {
4234
- results.push(text[1]);
4235
- }
4236
- return results;
4237
- }
4238
-
4239
- // Compose the baseUrl ( scheme + host + basePath )
4240
- function swagger2BaseUrl(_ref3) {var spec = _ref3.spec,scheme = _ref3.scheme,_ref3$contextUrl = _ref3.contextUrl,contextUrl = _ref3$contextUrl === void 0 ? '' : _ref3$contextUrl;
4241
- var parsedContextUrl = external_url_default.a.parse(contextUrl);
4242
- var firstSchemeInSpec = is_array_default()(spec.schemes) ? spec.schemes[0] : null;
4243
-
4244
- var computedScheme = scheme || firstSchemeInSpec || stripNonAlpha(parsedContextUrl.protocol) || 'http';
4245
- var computedHost = spec.host || parsedContextUrl.host || '';
4246
- var computedPath = spec.basePath || '';
4247
- var res;
4248
-
4249
- if (computedScheme && computedHost) {
4250
- // we have what we need for an absolute URL
4251
- res = "".concat(computedScheme, "://").concat(computedHost + computedPath);
4252
- } else
4253
- {
4254
- // if not, a relative URL will have to do
4255
- res = computedPath;
4256
- }
4257
-
4258
- // If last character is '/', trim it off
4259
- return res[res.length - 1] === '/' ? res.slice(0, -1) : res;
4260
- }
4261
- // CONCATENATED MODULE: ./src/index.js
4262
- function src_ownKeys(object, enumerableOnly) {var keys = keys_default()(object);if (get_own_property_symbols_default.a) {var symbols = get_own_property_symbols_default()(object);if (enumerableOnly) symbols = symbols.filter(function (sym) {return get_own_property_descriptor_default()(object, sym).enumerable;});keys.push.apply(keys, symbols);}return keys;}function src_objectSpread(target) {for (var i = 1; i < arguments.length; i++) {var source = arguments[i] != null ? arguments[i] : {};if (i % 2) {src_ownKeys(Object(source), true).forEach(function (key) {defineProperty_default()(target, key, source[key]);});} else if (get_own_property_descriptors_default.a) {define_properties_default()(target, get_own_property_descriptors_default()(source));} else {src_ownKeys(Object(source)).forEach(function (key) {define_property_default()(target, key, get_own_property_descriptor_default()(source, key));});}}return target;}
4263
-
4264
-
4265
-
4266
-
4267
-
4268
-
4269
-
4270
-
4271
-
4272
- Swagger.http = http_http;
4273
- Swagger.makeHttp = makeHttp.bind(null, Swagger.http);
4274
- Swagger.resolve = resolve;
4275
- Swagger.resolveSubtree = resolveSubtree;
4276
- Swagger.execute = execute;
4277
- Swagger.serializeRes = serializeRes;
4278
- Swagger.serializeHeaders = serializeHeaders;
4279
- Swagger.clearCache = resolver_clearCache;
4280
- Swagger.makeApisTagOperation = makeApisTagOperation;
4281
- Swagger.buildRequest = buildRequest;
4282
- Swagger.helpers = { opId: opId };
4283
- Swagger.getBaseUrl = execute_baseUrl;
4284
-
4285
- function Swagger(url) {var _this = this;var opts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
4286
- // Allow url as a separate argument
4287
- if (typeof url === 'string') {
4288
- opts.url = url;
4289
- } else
4290
- {
4291
- opts = url;
4292
- }
4293
-
4294
- if (!(this instanceof Swagger)) {
4295
- return new Swagger(opts);
4296
- }
4297
-
4298
- assign_default()(this, opts);
4299
-
4300
- var prom = this.resolve().
4301
- then(function () {
4302
- if (!_this.disableInterfaces) {
4303
- assign_default()(_this, Swagger.makeApisTagOperation(_this));
4304
- }
4305
- return _this;
4306
- });
4307
-
4308
- // Expose this instance on the promise that gets returned
4309
- prom.client = this;
4310
- return prom;
4311
- }
4312
-
4313
- Swagger.prototype = {
4314
-
4315
- http: http_http,
4316
-
4317
- execute: function execute(options) {
4318
- this.applyDefaults();
4319
-
4320
- return Swagger.execute(src_objectSpread({
4321
- spec: this.spec,
4322
- http: this.http,
4323
- securities: { authorized: this.authorizations },
4324
- contextUrl: typeof this.url === 'string' ? this.url : undefined,
4325
- requestInterceptor: this.requestInterceptor || null,
4326
- responseInterceptor: this.responseInterceptor || null },
4327
- options));
4328
-
4329
- },
4330
-
4331
- resolve: function resolve() {var _this2 = this;var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
4332
- return Swagger.resolve(src_objectSpread({
4333
- spec: this.spec,
4334
- url: this.url,
4335
- http: this.http,
4336
- allowMetaPatches: this.allowMetaPatches,
4337
- useCircularStructures: this.useCircularStructures,
4338
- requestInterceptor: this.requestInterceptor || null,
4339
- responseInterceptor: this.responseInterceptor || null },
4340
- options)).
4341
- then(function (obj) {
4342
- _this2.originalSpec = _this2.spec;
4343
- _this2.spec = obj.spec;
4344
- _this2.errors = obj.errors;
4345
- return _this2;
4346
- });
4347
- } };
4348
-
4349
-
4350
- Swagger.prototype.applyDefaults = function () {
4351
- var spec = this.spec;
4352
- var specUrl = this.url;
4353
- // TODO: OAS3: support servers here
4354
- if (specUrl && startsWith_default()(specUrl, 'http')) {
4355
- var parsed = external_url_default.a.parse(specUrl);
4356
- if (!spec.host) {
4357
- spec.host = parsed.host;
4358
- }
4359
- if (!spec.schemes) {
4360
- spec.schemes = [parsed.protocol.replace(':', '')];
4361
- }
4362
- if (!spec.basePath) {
4363
- spec.basePath = '/';
4364
- }
4365
- }
4366
- };
4367
-
4368
- /* harmony default export */ var src = __webpack_exports__["default"] = (Swagger);
4369
-
4370
- /***/ })
4371
- /******/ ])["default"];
4372
- //# sourceMappingURL=index.js.map