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
@@ -0,0 +1,516 @@
1
+ import _typeof from "@babel/runtime-corejs2/helpers/typeof";
2
+ import _Object$keys from "@babel/runtime-corejs2/core-js/object/keys";
3
+ import _Promise from "@babel/runtime-corejs2/core-js/promise";
4
+ import _WeakMap from "@babel/runtime-corejs2/core-js/weak-map";
5
+ import _Object$assign from "@babel/runtime-corejs2/core-js/object/assign";
6
+ import { fetch } from 'cross-fetch';
7
+ import jsYaml from 'js-yaml';
8
+ import qs from 'querystring-browser';
9
+ import url from 'url';
10
+ import lib from '.';
11
+ import createError from './create-error';
12
+ import { isFreelyNamed, absolutifyPointer } from '../helpers';
13
+ import { ACCEPT_HEADER_VALUE_FOR_DOCUMENTS } from '../../constants';
14
+ var ABSOLUTE_URL_REGEXP = new RegExp('^([a-z]+://|//)', 'i');
15
+ var JSONRefError = createError('JSONRefError', function cb(message, extra, oriError) {
16
+ this.originalError = oriError;
17
+
18
+ _Object$assign(this, extra || {});
19
+ });
20
+ var docCache = {};
21
+ var specmapRefs = new _WeakMap();
22
+ var skipResolutionTestFns = [function (path) {
23
+ return (// OpenAPI 3.0 Response Media Type Example
24
+ // ["paths", *, *, "responses", *, "content", *, "example"]
25
+ path[0] === 'paths' && path[3] === 'responses' && path[5] === 'content' && path[7] === 'example'
26
+ );
27
+ }, function (path) {
28
+ return (// OpenAPI 3.0 Request Body Media Type Example
29
+ // ["paths", *, *, "responses", *, "content", *, "example"]
30
+ path[0] === 'paths' && path[3] === 'requestBody' && path[4] === 'content' && path[6] === 'example'
31
+ );
32
+ }];
33
+
34
+ var shouldSkipResolution = function shouldSkipResolution(path) {
35
+ return skipResolutionTestFns.some(function (fn) {
36
+ return fn(path);
37
+ });
38
+ }; // =========================
39
+ // Core
40
+ // =========================
41
+
42
+ /**
43
+ * This plugin resolves the JSON pointers.
44
+ * A major part of this plugin deals with cyclic references via 2 mechanisms.
45
+ * 1. If a pointer was already resolved before in this path, halt.
46
+ * 2. If the patch value points to one of the ancestors in this path, halt.
47
+ *
48
+ * Note that either one of these mechanism is sufficient, both must be in place.
49
+ * For examples:
50
+ *
51
+ * Given the following spec, #1 alone is insufficient because after the 2nd
52
+ * application, there will be a cyclic object reference.
53
+ * a.b.c: $ref-d
54
+ * d.e.f: $ref-a (per #1, safe to return patch as no immediate cycle)
55
+ *
56
+ * Given the following spec, #2 alone is insufficient because although there will
57
+ * never be any cyclic object reference, the plugin will keep producing patches.
58
+ * a: $ref-b
59
+ * b: $ref-a
60
+ */
61
+
62
+
63
+ var plugin = {
64
+ key: '$ref',
65
+ plugin: function plugin(ref, key, fullPath, specmap) {
66
+ var specmapInstance = specmap.getInstance();
67
+ var parent = fullPath.slice(0, -1);
68
+
69
+ if (isFreelyNamed(parent) || shouldSkipResolution(parent)) {
70
+ return undefined;
71
+ }
72
+
73
+ var _specmap$getContext = specmap.getContext(fullPath),
74
+ baseDoc = _specmap$getContext.baseDoc;
75
+
76
+ if (typeof ref !== 'string') {
77
+ return new JSONRefError('$ref: must be a string (JSON-Ref)', {
78
+ $ref: ref,
79
+ baseDoc: baseDoc,
80
+ fullPath: fullPath
81
+ });
82
+ }
83
+
84
+ var splitString = split(ref);
85
+ var refPath = splitString[0];
86
+ var pointer = splitString[1] || '';
87
+ var basePath;
88
+
89
+ try {
90
+ basePath = baseDoc || refPath ? absoluteify(refPath, baseDoc) : null;
91
+ } catch (e) {
92
+ return wrapError(e, {
93
+ pointer: pointer,
94
+ $ref: ref,
95
+ basePath: basePath,
96
+ fullPath: fullPath
97
+ });
98
+ }
99
+
100
+ var promOrVal;
101
+ var tokens;
102
+
103
+ if (pointerAlreadyInPath(pointer, basePath, parent, specmap)) {
104
+ // Cyclic reference!
105
+ // if `useCircularStructures` is not set, just leave the reference
106
+ // unresolved, but absolutify it so that we don't leave an invalid $ref
107
+ // path in the content
108
+ if (!specmapInstance.useCircularStructures) {
109
+ var _absolutifiedRef = absolutifyPointer(ref, basePath);
110
+
111
+ if (ref === _absolutifiedRef) {
112
+ // avoids endless looping
113
+ // without this, the ref plugin never stops seeing this $ref
114
+ return null;
115
+ }
116
+
117
+ return lib.replace(fullPath, _absolutifiedRef);
118
+ }
119
+ }
120
+
121
+ if (basePath == null) {
122
+ tokens = jsonPointerToArray(pointer);
123
+ promOrVal = specmap.get(tokens);
124
+
125
+ if (typeof promOrVal === 'undefined') {
126
+ promOrVal = new JSONRefError("Could not resolve reference: ".concat(ref), {
127
+ pointer: pointer,
128
+ $ref: ref,
129
+ baseDoc: baseDoc,
130
+ fullPath: fullPath
131
+ });
132
+ }
133
+ } else {
134
+ promOrVal = extractFromDoc(basePath, pointer); // eslint-disable-next-line no-underscore-dangle
135
+
136
+ if (promOrVal.__value != null) {
137
+ promOrVal = promOrVal.__value; // eslint-disable-line no-underscore-dangle
138
+ } else {
139
+ promOrVal = promOrVal.catch(function (e) {
140
+ throw wrapError(e, {
141
+ pointer: pointer,
142
+ $ref: ref,
143
+ baseDoc: baseDoc,
144
+ fullPath: fullPath
145
+ });
146
+ });
147
+ }
148
+ }
149
+
150
+ if (promOrVal instanceof Error) {
151
+ return [lib.remove(fullPath), promOrVal];
152
+ }
153
+
154
+ var absolutifiedRef = absolutifyPointer(ref, basePath);
155
+ var patch = lib.replace(parent, promOrVal, {
156
+ $$ref: absolutifiedRef
157
+ });
158
+
159
+ if (basePath && basePath !== baseDoc) {
160
+ return [patch, lib.context(parent, {
161
+ baseDoc: basePath
162
+ })];
163
+ }
164
+
165
+ try {
166
+ // prevents circular values from being constructed, unless we specifically
167
+ // want that to happen
168
+ if (!patchValueAlreadyInPath(specmap.state, patch) || specmapInstance.useCircularStructures) {
169
+ return patch;
170
+ }
171
+ } catch (e) {
172
+ // if we're catching here, path traversal failed, so we should
173
+ // ditch without sending any patches back up.
174
+ //
175
+ // this is a narrow fix for the larger problem of patches being queued
176
+ // and then having the state they were generated against be modified
177
+ // before they are applied.
178
+ //
179
+ // TODO: re-engineer specmap patch/state management to avoid this
180
+ return null;
181
+ }
182
+
183
+ return undefined;
184
+ }
185
+ };
186
+
187
+ var mod = _Object$assign(plugin, {
188
+ docCache: docCache,
189
+ absoluteify: absoluteify,
190
+ clearCache: clearCache,
191
+ JSONRefError: JSONRefError,
192
+ wrapError: wrapError,
193
+ getDoc: getDoc,
194
+ split: split,
195
+ extractFromDoc: extractFromDoc,
196
+ fetchJSON: fetchJSON,
197
+ extract: extract,
198
+ jsonPointerToArray: jsonPointerToArray,
199
+ unescapeJsonPointerToken: unescapeJsonPointerToken
200
+ });
201
+
202
+ export default mod; // =========================
203
+ // Utilities
204
+ // =========================
205
+
206
+ /**
207
+ * Resolves a path and its base to an abolute URL.
208
+ * @api public
209
+ */
210
+
211
+ function absoluteify(path, basePath) {
212
+ if (!ABSOLUTE_URL_REGEXP.test(path)) {
213
+ if (!basePath) {
214
+ throw new JSONRefError("Tried to resolve a relative URL, without having a basePath. path: '".concat(path, "' basePath: '").concat(basePath, "'"));
215
+ }
216
+
217
+ return url.resolve(basePath, path);
218
+ }
219
+
220
+ return path;
221
+ }
222
+ /**
223
+ * Wraps an error as JSONRefError.
224
+ * @param {Error} e the error.
225
+ * @param {Object} extra (optional) optional data.
226
+ * @return {Error} an instance of JSONRefError.
227
+ * @api public
228
+ */
229
+
230
+
231
+ function wrapError(e, extra) {
232
+ var message;
233
+
234
+ if (e && e.response && e.response.body) {
235
+ message = "".concat(e.response.body.code, " ").concat(e.response.body.message);
236
+ } else {
237
+ message = e.message;
238
+ }
239
+
240
+ return new JSONRefError("Could not resolve reference: ".concat(message), extra, e);
241
+ }
242
+ /**
243
+ * Splits a pointer by the hash delimiter.
244
+ * @api public
245
+ */
246
+
247
+
248
+ function split(ref) {
249
+ return (ref + '').split('#'); // eslint-disable-line prefer-template
250
+ }
251
+ /**
252
+ * Extracts a pointer from its document.
253
+ * @param {String} docPath the absolute document URL.
254
+ * @param {String} pointer the pointer whose value is to be extracted.
255
+ * @return {Promise} a promise of the pointer value.
256
+ * @api public
257
+ */
258
+
259
+
260
+ function extractFromDoc(docPath, pointer) {
261
+ var doc = docCache[docPath];
262
+
263
+ if (doc && !lib.isPromise(doc)) {
264
+ // If doc is already available, return __value together with the promise.
265
+ // __value is for special handling in cycle check:
266
+ // pointerAlreadyInPath() won't work if patch.value is a promise,
267
+ // thus when that promise is finally resolved, cycle might happen (because
268
+ // `spec` and `docCache[basePath]` refer to the exact same object).
269
+ // See test "should resolve a cyclic spec when baseDoc is specified".
270
+ try {
271
+ var v = extract(pointer, doc);
272
+ return _Object$assign(_Promise.resolve(v), {
273
+ __value: v
274
+ });
275
+ } catch (e) {
276
+ return _Promise.reject(e);
277
+ }
278
+ }
279
+
280
+ return getDoc(docPath).then(function (_doc) {
281
+ return extract(pointer, _doc);
282
+ });
283
+ }
284
+ /**
285
+ * Clears all document caches.
286
+ * @param {String} item (optional) the name of the cache item to be cleared.
287
+ * @api public
288
+ */
289
+
290
+
291
+ function clearCache(item) {
292
+ if (typeof item !== 'undefined') {
293
+ delete docCache[item];
294
+ } else {
295
+ _Object$keys(docCache).forEach(function (key) {
296
+ delete docCache[key];
297
+ });
298
+ }
299
+ }
300
+ /**
301
+ * Fetches and caches a document.
302
+ * @param {String} docPath the absolute URL of the document.
303
+ * @return {Promise} a promise of the document content.
304
+ * @api public
305
+ */
306
+
307
+
308
+ function getDoc(docPath) {
309
+ var val = docCache[docPath];
310
+
311
+ if (val) {
312
+ return lib.isPromise(val) ? val : _Promise.resolve(val);
313
+ } // NOTE: we need to use `mod.fetchJSON` in order to be able to overwrite it.
314
+ // Any tips on how to make this cleaner, please ping!
315
+
316
+
317
+ docCache[docPath] = mod.fetchJSON(docPath).then(function (doc) {
318
+ docCache[docPath] = doc;
319
+ return doc;
320
+ });
321
+ return docCache[docPath];
322
+ }
323
+ /**
324
+ * Fetches a document.
325
+ * @param {String} docPath the absolute URL of the document.
326
+ * @return {Promise} a promise of the document content.
327
+ * @api public
328
+ */
329
+
330
+
331
+ function fetchJSON(docPath) {
332
+ return fetch(docPath, {
333
+ headers: {
334
+ Accept: ACCEPT_HEADER_VALUE_FOR_DOCUMENTS
335
+ },
336
+ loadSpec: true
337
+ }).then(function (res) {
338
+ return res.text();
339
+ }).then(function (text) {
340
+ return jsYaml.safeLoad(text);
341
+ });
342
+ }
343
+ /**
344
+ * Extracts a pointer from an object.
345
+ * @param {String[]} pointer the JSON pointer.
346
+ * @param {Object} obj an object whose value is to be extracted.
347
+ * @return {Object} the value to be extracted.
348
+ * @api public
349
+ */
350
+
351
+
352
+ function extract(pointer, obj) {
353
+ var tokens = jsonPointerToArray(pointer);
354
+
355
+ if (tokens.length < 1) {
356
+ return obj;
357
+ }
358
+
359
+ var val = lib.getIn(obj, tokens);
360
+
361
+ if (typeof val === 'undefined') {
362
+ throw new JSONRefError("Could not resolve pointer: ".concat(pointer, " does not exist in document"), {
363
+ pointer: pointer
364
+ });
365
+ }
366
+
367
+ return val;
368
+ }
369
+ /**
370
+ * Converts a JSON pointer to array.
371
+ * @api public
372
+ */
373
+
374
+
375
+ function jsonPointerToArray(pointer) {
376
+ if (typeof pointer !== 'string') {
377
+ throw new TypeError("Expected a string, got a ".concat(_typeof(pointer)));
378
+ }
379
+
380
+ if (pointer[0] === '/') {
381
+ pointer = pointer.substr(1);
382
+ }
383
+
384
+ if (pointer === '') {
385
+ return [];
386
+ }
387
+
388
+ return pointer.split('/').map(unescapeJsonPointerToken);
389
+ }
390
+ /**
391
+ * Unescapes a JSON pointer.
392
+ * @api public
393
+ */
394
+
395
+
396
+ function unescapeJsonPointerToken(token) {
397
+ if (typeof token !== 'string') {
398
+ return token;
399
+ }
400
+
401
+ return qs.unescape(token.replace(/~1/g, '/').replace(/~0/g, '~'));
402
+ }
403
+ /**
404
+ * Escapes a JSON pointer.
405
+ * @api public
406
+ */
407
+
408
+
409
+ function escapeJsonPointerToken(token) {
410
+ return qs.escape(token.replace(/~/g, '~0').replace(/\//g, '~1'));
411
+ }
412
+
413
+ function arrayToJsonPointer(arr) {
414
+ if (arr.length === 0) {
415
+ return '';
416
+ }
417
+
418
+ return "/".concat(arr.map(escapeJsonPointerToken).join('/'));
419
+ }
420
+
421
+ var pointerBoundaryChar = function pointerBoundaryChar(c) {
422
+ return !c || c === '/' || c === '#';
423
+ };
424
+
425
+ function pointerIsAParent(pointer, parentPointer) {
426
+ if (pointerBoundaryChar(parentPointer)) {
427
+ // This is the root of the document, so its naturally a parent
428
+ return true;
429
+ }
430
+
431
+ var nextChar = pointer.charAt(parentPointer.length);
432
+ var lastParentChar = parentPointer.slice(-1);
433
+ return pointer.indexOf(parentPointer) === 0 && (!nextChar || nextChar === '/' || nextChar === '#') && lastParentChar !== '#';
434
+ } // =========================
435
+ // Private
436
+ // =========================
437
+
438
+ /**
439
+ * Checks if this pointer points back to one or more pointers along the path.
440
+ */
441
+
442
+
443
+ function pointerAlreadyInPath(pointer, basePath, parent, specmap) {
444
+ var refs = specmapRefs.get(specmap);
445
+
446
+ if (!refs) {
447
+ // Stores all resolved references of a specmap instance.
448
+ // Schema: path -> pointer (path's $ref value).
449
+ refs = {};
450
+ specmapRefs.set(specmap, refs);
451
+ }
452
+
453
+ var parentPointer = arrayToJsonPointer(parent);
454
+ var fullyQualifiedPointer = "".concat(basePath || '<specmap-base>', "#").concat(pointer); // dirty hack to strip `allof/[index]` from the path, in order to avoid cases
455
+ // where we get false negatives because:
456
+ // - we resolve a path, then
457
+ // - allOf plugin collapsed `allOf/[index]` out of the path, then
458
+ // - we try to work on a child $ref within that collapsed path.
459
+ //
460
+ // because of the path collapse, we lose track of it in our specmapRefs hash
461
+ // solution: always throw the allOf constructs out of paths we store
462
+ // TODO: solve this with a global register, or by writing more metadata in
463
+ // either allOf or refs plugin
464
+
465
+ var safeParentPointer = parentPointer.replace(/allOf\/\d+\/?/g, ''); // Case 1: direct cycle, e.g. a.b.c.$ref: '/a.b'
466
+ // Detect by checking that the parent path doesn't start with pointer.
467
+ // This only applies if the pointer is internal, i.e. basePath === rootPath (could be null)
468
+
469
+ var rootDoc = specmap.contextTree.get([]).baseDoc;
470
+
471
+ if (basePath == rootDoc && pointerIsAParent(safeParentPointer, pointer)) {
472
+ // eslint-disable-line
473
+ return true;
474
+ } // Case 2: indirect cycle
475
+ // ex1: a.$ref: '/b' & b.c.$ref: '/b/c'
476
+ // ex2: a.$ref: '/b/c' & b.c.$ref: '/b'
477
+ // Detect by retrieving all the $refs along the path of parent
478
+ // and checking if any starts with pointer or vice versa.
479
+
480
+
481
+ var currPath = '';
482
+ var hasIndirectCycle = parent.some(function (token) {
483
+ currPath = "".concat(currPath, "/").concat(escapeJsonPointerToken(token));
484
+ return refs[currPath] && refs[currPath].some(function (ref) {
485
+ return pointerIsAParent(ref, fullyQualifiedPointer) || pointerIsAParent(fullyQualifiedPointer, ref);
486
+ });
487
+ });
488
+
489
+ if (hasIndirectCycle) {
490
+ return true;
491
+ } // No cycle, this ref will be resolved, so stores it now for future detection.
492
+ // No need to store if has cycle, as parent path is a dead-end and won't be checked again.
493
+
494
+
495
+ refs[safeParentPointer] = (refs[safeParentPointer] || []).concat(fullyQualifiedPointer);
496
+ return undefined;
497
+ }
498
+ /**
499
+ * Checks if the value of this patch ends up pointing to an ancestor along the path.
500
+ */
501
+
502
+
503
+ function patchValueAlreadyInPath(root, patch) {
504
+ var ancestors = [root];
505
+ patch.path.reduce(function (parent, p) {
506
+ ancestors.push(parent[p]);
507
+ return parent[p];
508
+ }, root);
509
+ return pointToAncestor(patch.value);
510
+
511
+ function pointToAncestor(obj) {
512
+ return lib.isObject(obj) && (ancestors.indexOf(obj) >= 0 || _Object$keys(obj).some(function (k) {
513
+ return pointToAncestor(obj[k]);
514
+ }));
515
+ }
516
+ }
@@ -0,0 +1,92 @@
1
+ import _regeneratorRuntime from "@babel/runtime-corejs2/regenerator";
2
+ import _Array$isArray from "@babel/runtime-corejs2/core-js/array/is-array";
3
+ import _objectSpread from "@babel/runtime-corejs2/helpers/objectSpread2";
4
+ import _asyncToGenerator from "@babel/runtime-corejs2/helpers/asyncToGenerator";
5
+ // The subtree resolver is a higher-level interface that allows you to
6
+ // get the same result that you would from `Swagger.resolve`, but focuses on
7
+ // a subtree of your object.
8
+ //
9
+ // It makes several assumptions that allow you to think less about what resolve,
10
+ // specmap, and normalizeSwagger are doing: if this is not suitable for you,
11
+ // you can emulate `resolveSubtree`'s behavior by talking to the traditional
12
+ // resolver directly.
13
+ //
14
+ // By providing a top-level `obj` and a `path` to resolve within, the subtree
15
+ // at `path` will be resolved and normalized in the context of your top-level
16
+ // `obj`. You'll get the resolved subtree you're interest in as a return value
17
+ // (or, you can use `returnEntireTree` to get everything back).
18
+ //
19
+ // This is useful for cases where resolving your entire object is unnecessary
20
+ // and/or non-performant; we use this interface for lazily resolving operations
21
+ // and models in Swagger-UI, which allows us to handle larger definitions.
22
+ //
23
+ // It's likely that Swagger-Client will rely entirely on lazy resolving in
24
+ // future versions.
25
+ //
26
+ // TODO: move the remarks above into project documentation
27
+ import get from 'lodash/get';
28
+ import resolve from '../resolver';
29
+ import { normalizeSwagger } from '../helpers';
30
+ export default function resolveSubtree(_x, _x2) {
31
+ return _resolveSubtree.apply(this, arguments);
32
+ }
33
+
34
+ function _resolveSubtree() {
35
+ _resolveSubtree = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(obj, path) {
36
+ var opts,
37
+ returnEntireTree,
38
+ baseDoc,
39
+ requestInterceptor,
40
+ responseInterceptor,
41
+ parameterMacro,
42
+ modelPropertyMacro,
43
+ useCircularStructures,
44
+ resolveOptions,
45
+ _normalizeSwagger,
46
+ normalized,
47
+ result,
48
+ _args = arguments;
49
+
50
+ return _regeneratorRuntime.wrap(function _callee$(_context) {
51
+ while (1) {
52
+ switch (_context.prev = _context.next) {
53
+ case 0:
54
+ opts = _args.length > 2 && _args[2] !== undefined ? _args[2] : {};
55
+ returnEntireTree = opts.returnEntireTree, baseDoc = opts.baseDoc, requestInterceptor = opts.requestInterceptor, responseInterceptor = opts.responseInterceptor, parameterMacro = opts.parameterMacro, modelPropertyMacro = opts.modelPropertyMacro, useCircularStructures = opts.useCircularStructures;
56
+ resolveOptions = {
57
+ pathDiscriminator: path,
58
+ baseDoc: baseDoc,
59
+ requestInterceptor: requestInterceptor,
60
+ responseInterceptor: responseInterceptor,
61
+ parameterMacro: parameterMacro,
62
+ modelPropertyMacro: modelPropertyMacro,
63
+ useCircularStructures: useCircularStructures
64
+ };
65
+ _normalizeSwagger = normalizeSwagger({
66
+ spec: obj
67
+ }), normalized = _normalizeSwagger.spec;
68
+ _context.next = 6;
69
+ return resolve(_objectSpread(_objectSpread({}, resolveOptions), {}, {
70
+ spec: normalized,
71
+ allowMetaPatches: true,
72
+ skipNormalization: true
73
+ }));
74
+
75
+ case 6:
76
+ result = _context.sent;
77
+
78
+ if (!returnEntireTree && _Array$isArray(path) && path.length) {
79
+ result.spec = get(result.spec, path) || null;
80
+ }
81
+
82
+ return _context.abrupt("return", result);
83
+
84
+ case 9:
85
+ case "end":
86
+ return _context.stop();
87
+ }
88
+ }
89
+ }, _callee);
90
+ }));
91
+ return _resolveSubtree.apply(this, arguments);
92
+ }
@@ -0,0 +1,10 @@
1
+ 'use strict'; // eslint-disable-line
2
+
3
+ const {
4
+ default: SwaggerClient
5
+ } = require('./index'); // add backwards compatibility with older versions of swagger-ui
6
+ // by exporting one single symbol.
7
+ // Refs https://github.com/swagger-api/swagger-ui/issues/6210
8
+
9
+
10
+ module.exports = SwaggerClient;
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+
3
+ exports.__esModule = true;
4
+ exports.ACCEPT_HEADER_VALUE_FOR_DOCUMENTS = void 0;
5
+ // eslint-disable-next-line import/prefer-default-export
6
+ const ACCEPT_HEADER_VALUE_FOR_DOCUMENTS = 'application/json, application/yaml';
7
+ exports.ACCEPT_HEADER_VALUE_FOR_DOCUMENTS = ACCEPT_HEADER_VALUE_FOR_DOCUMENTS;