@sungen/driver-api 3.2.14 → 3.2.16
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/package.json +2 -2
- package/src/index.ts +8 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sungen/driver-api",
|
|
3
|
-
"version": "3.2.
|
|
3
|
+
"version": "3.2.16",
|
|
4
4
|
"description": "Sungen API capability — the @api annotation, API catalog, OpenAPI import + `sungen api import`, and the specs/api.ts runtime template. Plugs into @sun-asterisk/sungen via the capability SPI.",
|
|
5
5
|
"main": "src/index.ts",
|
|
6
6
|
"types": "src/index.ts",
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
"author": "eqe team (engineer & quality) — Sun Asterisk",
|
|
14
14
|
"license": "MIT",
|
|
15
15
|
"dependencies": {
|
|
16
|
-
"@sun-asterisk/sungen": "3.2.
|
|
16
|
+
"@sun-asterisk/sungen": "3.2.16",
|
|
17
17
|
"commander": "^14.0.2",
|
|
18
18
|
"yaml": "^2.8.2"
|
|
19
19
|
},
|
package/src/index.ts
CHANGED
|
@@ -28,6 +28,9 @@ import { apiRepair } from './api-repair';
|
|
|
28
28
|
/**
|
|
29
29
|
* Parse `name(a={{x}},b="lit",c=3)` annotation overrides → JS expressions. Inlined from core
|
|
30
30
|
* (was `parseQueryOverrides`) so this driver has NO runtime dependency on @sun-asterisk/sungen.
|
|
31
|
+
* A `{{ref}}` override binds into the request's JSON body/params, so it resolves via
|
|
32
|
+
* `testData.raw()` (native type, still interpolates embedded refs) rather than `get()`
|
|
33
|
+
* (Gherkin-text stringify) — a numeric override otherwise reaches the JSON body as a string.
|
|
31
34
|
*/
|
|
32
35
|
function parseQueryOverrides(raw?: string): Record<string, string> {
|
|
33
36
|
const out: Record<string, string> = {};
|
|
@@ -40,7 +43,7 @@ function parseQueryOverrides(raw?: string): Record<string, string> {
|
|
|
40
43
|
if (!key) continue;
|
|
41
44
|
const v = val.match(/^\{\{\s*([^}]+?)\s*\}\}$/);
|
|
42
45
|
const q = val.match(/^["'](.*)["']$/);
|
|
43
|
-
if (v) out[key] = `testData.
|
|
46
|
+
if (v) out[key] = `testData.raw(${JSON.stringify(v[1])})`;
|
|
44
47
|
else if (q) out[key] = JSON.stringify(q[1]);
|
|
45
48
|
else if (/^-?\d+(?:\.\d+)?$/.test(val)) out[key] = val;
|
|
46
49
|
else out[key] = JSON.stringify(val);
|
|
@@ -81,8 +84,11 @@ function apiPreconditionCodegen(input: { tags: string[]; screenName: string; cwd
|
|
|
81
84
|
const name = m[1];
|
|
82
85
|
const overrides = parseQueryOverrides(m[2]); // same key=value override grammar
|
|
83
86
|
const entry = resolveApi(name, input.screenName, input.cwd); // throws (fail-fast) if missing/ambiguous
|
|
87
|
+
// Bind params with raw() (uncoerced native type), not get() (Gherkin-text stringify) — the
|
|
88
|
+
// runtime body substitution is type-preserving JSON, so a numeric param must reach it as a
|
|
89
|
+
// number, not a JSON string.
|
|
84
90
|
const paramsObj = apiParamNames(entry)
|
|
85
|
-
.map((p) => `${JSON.stringify(p)}: ${p in overrides ? overrides[p] : `testData.
|
|
91
|
+
.map((p) => `${JSON.stringify(p)}: ${p in overrides ? overrides[p] : `testData.raw(${JSON.stringify(p)})`}`)
|
|
86
92
|
.join(', ');
|
|
87
93
|
const label = JSON.stringify(entry.description ? `api "${name}" — ${entry.description}` : `api "${name}"`);
|
|
88
94
|
const ds = entry.datasource ? JSON.stringify(entry.datasource) : 'undefined';
|