mock-fried 1.2.0 → 1.2.1
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/module.json
CHANGED
|
@@ -26,16 +26,26 @@ function parseApiFile(filePath, fileName) {
|
|
|
26
26
|
const summary = jsdocLines[jsdocLines.length - 1] || jsdocLines[0] || operationId;
|
|
27
27
|
const body = methodBodies.get(operationId);
|
|
28
28
|
if (!body) continue;
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
29
|
+
let path;
|
|
30
|
+
const urlPathMatch = body.match(/let\s+urlPath\s*=\s*`([^`]+)`/);
|
|
31
|
+
if (urlPathMatch?.[1]) {
|
|
32
|
+
path = urlPathMatch[1];
|
|
33
|
+
path = path.replace(/\$\{[^}]+\}/g, (match2) => {
|
|
34
|
+
const paramName = match2.match(/requestParameters(?:\.(\w+)|\["?(\w+)"?\])/)?.[1] || match2.match(/requestParameters(?:\.(\w+)|\["?(\w+)"?\])/)?.[2];
|
|
35
|
+
if (paramName) {
|
|
36
|
+
return `{${paramName}}`;
|
|
37
|
+
}
|
|
38
|
+
return "";
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
if (!path) {
|
|
42
|
+
const requestPathMatch = body.match(/path:\s*`([^`]+)`/);
|
|
43
|
+
if (requestPathMatch?.[1]) {
|
|
44
|
+
path = requestPathMatch[1];
|
|
45
|
+
path = path.replace(/\{\$\{["']?(\w+)["']?\}\}/g, "{$1}");
|
|
36
46
|
}
|
|
37
|
-
|
|
38
|
-
|
|
47
|
+
}
|
|
48
|
+
if (!path) continue;
|
|
39
49
|
const methodMatch = body.match(/method:\s*'(\w+)'/);
|
|
40
50
|
const method = methodMatch?.[1] || "GET";
|
|
41
51
|
const pathParams = [];
|
|
@@ -51,10 +61,10 @@ function parseApiFile(filePath, fileName) {
|
|
|
51
61
|
}
|
|
52
62
|
}
|
|
53
63
|
const queryParams = [];
|
|
54
|
-
const queryParamRegex = /if\s*\(requestParameters\[
|
|
64
|
+
const queryParamRegex = /if\s*\(requestParameters(?:\.(\w+)|\[['"](\w+)['"]\])\s*!==?\s*(?:undefined|null)\)\s*\{\s*queryParameters\[['"](\w+)['"]\]/g;
|
|
55
65
|
let qpm;
|
|
56
66
|
while ((qpm = queryParamRegex.exec(body)) !== null) {
|
|
57
|
-
const paramName = qpm[2];
|
|
67
|
+
const paramName = qpm[3] || qpm[1] || qpm[2];
|
|
58
68
|
if (paramName) {
|
|
59
69
|
queryParams.push({
|
|
60
70
|
name: paramName,
|