swagger-client 3.26.5 → 3.26.7
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/dist/swagger-client.browser.js +62 -55
- package/dist/swagger-client.browser.min.js +1 -1
- package/dist/swagger-client.browser.min.js.map +1 -1
- package/es/execute/oas3/parameter-builders.js +3 -5
- package/es/execute/oas3/style-serializer.js +31 -44
- package/es/http/index.js +3 -7
- package/lib/execute/oas3/parameter-builders.js +2 -4
- package/lib/execute/oas3/style-serializer.js +33 -45
- package/lib/http/index.js +2 -6
- package/package.json +1 -1
|
@@ -658,16 +658,14 @@ function path({
|
|
|
658
658
|
if (value === undefined) return;
|
|
659
659
|
if (content) {
|
|
660
660
|
const effectiveMediaType = Object.keys(content)[0];
|
|
661
|
-
req.url = req.url.split(`{${name}}`).join((0,_style_serializer_js__WEBPACK_IMPORTED_MODULE_0__.
|
|
662
|
-
escape: true
|
|
663
|
-
}));
|
|
661
|
+
req.url = req.url.split(`{${name}}`).join((0,_style_serializer_js__WEBPACK_IMPORTED_MODULE_0__.encodeCharacters)((0,_content_serializer_js__WEBPACK_IMPORTED_MODULE_1__["default"])(value, effectiveMediaType)));
|
|
664
662
|
} else {
|
|
665
663
|
const styledValue = (0,_style_serializer_js__WEBPACK_IMPORTED_MODULE_0__["default"])({
|
|
666
664
|
key: parameter.name,
|
|
667
665
|
value,
|
|
668
666
|
style: style || 'simple',
|
|
669
667
|
explode: explode || false,
|
|
670
|
-
escape:
|
|
668
|
+
escape: 'reserved'
|
|
671
669
|
});
|
|
672
670
|
req.url = req.url.replace(new RegExp(`{${name}}`, 'g'), styledValue);
|
|
673
671
|
}
|
|
@@ -774,37 +772,23 @@ function cookie({
|
|
|
774
772
|
__webpack_require__.r(__webpack_exports__);
|
|
775
773
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
776
774
|
/* harmony export */ "default": () => (/* binding */ stylize),
|
|
777
|
-
/* harmony export */
|
|
775
|
+
/* harmony export */ encodeCharacters: () => (/* binding */ encodeCharacters),
|
|
776
|
+
/* harmony export */ valueEncoder: () => (/* binding */ valueEncoder)
|
|
778
777
|
/* harmony export */ });
|
|
779
778
|
const isRfc3986Reserved = char => ":/?#[]@!$&'()*+,;=".indexOf(char) > -1;
|
|
780
|
-
const
|
|
779
|
+
const isRfc3986Unreserved = char => /^[a-z0-9\-._~]+$/i.test(char);
|
|
781
780
|
|
|
782
781
|
// eslint-disable-next-line default-param-last
|
|
783
|
-
function
|
|
784
|
-
escape
|
|
785
|
-
} = {}, parse) {
|
|
786
|
-
if (typeof str === 'number') {
|
|
787
|
-
str = str.toString();
|
|
788
|
-
}
|
|
789
|
-
if (typeof str !== 'string' || !str.length) {
|
|
790
|
-
return str;
|
|
791
|
-
}
|
|
792
|
-
if (!escape) {
|
|
793
|
-
return str;
|
|
794
|
-
}
|
|
795
|
-
if (parse) {
|
|
796
|
-
return JSON.parse(str);
|
|
797
|
-
}
|
|
798
|
-
|
|
782
|
+
function encodeCharacters(str, characterSet = 'reserved') {
|
|
799
783
|
// In ES6 you can do this quite easily by using the new ... spread operator.
|
|
800
784
|
// This causes the string iterator (another new ES6 feature) to be used internally,
|
|
801
785
|
// and because that iterator is designed to deal with
|
|
802
786
|
// code points rather than UCS-2/UTF-16 code units.
|
|
803
787
|
return [...str].map(char => {
|
|
804
|
-
if (
|
|
788
|
+
if (isRfc3986Unreserved(char)) {
|
|
805
789
|
return char;
|
|
806
790
|
}
|
|
807
|
-
if (isRfc3986Reserved(char) &&
|
|
791
|
+
if (isRfc3986Reserved(char) && characterSet === 'unsafe') {
|
|
808
792
|
return char;
|
|
809
793
|
}
|
|
810
794
|
const encoder = new TextEncoder();
|
|
@@ -824,6 +808,17 @@ function stylize(config) {
|
|
|
824
808
|
}
|
|
825
809
|
return encodePrimitive(config);
|
|
826
810
|
}
|
|
811
|
+
function valueEncoder(value, escape = false) {
|
|
812
|
+
if (Array.isArray(value) || value !== null && typeof value === 'object') {
|
|
813
|
+
value = JSON.stringify(value);
|
|
814
|
+
} else if (typeof value === 'number' || typeof value === 'boolean') {
|
|
815
|
+
value = String(value);
|
|
816
|
+
}
|
|
817
|
+
if (escape && value.length > 0) {
|
|
818
|
+
return encodeCharacters(value, escape);
|
|
819
|
+
}
|
|
820
|
+
return value;
|
|
821
|
+
}
|
|
827
822
|
function encodeArray({
|
|
828
823
|
key,
|
|
829
824
|
value,
|
|
@@ -831,17 +826,14 @@ function encodeArray({
|
|
|
831
826
|
explode,
|
|
832
827
|
escape
|
|
833
828
|
}) {
|
|
834
|
-
const valueEncoder = str => encodeDisallowedCharacters(str, {
|
|
835
|
-
escape
|
|
836
|
-
});
|
|
837
829
|
if (style === 'simple') {
|
|
838
|
-
return value.map(val => valueEncoder(val)).join(',');
|
|
830
|
+
return value.map(val => valueEncoder(val, escape)).join(',');
|
|
839
831
|
}
|
|
840
832
|
if (style === 'label') {
|
|
841
|
-
return `.${value.map(val => valueEncoder(val)).join('.')}`;
|
|
833
|
+
return `.${value.map(val => valueEncoder(val, escape)).join('.')}`;
|
|
842
834
|
}
|
|
843
835
|
if (style === 'matrix') {
|
|
844
|
-
return value.map(val => valueEncoder(val)).reduce((prev, curr) => {
|
|
836
|
+
return value.map(val => valueEncoder(val, escape)).reduce((prev, curr) => {
|
|
845
837
|
if (!prev || explode) {
|
|
846
838
|
return `${prev || ''};${key}=${curr}`;
|
|
847
839
|
}
|
|
@@ -850,15 +842,15 @@ function encodeArray({
|
|
|
850
842
|
}
|
|
851
843
|
if (style === 'form') {
|
|
852
844
|
const after = explode ? `&${key}=` : ',';
|
|
853
|
-
return value.map(val => valueEncoder(val)).join(after);
|
|
845
|
+
return value.map(val => valueEncoder(val, escape)).join(after);
|
|
854
846
|
}
|
|
855
847
|
if (style === 'spaceDelimited') {
|
|
856
848
|
const after = explode ? `${key}=` : '';
|
|
857
|
-
return value.map(val => valueEncoder(val)).join(` ${after}`);
|
|
849
|
+
return value.map(val => valueEncoder(val, escape)).join(` ${after}`);
|
|
858
850
|
}
|
|
859
851
|
if (style === 'pipeDelimited') {
|
|
860
852
|
const after = explode ? `${key}=` : '';
|
|
861
|
-
return value.map(val => valueEncoder(val)).join(`|${after}`);
|
|
853
|
+
return value.map(val => valueEncoder(val, escape)).join(`|${after}`);
|
|
862
854
|
}
|
|
863
855
|
return undefined;
|
|
864
856
|
}
|
|
@@ -869,13 +861,10 @@ function encodeObject({
|
|
|
869
861
|
explode,
|
|
870
862
|
escape
|
|
871
863
|
}) {
|
|
872
|
-
const valueEncoder = str => encodeDisallowedCharacters(str, {
|
|
873
|
-
escape
|
|
874
|
-
});
|
|
875
864
|
const valueKeys = Object.keys(value);
|
|
876
865
|
if (style === 'simple') {
|
|
877
866
|
return valueKeys.reduce((prev, curr) => {
|
|
878
|
-
const val = valueEncoder(value[curr]);
|
|
867
|
+
const val = valueEncoder(value[curr], escape);
|
|
879
868
|
const middleChar = explode ? '=' : ',';
|
|
880
869
|
const prefix = prev ? `${prev},` : '';
|
|
881
870
|
return `${prefix}${curr}${middleChar}${val}`;
|
|
@@ -883,7 +872,7 @@ function encodeObject({
|
|
|
883
872
|
}
|
|
884
873
|
if (style === 'label') {
|
|
885
874
|
return valueKeys.reduce((prev, curr) => {
|
|
886
|
-
const val = valueEncoder(value[curr]);
|
|
875
|
+
const val = valueEncoder(value[curr], escape);
|
|
887
876
|
const middleChar = explode ? '=' : '.';
|
|
888
877
|
const prefix = prev ? `${prev}.` : '.';
|
|
889
878
|
return `${prefix}${curr}${middleChar}${val}`;
|
|
@@ -891,7 +880,7 @@ function encodeObject({
|
|
|
891
880
|
}
|
|
892
881
|
if (style === 'matrix' && explode) {
|
|
893
882
|
return valueKeys.reduce((prev, curr) => {
|
|
894
|
-
const val = valueEncoder(value[curr]);
|
|
883
|
+
const val = valueEncoder(value[curr], escape);
|
|
895
884
|
const prefix = prev ? `${prev};` : ';';
|
|
896
885
|
return `${prefix}${curr}=${val}`;
|
|
897
886
|
}, '');
|
|
@@ -899,14 +888,14 @@ function encodeObject({
|
|
|
899
888
|
if (style === 'matrix') {
|
|
900
889
|
// no explode
|
|
901
890
|
return valueKeys.reduce((prev, curr) => {
|
|
902
|
-
const val = valueEncoder(value[curr]);
|
|
891
|
+
const val = valueEncoder(value[curr], escape);
|
|
903
892
|
const prefix = prev ? `${prev},` : `;${key}=`;
|
|
904
893
|
return `${prefix}${curr},${val}`;
|
|
905
894
|
}, '');
|
|
906
895
|
}
|
|
907
896
|
if (style === 'form') {
|
|
908
897
|
return valueKeys.reduce((prev, curr) => {
|
|
909
|
-
const val = valueEncoder(value[curr]);
|
|
898
|
+
const val = valueEncoder(value[curr], escape);
|
|
910
899
|
const prefix = prev ? `${prev}${explode ? '&' : ','}` : '';
|
|
911
900
|
const separator = explode ? '=' : ',';
|
|
912
901
|
return `${prefix}${curr}${separator}${val}`;
|
|
@@ -920,23 +909,20 @@ function encodePrimitive({
|
|
|
920
909
|
style,
|
|
921
910
|
escape
|
|
922
911
|
}) {
|
|
923
|
-
const valueEncoder = str => encodeDisallowedCharacters(str, {
|
|
924
|
-
escape
|
|
925
|
-
});
|
|
926
912
|
if (style === 'simple') {
|
|
927
|
-
return valueEncoder(value);
|
|
913
|
+
return valueEncoder(value, escape);
|
|
928
914
|
}
|
|
929
915
|
if (style === 'label') {
|
|
930
|
-
return `.${valueEncoder(value)}`;
|
|
916
|
+
return `.${valueEncoder(value, escape)}`;
|
|
931
917
|
}
|
|
932
918
|
if (style === 'matrix') {
|
|
933
|
-
return `;${key}=${valueEncoder(value)}`;
|
|
919
|
+
return `;${key}=${valueEncoder(value, escape)}`;
|
|
934
920
|
}
|
|
935
921
|
if (style === 'form') {
|
|
936
|
-
return valueEncoder(value);
|
|
922
|
+
return valueEncoder(value, escape);
|
|
937
923
|
}
|
|
938
924
|
if (style === 'deepObject') {
|
|
939
|
-
return valueEncoder(value,
|
|
925
|
+
return valueEncoder(value, escape);
|
|
940
926
|
}
|
|
941
927
|
return undefined;
|
|
942
928
|
}
|
|
@@ -1857,12 +1843,8 @@ function formatKeyValueBySerializationOption(key, value, skipEncoding, serializa
|
|
|
1857
1843
|
const explode = typeof serializationOption.explode === 'undefined' ? style === 'form' : serializationOption.explode;
|
|
1858
1844
|
// eslint-disable-next-line no-nested-ternary
|
|
1859
1845
|
const escape = skipEncoding ? false : serializationOption && serializationOption.allowReserved ? 'unsafe' : 'reserved';
|
|
1860
|
-
const encodeFn = v => (0,_execute_oas3_style_serializer_js__WEBPACK_IMPORTED_MODULE_2__.
|
|
1861
|
-
|
|
1862
|
-
});
|
|
1863
|
-
const encodeKeyFn = skipEncoding ? k => k : k => (0,_execute_oas3_style_serializer_js__WEBPACK_IMPORTED_MODULE_2__.encodeDisallowedCharacters)(k, {
|
|
1864
|
-
escape
|
|
1865
|
-
});
|
|
1846
|
+
const encodeFn = v => (0,_execute_oas3_style_serializer_js__WEBPACK_IMPORTED_MODULE_2__.valueEncoder)(v, escape);
|
|
1847
|
+
const encodeKeyFn = skipEncoding ? k => k : k => encodeFn(k);
|
|
1866
1848
|
|
|
1867
1849
|
// Primitive
|
|
1868
1850
|
if (typeof value !== 'object') {
|
|
@@ -20654,6 +20636,14 @@ const mergeAll = (visitors, {
|
|
|
20654
20636
|
const visitFn = visitFnGetter(visitors[i], nodeTypeGetter(currentNode), false);
|
|
20655
20637
|
if (typeof visitFn === 'function') {
|
|
20656
20638
|
const result = visitFn.call(visitors[i], currentNode, ...rest);
|
|
20639
|
+
|
|
20640
|
+
// check if the visitor is async
|
|
20641
|
+
if (typeof (result === null || result === void 0 ? void 0 : result.then) === 'function') {
|
|
20642
|
+
throw new _swagger_api_apidom_error__WEBPACK_IMPORTED_MODULE_0__["default"]('Async visitor not supported in sync mode', {
|
|
20643
|
+
visitor: visitors[i],
|
|
20644
|
+
visitFn
|
|
20645
|
+
});
|
|
20646
|
+
}
|
|
20657
20647
|
if (result === skipVisitingNodeSymbol) {
|
|
20658
20648
|
skipping[i] = node;
|
|
20659
20649
|
} else if (result === breakSymbol) {
|
|
@@ -20679,6 +20669,14 @@ const mergeAll = (visitors, {
|
|
|
20679
20669
|
const visitFn = visitFnGetter(visitors[i], nodeTypeGetter(node), true);
|
|
20680
20670
|
if (typeof visitFn === 'function') {
|
|
20681
20671
|
const result = visitFn.call(visitors[i], node, ...rest);
|
|
20672
|
+
|
|
20673
|
+
// check if the visitor is async
|
|
20674
|
+
if (typeof (result === null || result === void 0 ? void 0 : result.then) === 'function') {
|
|
20675
|
+
throw new _swagger_api_apidom_error__WEBPACK_IMPORTED_MODULE_0__["default"]('Async visitor not supported in sync mode', {
|
|
20676
|
+
visitor: visitors[i],
|
|
20677
|
+
visitFn
|
|
20678
|
+
});
|
|
20679
|
+
}
|
|
20682
20680
|
if (result === breakSymbol) {
|
|
20683
20681
|
skipping[i] = breakSymbol;
|
|
20684
20682
|
} else if (result !== undefined && result !== skipVisitingNodeSymbol) {
|
|
@@ -20922,6 +20920,7 @@ visitor, {
|
|
|
20922
20920
|
}
|
|
20923
20921
|
let result;
|
|
20924
20922
|
if (!Array.isArray(node)) {
|
|
20923
|
+
var _result;
|
|
20925
20924
|
if (!nodePredicate(node)) {
|
|
20926
20925
|
throw new _swagger_api_apidom_error__WEBPACK_IMPORTED_MODULE_0__["default"](`Invalid AST Node: ${String(node)}`, {
|
|
20927
20926
|
node
|
|
@@ -20943,6 +20942,14 @@ visitor, {
|
|
|
20943
20942
|
// retrieve result
|
|
20944
20943
|
result = visitFn.call(visitor, node, key, parent, path, ancestors);
|
|
20945
20944
|
}
|
|
20945
|
+
|
|
20946
|
+
// check if the visitor is async
|
|
20947
|
+
if (typeof ((_result = result) === null || _result === void 0 ? void 0 : _result.then) === 'function') {
|
|
20948
|
+
throw new _swagger_api_apidom_error__WEBPACK_IMPORTED_MODULE_0__["default"]('Async visitor not supported in sync mode', {
|
|
20949
|
+
visitor,
|
|
20950
|
+
visitFn
|
|
20951
|
+
});
|
|
20952
|
+
}
|
|
20946
20953
|
if (result === breakSymbol) {
|
|
20947
20954
|
break;
|
|
20948
20955
|
}
|