swagger-client 3.18.0 → 3.18.4

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.
package/es/helpers.js CHANGED
@@ -171,7 +171,7 @@ export function normalizeSwagger(parsedSpec) {
171
171
 
172
172
  var operation = path[method];
173
173
 
174
- if (path == null || !_includesInstanceProperty(_context6 = ['object', 'function']).call(_context6, _typeof(path))) {
174
+ if (operation == null || !_includesInstanceProperty(_context6 = ['object', 'function']).call(_context6, _typeof(operation))) {
175
175
  return "continue"; // eslint-disable-line no-continue
176
176
  }
177
177
 
@@ -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;
@@ -1,15 +1,13 @@
1
1
  import _typeof from "@babel/runtime-corejs3/helpers/typeof";
2
2
  import _toConsumableArray from "@babel/runtime-corejs3/helpers/toConsumableArray";
3
- import _defineProperty from "@babel/runtime-corejs3/helpers/defineProperty";
4
3
  import _objectSpread from "@babel/runtime-corejs3/helpers/objectSpread2";
5
4
  import _Object$assign from "@babel/runtime-corejs3/core-js-stable/object/assign";
6
- import _concatInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/concat";
7
5
  import _Object$keys from "@babel/runtime-corejs3/core-js-stable/object/keys";
8
6
  import _mapInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/map";
9
7
  import _filterInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/filter";
8
+ import _concatInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/concat";
10
9
  import * as jsonPatch from 'fast-json-patch';
11
- import deepExtend from 'deep-extend';
12
- import cloneDeep from 'lodash/cloneDeep';
10
+ import deepmerge from 'deepmerge';
13
11
  export default {
14
12
  add: add,
15
13
  replace: replace,
@@ -50,45 +48,11 @@ function applyPatch(obj, patch, opts) {
50
48
 
51
49
  jsonPatch.applyPatch(obj, [replace(patch.path, newValue)]);
52
50
  } else if (patch.op === 'mergeDeep') {
53
- var currentValue = getInByJsonPath(obj, patch.path); // Iterate the properties of the patch
54
- // eslint-disable-next-line no-restricted-syntax, guard-for-in
55
-
56
- for (var prop in patch.value) {
57
- var propVal = patch.value[prop];
58
- var isArray = Array.isArray(propVal);
59
-
60
- if (isArray) {
61
- // deepExtend doesn't merge arrays, so we will do it manually
62
- var existing = currentValue[prop] || [];
63
- currentValue[prop] = _concatInstanceProperty(existing).call(existing, propVal);
64
- } else if (isObject(propVal) && !isArray) {
65
- // If it's an object, iterate it's keys and merge
66
- // if there are conflicting keys, merge deep, otherwise shallow merge
67
- var currentObj = _objectSpread({}, currentValue[prop]); // eslint-disable-next-line no-restricted-syntax
68
-
69
-
70
- for (var key in propVal) {
71
- if (Object.prototype.hasOwnProperty.call(currentObj, key)) {
72
- // if there is a single conflicting key, just deepExtend the entire value
73
- // and break from the loop (since all future keys are also merged)
74
- // We do this because we can't deepExtend two primitives
75
- // (currentObj[key] & propVal[key] may be primitives).
76
- //
77
- // we also deeply assign here, since we aren't in control of
78
- // how deepExtend affects existing nested objects
79
- currentObj = deepExtend(cloneDeep(currentObj), propVal);
80
- break;
81
- } else {
82
- _Object$assign(currentObj, _defineProperty({}, key, propVal[key]));
83
- }
84
- }
85
-
86
- currentValue[prop] = currentObj;
87
- } else {
88
- // It's a primitive, just replace existing
89
- currentValue[prop] = propVal;
90
- }
91
- }
51
+ var currentValue = getInByJsonPath(obj, patch.path);
52
+
53
+ var _newValue = deepmerge(currentValue, patch.value);
54
+
55
+ obj = jsonPatch.applyPatch(obj, [replace(patch.path, _newValue)]).newDocument;
92
56
  } else if (patch.op === 'add' && patch.path === '' && isObject(patch.value)) {
93
57
  // { op: 'add', path: '', value: { a: 1, b: 2 }}
94
58
  // has no effect: json patch refuses to do anything.
@@ -119,9 +83,9 @@ function applyPatch(obj, patch, opts) {
119
83
  if (opts.allowMetaPatches && patch.meta && isAdditiveMutation(patch) && (Array.isArray(patch.value) || isObject(patch.value))) {
120
84
  var _currentValue = getInByJsonPath(obj, patch.path);
121
85
 
122
- var _newValue = _objectSpread(_objectSpread({}, _currentValue), patch.meta);
86
+ var _newValue2 = _objectSpread(_objectSpread({}, _currentValue), patch.meta);
123
87
 
124
- jsonPatch.applyPatch(obj, [replace(patch.path, _newValue)]);
88
+ jsonPatch.applyPatch(obj, [replace(patch.path, _newValue2)]);
125
89
  }
126
90
  }
127
91
 
package/lib/helpers.js CHANGED
@@ -171,7 +171,7 @@ function normalizeSwagger(parsedSpec) {
171
171
  for (const method in path) {
172
172
  const operation = path[method];
173
173
 
174
- if (path == null || !['object', 'function'].includes(typeof path)) {
174
+ if (operation == null || !['object', 'function'].includes(typeof operation)) {
175
175
  continue; // eslint-disable-line no-continue
176
176
  }
177
177
 
@@ -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
@@ -5,9 +5,7 @@ exports.default = void 0;
5
5
 
6
6
  var jsonPatch = _interopRequireWildcard(require("fast-json-patch"));
7
7
 
8
- var _deepExtend = _interopRequireDefault(require("deep-extend"));
9
-
10
- var _cloneDeep = _interopRequireDefault(require("lodash/cloneDeep"));
8
+ var _deepmerge = _interopRequireDefault(require("deepmerge"));
11
9
 
12
10
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13
11
 
@@ -60,47 +58,9 @@ function applyPatch(obj, patch, opts) {
60
58
  Object.assign(newValue, patch.value);
61
59
  jsonPatch.applyPatch(obj, [replace(patch.path, newValue)]);
62
60
  } else if (patch.op === 'mergeDeep') {
63
- const currentValue = getInByJsonPath(obj, patch.path); // Iterate the properties of the patch
64
- // eslint-disable-next-line no-restricted-syntax, guard-for-in
65
-
66
- for (const prop in patch.value) {
67
- const propVal = patch.value[prop];
68
- const isArray = Array.isArray(propVal);
69
-
70
- if (isArray) {
71
- // deepExtend doesn't merge arrays, so we will do it manually
72
- const existing = currentValue[prop] || [];
73
- currentValue[prop] = existing.concat(propVal);
74
- } else if (isObject(propVal) && !isArray) {
75
- // If it's an object, iterate it's keys and merge
76
- // if there are conflicting keys, merge deep, otherwise shallow merge
77
- let currentObj = _objectSpread({}, currentValue[prop]); // eslint-disable-next-line no-restricted-syntax
78
-
79
-
80
- for (const key in propVal) {
81
- if (Object.prototype.hasOwnProperty.call(currentObj, key)) {
82
- // if there is a single conflicting key, just deepExtend the entire value
83
- // and break from the loop (since all future keys are also merged)
84
- // We do this because we can't deepExtend two primitives
85
- // (currentObj[key] & propVal[key] may be primitives).
86
- //
87
- // we also deeply assign here, since we aren't in control of
88
- // how deepExtend affects existing nested objects
89
- currentObj = (0, _deepExtend.default)((0, _cloneDeep.default)(currentObj), propVal);
90
- break;
91
- } else {
92
- Object.assign(currentObj, {
93
- [key]: propVal[key]
94
- });
95
- }
96
- }
97
-
98
- currentValue[prop] = currentObj;
99
- } else {
100
- // It's a primitive, just replace existing
101
- currentValue[prop] = propVal;
102
- }
103
- }
61
+ const currentValue = getInByJsonPath(obj, patch.path);
62
+ const newValue = (0, _deepmerge.default)(currentValue, patch.value);
63
+ obj = jsonPatch.applyPatch(obj, [replace(patch.path, newValue)]).newDocument;
104
64
  } else if (patch.op === 'add' && patch.path === '' && isObject(patch.value)) {
105
65
  // { op: 'add', path: '', value: { a: 1, b: 2 }}
106
66
  // has no effect: json patch refuses to do anything.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "swagger-client",
3
- "version": "3.18.0",
3
+ "version": "3.18.4",
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",
@@ -63,15 +63,15 @@
63
63
  ],
64
64
  "license": "Apache-2.0",
65
65
  "devDependencies": {
66
- "@babel/cli": "=7.16.0",
67
- "@babel/core": "=7.16.5",
68
- "@babel/plugin-proposal-class-properties": "=7.16.5",
69
- "@babel/plugin-proposal-object-rest-spread": "=7.16.5",
70
- "@babel/plugin-transform-runtime": "=7.16.5",
71
- "@babel/preset-env": "=7.16.5",
72
- "@babel/register": "=7.16.5",
73
- "@commitlint/cli": "^15.0.0",
74
- "@commitlint/config-conventional": "^15.0.0",
66
+ "@babel/cli": "=7.16.8",
67
+ "@babel/core": "=7.16.12",
68
+ "@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.10",
71
+ "@babel/preset-env": "=7.16.11",
72
+ "@babel/register": "=7.16.9",
73
+ "@commitlint/cli": "^16.0.1",
74
+ "@commitlint/config-conventional": "^16.0.0",
75
75
  "abort-controller": "^3.0.0",
76
76
  "babel-loader": "=8.2.3",
77
77
  "babel-plugin-lodash": "=3.3.4",
@@ -79,9 +79,9 @@
79
79
  "eslint": "^8.2.0",
80
80
  "eslint-config-airbnb-base": "^15.0.0",
81
81
  "eslint-config-prettier": "=8.3.0",
82
- "eslint-plugin-import": "=2.25.3",
82
+ "eslint-plugin-import": "=2.25.4",
83
83
  "eslint-plugin-prettier": "=4.0.0",
84
- "expect": "=27.4.2",
84
+ "expect": "=27.4.6",
85
85
  "fetch-mock": "=9.11.0",
86
86
  "glob": "=7.2.0",
87
87
  "husky": "^7.0.1",
@@ -90,17 +90,17 @@
90
90
  "jest": "^27.0.1",
91
91
  "json-loader": "=0.5.7",
92
92
  "license-checker": "=25.0.1",
93
- "lint-staged": "=12.1.3",
93
+ "lint-staged": "=12.3.3",
94
94
  "lodash-webpack-plugin": "=0.11.6",
95
- "nock": "=13.2.1",
96
- "node-fetch": "=2.6.1",
95
+ "nock": "=13.2.2",
96
+ "node-fetch": "^2.6.7",
97
97
  "npm-run-all": "=4.1.5",
98
98
  "prettier": "^2.3.0",
99
99
  "rimraf": "=3.0.2",
100
100
  "terser-webpack-plugin": "^5.0.3",
101
- "webpack": "=5.65.0",
101
+ "webpack": "=5.68.0",
102
102
  "webpack-bundle-size-analyzer": "=3.1.0",
103
- "webpack-cli": "=4.9.1",
103
+ "webpack-cli": "=4.9.2",
104
104
  "webpack-stats-plugin": "=1.0.3",
105
105
  "xmock": "=0.3.0"
106
106
  },
@@ -108,8 +108,8 @@
108
108
  "@babel/runtime-corejs3": "^7.11.2",
109
109
  "btoa": "^1.2.1",
110
110
  "cookie": "~0.4.1",
111
- "cross-fetch": "^3.1.4",
112
- "deep-extend": "~0.6.0",
111
+ "cross-fetch": "^3.1.5",
112
+ "deepmerge": "~4.2.2",
113
113
  "fast-json-patch": "^3.0.0-1",
114
114
  "form-data-encoder": "^1.4.3",
115
115
  "formdata-node": "^4.0.0",