@sungen/driver-api 3.2.22-beta.1 → 3.2.22-beta.2

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sungen/driver-api",
3
- "version": "3.2.22-beta.1",
3
+ "version": "3.2.22-beta.2",
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.22-beta.1",
16
+ "@sun-asterisk/sungen": "3.2.22-beta.2",
17
17
  "commander": "^14.0.2",
18
18
  "yaml": "^2.8.2"
19
19
  },
@@ -176,6 +176,13 @@ export function validateApiEntry(entry: ApiEntry, datasourceNames: string[] | nu
176
176
  // files are always sent as multipart; an explicit json/form encoding contradicts that.
177
177
  if (entry.encoding && entry.encoding !== 'multipart') errs.push(`api "${entry.name}": has files: but encoding: ${entry.encoding} — a file upload must be multipart (omit encoding).`);
178
178
  }
179
+ // A GET/HEAD request may not carry a body — fetch/undici refuses one, so the runtime would have to
180
+ // drop it. Catch the contradiction HERE, in the catalog the author wrote, rather than let a request
181
+ // go out silently shorter than the entry says it is.
182
+ const carriesBody = entry.body !== undefined || !!(entry.files && Object.keys(entry.files).length) || !!entry.bodyFile;
183
+ if ((entry.method === 'GET' || entry.method === 'HEAD') && carriesBody) {
184
+ errs.push(`api "${entry.name}": a ${entry.method} request cannot carry a body — remove body:/files:/bodyFile:, or change method: to POST/PUT/PATCH.`);
185
+ }
179
186
  if (entry.bodyFile && !entry.bodyFile.path) errs.push(`api "${entry.name}": bodyFile has no path.`);
180
187
  if (entry.bodyFile && entry.files) errs.push(`api "${entry.name}": use either files: (multipart form parts) or bodyFile: (raw binary body), not both.`);
181
188
  if (entry.bodyFile && entry.body !== undefined) errs.push(`api "${entry.name}": bodyFile: (raw binary body) cannot combine with a body:.`);