@sebspark/openapi-client 1.4.1 → 1.4.3
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/index.js +41 -29
- package/dist/index.mjs +41 -29
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -43,40 +43,52 @@ var import_axios = __toESM(require("axios"));
|
|
|
43
43
|
// src/paramsSerializer.ts
|
|
44
44
|
var encodeParam = (param) => encodeURIComponent(param);
|
|
45
45
|
var encodeValue = (param, encodeCommas = false) => {
|
|
46
|
-
if (
|
|
47
|
-
|
|
46
|
+
if (typeof param === "number" || typeof param === "string") {
|
|
47
|
+
if (encodeCommas) {
|
|
48
|
+
return encodeURIComponent(param);
|
|
49
|
+
}
|
|
50
|
+
return param.toString().split(",").map((p) => encodeURIComponent(p)).join(",");
|
|
48
51
|
}
|
|
49
|
-
return
|
|
52
|
+
return "";
|
|
50
53
|
};
|
|
51
|
-
var paramsSerializer = (format) => (
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
54
|
+
var paramsSerializer = (format) => (params) => {
|
|
55
|
+
if (!params) {
|
|
56
|
+
return "";
|
|
57
|
+
}
|
|
58
|
+
const s = [];
|
|
59
|
+
for (const [key, value] of Object.entries(params)) {
|
|
60
|
+
if (value === void 0) {
|
|
61
|
+
continue;
|
|
56
62
|
}
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
return value.map((arrayValue, ix) => {
|
|
63
|
-
switch (format) {
|
|
64
|
-
case "indices": {
|
|
65
|
-
return `${encodeParam(key)}[${ix}]=${encodeValue(arrayValue)}`;
|
|
66
|
-
}
|
|
67
|
-
case "repeat": {
|
|
68
|
-
return `${encodeParam(key)}=${encodeValue(arrayValue)}`;
|
|
69
|
-
}
|
|
70
|
-
default: {
|
|
71
|
-
return `${encodeParam(key)}[]=${encodeValue(arrayValue)}`;
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
});
|
|
63
|
+
if (Array.isArray(value)) {
|
|
64
|
+
const title = encodeParam(key);
|
|
65
|
+
if (format === "comma") {
|
|
66
|
+
s.push(`${title}=${value.map((v) => encodeValue(v, true)).join(",")}`);
|
|
67
|
+
continue;
|
|
75
68
|
}
|
|
76
|
-
|
|
77
|
-
|
|
69
|
+
value.forEach((v, ix) => {
|
|
70
|
+
const value2 = encodeValue(v);
|
|
71
|
+
switch (format) {
|
|
72
|
+
case "indices": {
|
|
73
|
+
s.push(`${title}[${ix}]=${value2}`);
|
|
74
|
+
break;
|
|
75
|
+
}
|
|
76
|
+
case "repeat": {
|
|
77
|
+
s.push(`${title}=${value2}`);
|
|
78
|
+
break;
|
|
79
|
+
}
|
|
80
|
+
default: {
|
|
81
|
+
s.push(`${title}[]=${value2}`);
|
|
82
|
+
break;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
});
|
|
86
|
+
} else {
|
|
87
|
+
s.push(`${encodeParam(key)}=${encodeValue(value)}`);
|
|
88
|
+
}
|
|
78
89
|
}
|
|
79
|
-
);
|
|
90
|
+
return s.join("&");
|
|
91
|
+
};
|
|
80
92
|
|
|
81
93
|
// src/client.ts
|
|
82
94
|
var TypedClient = (baseURL, globalOptions) => {
|
package/dist/index.mjs
CHANGED
|
@@ -8,40 +8,52 @@ import axios from "axios";
|
|
|
8
8
|
// src/paramsSerializer.ts
|
|
9
9
|
var encodeParam = (param) => encodeURIComponent(param);
|
|
10
10
|
var encodeValue = (param, encodeCommas = false) => {
|
|
11
|
-
if (
|
|
12
|
-
|
|
11
|
+
if (typeof param === "number" || typeof param === "string") {
|
|
12
|
+
if (encodeCommas) {
|
|
13
|
+
return encodeURIComponent(param);
|
|
14
|
+
}
|
|
15
|
+
return param.toString().split(",").map((p) => encodeURIComponent(p)).join(",");
|
|
13
16
|
}
|
|
14
|
-
return
|
|
17
|
+
return "";
|
|
15
18
|
};
|
|
16
|
-
var paramsSerializer = (format) => (
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
19
|
+
var paramsSerializer = (format) => (params) => {
|
|
20
|
+
if (!params) {
|
|
21
|
+
return "";
|
|
22
|
+
}
|
|
23
|
+
const s = [];
|
|
24
|
+
for (const [key, value] of Object.entries(params)) {
|
|
25
|
+
if (value === void 0) {
|
|
26
|
+
continue;
|
|
21
27
|
}
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
return value.map((arrayValue, ix) => {
|
|
28
|
-
switch (format) {
|
|
29
|
-
case "indices": {
|
|
30
|
-
return `${encodeParam(key)}[${ix}]=${encodeValue(arrayValue)}`;
|
|
31
|
-
}
|
|
32
|
-
case "repeat": {
|
|
33
|
-
return `${encodeParam(key)}=${encodeValue(arrayValue)}`;
|
|
34
|
-
}
|
|
35
|
-
default: {
|
|
36
|
-
return `${encodeParam(key)}[]=${encodeValue(arrayValue)}`;
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
});
|
|
28
|
+
if (Array.isArray(value)) {
|
|
29
|
+
const title = encodeParam(key);
|
|
30
|
+
if (format === "comma") {
|
|
31
|
+
s.push(`${title}=${value.map((v) => encodeValue(v, true)).join(",")}`);
|
|
32
|
+
continue;
|
|
40
33
|
}
|
|
41
|
-
|
|
42
|
-
|
|
34
|
+
value.forEach((v, ix) => {
|
|
35
|
+
const value2 = encodeValue(v);
|
|
36
|
+
switch (format) {
|
|
37
|
+
case "indices": {
|
|
38
|
+
s.push(`${title}[${ix}]=${value2}`);
|
|
39
|
+
break;
|
|
40
|
+
}
|
|
41
|
+
case "repeat": {
|
|
42
|
+
s.push(`${title}=${value2}`);
|
|
43
|
+
break;
|
|
44
|
+
}
|
|
45
|
+
default: {
|
|
46
|
+
s.push(`${title}[]=${value2}`);
|
|
47
|
+
break;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
} else {
|
|
52
|
+
s.push(`${encodeParam(key)}=${encodeValue(value)}`);
|
|
53
|
+
}
|
|
43
54
|
}
|
|
44
|
-
);
|
|
55
|
+
return s.join("&");
|
|
56
|
+
};
|
|
45
57
|
|
|
46
58
|
// src/client.ts
|
|
47
59
|
var TypedClient = (baseURL, globalOptions) => {
|