swagger-client 3.18.2 → 3.18.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -19,7 +19,7 @@ import SWAGGER2_PARAMETER_BUILDERS from './swagger2/parameter-builders.js';
19
19
  import * as OAS3_PARAMETER_BUILDERS from './oas3/parameter-builders.js';
20
20
  import oas3BuildRequest from './oas3/build-request.js';
21
21
  import swagger2BuildRequest from './swagger2/build-request.js';
22
- import { getOperationRaw, legacyIdFromPathMethod, isOAS3 } from '../helpers.js';
22
+ import { getOperationRaw, legacyIdFromPathMethod, isOAS3 } from '../helpers/index.js';
23
23
 
24
24
  var arrayOrEmpty = function arrayOrEmpty(ar) {
25
25
  return Array.isArray(ar) ? ar : [];
@@ -9,7 +9,7 @@ import _concatInstanceProperty from "@babel/runtime-corejs3/core-js-stable/insta
9
9
  // `src/execute/index.js#buildRequest`
10
10
  import { isPlainObject } from 'is-plain-object';
11
11
  import get from 'lodash/get';
12
- import btoa from 'btoa';
12
+ import btoa from '../../helpers/btoa.node.js';
13
13
  export default function buildRequest(options, req) {
14
14
  var operation = options.operation,
15
15
  requestBody = options.requestBody,
@@ -3,7 +3,7 @@ import _slicedToArray from "@babel/runtime-corejs3/helpers/slicedToArray";
3
3
  import _filterInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/filter";
4
4
  import _Object$keys from "@babel/runtime-corejs3/core-js-stable/object/keys";
5
5
  import _concatInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/concat";
6
- import btoa from 'btoa'; // This function runs after the common function,
6
+ import btoa from '../../helpers/btoa.node.js'; // This function runs after the common function,
7
7
  // `src/execute/index.js#buildRequest`
8
8
 
9
9
  export default function buildRequest(options, req) {
@@ -0,0 +1,19 @@
1
+ import _globalThis from "@babel/runtime-corejs3/core-js/global-this";
2
+
3
+ /* eslint-disable no-undef, no-restricted-globals */
4
+ var globalObject = function () {
5
+ // new standardized access to the global object
6
+ if (typeof _globalThis !== 'undefined') {
7
+ return _globalThis;
8
+ } // WebWorker specific access
9
+
10
+
11
+ if (typeof self !== 'undefined') {
12
+ return self;
13
+ }
14
+
15
+ return window;
16
+ }();
17
+
18
+ var btoa = globalObject.btoa;
19
+ export default btoa;
@@ -0,0 +1,15 @@
1
+ import { Buffer } from 'buffer';
2
+
3
+ var btoa = function btoa(val) {
4
+ var buffer;
5
+
6
+ if (val instanceof Buffer) {
7
+ buffer = val;
8
+ } else {
9
+ buffer = Buffer.from(val.toString(), 'binary');
10
+ }
11
+
12
+ return buffer.toString('base64');
13
+ };
14
+
15
+ export default btoa;
File without changes
package/es/index.js CHANGED
@@ -7,7 +7,7 @@ import Resolver, { clearCache } from './resolver.js';
7
7
  import resolveSubtree from './subtree-resolver/index.js';
8
8
  import { makeApisTagOperation } from './interfaces.js';
9
9
  import { execute, buildRequest, baseUrl } from './execute/index.js';
10
- import { opId } from './helpers.js';
10
+ import { opId } from './helpers/index.js';
11
11
  Swagger.http = Http;
12
12
  Swagger.makeHttp = makeHttp.bind(null, Swagger.http);
13
13
  Swagger.resolve = Resolver;
package/es/interfaces.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import _objectSpread from "@babel/runtime-corejs3/helpers/objectSpread2";
2
2
  import _concatInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/concat";
3
- import { eachOperation, opId } from './helpers.js';
3
+ import { eachOperation, opId } from './helpers/index.js';
4
4
 
5
5
  var nullFn = function nullFn() {
6
6
  return null;
package/es/resolver.js CHANGED
@@ -2,7 +2,7 @@ import _asyncToGenerator from "@babel/runtime-corejs3/helpers/asyncToGenerator";
2
2
  import _regeneratorRuntime from "@babel/runtime-corejs3/regenerator";
3
3
  import Http from './http/index.js';
4
4
  import mapSpec, { plugins } from './specmap/index.js';
5
- import { normalizeSwagger } from './helpers.js';
5
+ import { normalizeSwagger } from './helpers/index.js';
6
6
  import { ACCEPT_HEADER_VALUE_FOR_DOCUMENTS } from './constants.js';
7
7
  export function makeFetchJSON(http) {
8
8
  var opts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
@@ -77,15 +77,24 @@ export default {
77
77
  });
78
78
  patches.push.apply(patches, _toConsumableArray(absoluteRefPatches));
79
79
  return undefined;
80
- }); // Merge back the values from the original definition
80
+ }); // If there was an example in the original definition,
81
+ // keep it instead of merging with examples from other schema
82
+
83
+ if (originalDefinitionObj.example) {
84
+ var _context2;
85
+
86
+ // Delete other schema examples
87
+ patches.push(specmap.remove(_concatInstanceProperty(_context2 = []).call(_context2, parent, 'example')));
88
+ } // Merge back the values from the original definition
89
+
81
90
 
82
91
  patches.push(specmap.mergeDeep(parent, originalDefinitionObj)); // If there was not an original $$ref value, make sure to remove
83
92
  // any $$ref value that may exist from the result of `allOf` merges
84
93
 
85
94
  if (!originalDefinitionObj.$$ref) {
86
- var _context2;
95
+ var _context3;
87
96
 
88
- patches.push(specmap.remove(_concatInstanceProperty(_context2 = []).call(_context2, parent, '$$ref')));
97
+ patches.push(specmap.remove(_concatInstanceProperty(_context3 = []).call(_context3, parent, '$$ref')));
89
98
  }
90
99
 
91
100
  return patches;
@@ -25,7 +25,7 @@ import _regeneratorRuntime from "@babel/runtime-corejs3/regenerator";
25
25
  // TODO: move the remarks above into project documentation
26
26
  import get from 'lodash/get';
27
27
  import resolve from '../resolver.js';
28
- import { normalizeSwagger } from '../helpers.js';
28
+ import { normalizeSwagger } from '../helpers/index.js';
29
29
  export default function resolveSubtree(_x, _x2) {
30
30
  return _resolveSubtree.apply(this, arguments);
31
31
  }
@@ -26,7 +26,7 @@ var _buildRequest = _interopRequireDefault(require("./oas3/build-request.js"));
26
26
 
27
27
  var _buildRequest2 = _interopRequireDefault(require("./swagger2/build-request.js"));
28
28
 
29
- var _helpers = require("../helpers.js");
29
+ var _index2 = require("../helpers/index.js");
30
30
 
31
31
  const _excluded = ["http", "fetch", "spec", "operationId", "pathName", "method", "parameters", "securities"];
32
32
 
@@ -100,7 +100,7 @@ function execute(_ref) {
100
100
  const http = userHttp || fetch || _index.default; // Default to _our_ http
101
101
 
102
102
  if (pathName && method && !operationId) {
103
- operationId = (0, _helpers.legacyIdFromPathMethod)(pathName, method);
103
+ operationId = (0, _index2.legacyIdFromPathMethod)(pathName, method);
104
104
  }
105
105
 
106
106
  const request = self.buildRequest(_objectSpread({
@@ -139,7 +139,7 @@ function buildRequest(options) {
139
139
  parameters,
140
140
  parameterBuilders
141
141
  } = options;
142
- const specIsOAS3 = (0, _helpers.isOAS3)(spec);
142
+ const specIsOAS3 = (0, _index2.isOAS3)(spec);
143
143
 
144
144
  if (!parameterBuilders) {
145
145
  // user did not provide custom parameter builders
@@ -176,7 +176,7 @@ function buildRequest(options) {
176
176
  req.userFetch = userFetch;
177
177
  }
178
178
 
179
- const operationRaw = (0, _helpers.getOperationRaw)(spec, operationId);
179
+ const operationRaw = (0, _index2.getOperationRaw)(spec, operationId);
180
180
 
181
181
  if (!operationRaw) {
182
182
  throw new OperationNotFoundError(`Operation ${operationId} not found`);
@@ -315,7 +315,7 @@ const stripNonAlpha = str => str ? str.replace(/\W/g, '') : null; // be careful
315
315
 
316
316
 
317
317
  function baseUrl(obj) {
318
- const specIsOAS3 = (0, _helpers.isOAS3)(obj.spec);
318
+ const specIsOAS3 = (0, _index2.isOAS3)(obj.spec);
319
319
  return specIsOAS3 ? oas3BaseUrl(obj) : swagger2BaseUrl(obj);
320
320
  }
321
321
 
@@ -8,7 +8,7 @@ var _isPlainObject = require("is-plain-object");
8
8
 
9
9
  var _get = _interopRequireDefault(require("lodash/get"));
10
10
 
11
- var _btoa = _interopRequireDefault(require("btoa"));
11
+ var _btoaNode = _interopRequireDefault(require("../../helpers/btoa.node.js"));
12
12
 
13
13
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
14
14
 
@@ -151,7 +151,7 @@ function applySecurities({
151
151
  if (/^basic$/i.test(schema.scheme)) {
152
152
  const username = value.username || '';
153
153
  const password = value.password || '';
154
- const encoded = (0, _btoa.default)(`${username}:${password}`);
154
+ const encoded = (0, _btoaNode.default)(`${username}:${password}`);
155
155
  result.headers.Authorization = `Basic ${encoded}`;
156
156
  }
157
157
 
@@ -4,7 +4,7 @@ exports.__esModule = true;
4
4
  exports.applySecurities = applySecurities;
5
5
  exports.default = buildRequest;
6
6
 
7
- var _btoa = _interopRequireDefault(require("btoa"));
7
+ var _btoaNode = _interopRequireDefault(require("../../helpers/btoa.node.js"));
8
8
 
9
9
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
10
10
 
@@ -116,7 +116,7 @@ function applySecurities({
116
116
  } else {
117
117
  const username = value.username || '';
118
118
  const password = value.password || '';
119
- value.base64 = (0, _btoa.default)(`${username}:${password}`);
119
+ value.base64 = (0, _btoaNode.default)(`${username}:${password}`);
120
120
  result.headers.authorization = `Basic ${value.base64}`;
121
121
  }
122
122
  } else if (type === 'oauth2' && oauthToken) {
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+
3
+ exports.__esModule = true;
4
+ exports.default = void 0;
5
+
6
+ /* eslint-disable no-undef, no-restricted-globals */
7
+ const globalObject = (() => {
8
+ // new standardized access to the global object
9
+ if (typeof globalThis !== 'undefined') {
10
+ return globalThis;
11
+ } // WebWorker specific access
12
+
13
+
14
+ if (typeof self !== 'undefined') {
15
+ return self;
16
+ }
17
+
18
+ return window;
19
+ })();
20
+
21
+ const {
22
+ btoa
23
+ } = globalObject;
24
+ var _default = btoa;
25
+ exports.default = _default;
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+
3
+ exports.__esModule = true;
4
+ exports.default = void 0;
5
+
6
+ var _buffer = require("buffer");
7
+
8
+ const btoa = val => {
9
+ let buffer;
10
+
11
+ if (val instanceof _buffer.Buffer) {
12
+ buffer = val;
13
+ } else {
14
+ buffer = _buffer.Buffer.from(val.toString(), 'binary');
15
+ }
16
+
17
+ return buffer.toString('base64');
18
+ };
19
+
20
+ var _default = btoa;
21
+ exports.default = _default;
File without changes
package/lib/index.js CHANGED
@@ -15,7 +15,7 @@ var _interfaces = require("./interfaces.js");
15
15
 
16
16
  var _index3 = require("./execute/index.js");
17
17
 
18
- var _helpers = require("./helpers.js");
18
+ var _index4 = require("./helpers/index.js");
19
19
 
20
20
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
21
21
 
@@ -40,7 +40,7 @@ Swagger.clearCache = _resolver.clearCache;
40
40
  Swagger.makeApisTagOperation = _interfaces.makeApisTagOperation;
41
41
  Swagger.buildRequest = _index3.buildRequest;
42
42
  Swagger.helpers = {
43
- opId: _helpers.opId
43
+ opId: _index4.opId
44
44
  };
45
45
  Swagger.getBaseUrl = _index3.baseUrl;
46
46
 
package/lib/interfaces.js CHANGED
@@ -7,7 +7,7 @@ exports.makeExecute = makeExecute;
7
7
  exports.mapTagOperations = mapTagOperations;
8
8
  exports.self = void 0;
9
9
 
10
- var _helpers = require("./helpers.js");
10
+ var _index = require("./helpers/index.js");
11
11
 
12
12
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
13
13
 
@@ -113,7 +113,7 @@ function mapTagOperations({
113
113
  const operationIdCounter = {};
114
114
  const tagOperations = {}; // Will house all tags + operations
115
115
 
116
- (0, _helpers.eachOperation)(spec, ({
116
+ (0, _index.eachOperation)(spec, ({
117
117
  pathName,
118
118
  method,
119
119
  operation
@@ -126,7 +126,7 @@ function mapTagOperations({
126
126
 
127
127
  tagOperations[tag] = tagOperations[tag] || {};
128
128
  const tagObj = tagOperations[tag];
129
- const id = (0, _helpers.opId)(operation, pathName, method, {
129
+ const id = (0, _index.opId)(operation, pathName, method, {
130
130
  v2OperationIdCompatibilityMode
131
131
  });
132
132
  const cbResult = cb({
package/lib/resolver.js CHANGED
@@ -9,7 +9,7 @@ var _index = _interopRequireDefault(require("./http/index.js"));
9
9
 
10
10
  var _index2 = _interopRequireWildcard(require("./specmap/index.js"));
11
11
 
12
- var _helpers = require("./helpers.js");
12
+ var _index3 = require("./helpers/index.js");
13
13
 
14
14
  var _constants = require("./constants.js");
15
15
 
@@ -116,6 +116,6 @@ function resolve(obj) {
116
116
  parameterMacro,
117
117
  modelPropertyMacro,
118
118
  useCircularStructures
119
- }).then(skipNormalization ? async a => a : _helpers.normalizeSwagger);
119
+ }).then(skipNormalization ? async a => a : _index3.normalizeSwagger);
120
120
  }
121
121
  }
@@ -77,7 +77,14 @@ var _default = {
77
77
  });
78
78
  patches.push(...absoluteRefPatches);
79
79
  return undefined;
80
- }); // Merge back the values from the original definition
80
+ }); // If there was an example in the original definition,
81
+ // keep it instead of merging with examples from other schema
82
+
83
+ if (originalDefinitionObj.example) {
84
+ // Delete other schema examples
85
+ patches.push(specmap.remove([].concat(parent, 'example')));
86
+ } // Merge back the values from the original definition
87
+
81
88
 
82
89
  patches.push(specmap.mergeDeep(parent, originalDefinitionObj)); // If there was not an original $$ref value, make sure to remove
83
90
  // any $$ref value that may exist from the result of `allOf` merges
@@ -7,7 +7,7 @@ var _get = _interopRequireDefault(require("lodash/get"));
7
7
 
8
8
  var _resolver = _interopRequireDefault(require("../resolver.js"));
9
9
 
10
- var _helpers = require("../helpers.js");
10
+ var _index = require("../helpers/index.js");
11
11
 
12
12
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13
13
 
@@ -38,7 +38,7 @@ async function resolveSubtree(obj, path, opts = {}) {
38
38
  };
39
39
  const {
40
40
  spec: normalized
41
- } = (0, _helpers.normalizeSwagger)({
41
+ } = (0, _index.normalizeSwagger)({
42
42
  spec: obj
43
43
  });
44
44
  const result = await (0, _resolver.default)(_objectSpread(_objectSpread({}, resolveOptions), {}, {
package/package.json CHANGED
@@ -1,11 +1,14 @@
1
1
  {
2
2
  "name": "swagger-client",
3
- "version": "3.18.2",
3
+ "version": "3.18.5",
4
4
  "description": "SwaggerJS - a collection of interfaces for OAI specs",
5
5
  "browser": {
6
6
  "./src/http/fold-formdata-to-request.node.js": "./src/http/fold-formdata-to-request.browser.js",
7
7
  "./lib/http/fold-formdata-to-request.node.js": "./lib/http/fold-formdata-to-request.browser.js",
8
- "./es/http/fold-formdata-to-request.node.js": "./es/http/fold-formdata-to-request.browser.js"
8
+ "./es/http/fold-formdata-to-request.node.js": "./es/http/fold-formdata-to-request.browser.js",
9
+ "./src/helpers/btoa.node.js": "./src/helpers/btoa.browser.js",
10
+ "./lib/helpers/btoa.node.js": "./lib/helpers/btoa.browser.js",
11
+ "./es/helpers/btoa.node.js": "./es/helpers/btoa.browser.js"
9
12
  },
10
13
  "main": "lib/commonjs.js",
11
14
  "module": "es/index.js",
@@ -63,52 +66,51 @@
63
66
  ],
64
67
  "license": "Apache-2.0",
65
68
  "devDependencies": {
66
- "@babel/cli": "=7.16.8",
67
- "@babel/core": "=7.16.7",
69
+ "@babel/cli": "=7.17.10",
70
+ "@babel/core": "=7.17.10",
68
71
  "@babel/plugin-proposal-class-properties": "=7.16.7",
69
- "@babel/plugin-proposal-object-rest-spread": "=7.16.7",
70
- "@babel/plugin-transform-runtime": "=7.16.8",
71
- "@babel/preset-env": "=7.16.8",
72
- "@babel/register": "=7.16.9",
72
+ "@babel/plugin-proposal-object-rest-spread": "=7.17.3",
73
+ "@babel/plugin-transform-runtime": "=7.17.10",
74
+ "@babel/preset-env": "=7.17.10",
75
+ "@babel/register": "=7.17.7",
73
76
  "@commitlint/cli": "^16.0.1",
74
77
  "@commitlint/config-conventional": "^16.0.0",
75
78
  "abort-controller": "^3.0.0",
76
- "babel-loader": "=8.2.3",
79
+ "babel-loader": "=8.2.5",
77
80
  "babel-plugin-lodash": "=3.3.4",
78
81
  "cross-env": "=7.0.3",
79
82
  "eslint": "^8.2.0",
80
83
  "eslint-config-airbnb-base": "^15.0.0",
81
- "eslint-config-prettier": "=8.3.0",
82
- "eslint-plugin-import": "=2.25.4",
84
+ "eslint-config-prettier": "=8.5.0",
85
+ "eslint-plugin-import": "=2.26.0",
83
86
  "eslint-plugin-prettier": "=4.0.0",
84
- "expect": "=27.4.6",
87
+ "expect": "=27.5.1",
85
88
  "fetch-mock": "=9.11.0",
86
- "glob": "=7.2.0",
89
+ "glob": "=8.0.1",
87
90
  "husky": "^7.0.1",
88
91
  "inspectpack": "=4.7.1",
89
92
  "install": "=0.13.0",
90
93
  "jest": "^27.0.1",
91
94
  "json-loader": "=0.5.7",
92
95
  "license-checker": "=25.0.1",
93
- "lint-staged": "=12.2.0",
96
+ "lint-staged": "=12.4.1",
94
97
  "lodash-webpack-plugin": "=0.11.6",
95
- "nock": "=13.2.2",
96
- "node-fetch": "=2.6.1",
98
+ "nock": "=13.2.4",
99
+ "node-fetch": "^2.6.7",
97
100
  "npm-run-all": "=4.1.5",
98
101
  "prettier": "^2.3.0",
99
102
  "rimraf": "=3.0.2",
100
103
  "terser-webpack-plugin": "^5.0.3",
101
- "webpack": "=5.66.0",
104
+ "webpack": "=5.72.0",
102
105
  "webpack-bundle-size-analyzer": "=3.1.0",
103
- "webpack-cli": "=4.9.1",
106
+ "webpack-cli": "=4.9.2",
104
107
  "webpack-stats-plugin": "=1.0.3",
105
108
  "xmock": "=0.3.0"
106
109
  },
107
110
  "dependencies": {
108
111
  "@babel/runtime-corejs3": "^7.11.2",
109
- "btoa": "^1.2.1",
110
- "cookie": "~0.4.1",
111
- "cross-fetch": "^3.1.4",
112
+ "cookie": "~0.5.0",
113
+ "cross-fetch": "^3.1.5",
112
114
  "deepmerge": "~4.2.2",
113
115
  "fast-json-patch": "^3.0.0-1",
114
116
  "form-data-encoder": "^1.4.3",