Repository navigation
Commit 6d5c021
fix(connector-openapi): path-item parameters reach every operation's input schema (#27981)
domain:server#4 · os-elon-musk · session_016WV4d1Np3hU7RQnA13YZcL
Fixes #27463
## 维护者速读
- 改了什么:`connector-openapi` 的 `collectOperations` 现在把 OpenAPI 3.x Path
Item 上的 `parameters` 合并进该路径下每个操作的参数;操作里 `name` + `in`
相同的条目整条覆盖路径级条目。另加四个固定测试和一个 patch changeset。
- 为什么改:路径级参数从来不被读取,所以在路径上声明的必填 id(GET / PATCH / DELETE 共用的常见写法)不会出现在动作的
`inputSchema` 里,作者和流程设计器看到的输入定义缺了必填项。
- 风险与回滚:只改动作的 `inputSchema`;运行时不会用它校验调用输入,实测缺 `petId`
的调用修复前后一样被派发,没有原本被接受、现在被拒绝的调用。回滚就是 revert 这一个提交。
- 先看:`packages/connectors/connector-openapi/src/openapi-connector.ts` 的
`collectOperations` / `mergeParameters`。
- 两分钟验证:`pnpm --filter @objectstack/connector-openapi test -t
"path-item-level"`,四个测试都绿;把 `openapi-connector.ts` 还原到 base 后,其中三个变红。
- 需要你做的:审阅并合并。另外,经 `normalize-openapi` 转换的 Swagger 2.0
文档也会受益:实测升级器把路径级参数留在 path item 上,并没有下沉到操作里,与卡片描述不同。
Clause-②: no — only the generated action's `inputSchema` gains the
path-level parameters the document already declares; nothing validates a
call's input against it, so every call accepted before is still
dispatched as before (measured end to end).
Metadata-protocol: none
## What changes
- `collectOperations` merges each path item's `parameters` into every
operation under that path: path-level entries first, then the
operation's own. An operation entry with the same `name` + `in` replaces
the path-level one whole (its schema and its `required`), as OpenAPI 3.x
defines. A path-level and an operation-level parameter that share a name
but not `in` are both kept.
- A path item with no `parameters` leaves the operation's array exactly
as it was. A `$ref` entry has no `name`/`in` to match on, so it is kept
as is; `buildInputSchema` skips an unresolved one, as before.
- `OpenApiPathItem` declares the optional `parameters` key.
## Why
The generator built each operation from `record[method]` only, so a
parameter declared once on the path never reached the action's
`inputSchema`. Measured at bacb3e6 through
`createOpenApiProviderFactory`: an OpenAPI 3.0.3 document with
`'/pets/{petId}': { parameters: [{ name: 'petId', in: 'path', required:
true }], get: … }` materialized `getPet` with `inputSchema: null`.
Agents and flows built from that schema call the action wrong.
Swagger 2.0 documents converted by `normalize-openapi` have the same
shape: measured, the upgrader keeps path-level parameters on the path
item (in 3.x form) and does not copy them into operations. They now get
the same fix, and the normalizer's own tests are unchanged and green.
## Verification
- Pins in `openapi-provider.test.ts`, one per shape, all through the
provider factory: path-level only (GET and DELETE both get `petId`,
required), operation override (whole-entry replacement; a concatenation
would keep the path-level `required`), same name with a different `in`
(both kept), and the operation-only control.
- Red first: pins 1–3 red before the fix, the control green. Ablation:
with the fix reverted in the tree, the same three go red and the other
40 tests in the file stay green; restored, the file hash equals the
committed one.
- Clause-②: a real boot (LiteKernel + AutomationServicePlugin +
ConnectorOpenApiPlugin, declared `provider: 'openapi'`) runs a
`connector_action` flow calling `getPet` with `input: {}`. It succeeds
and requests the same URL before and after the fix; nothing refuses it.
- `pnpm --filter @objectstack/connector-openapi test` (67/67),
`typecheck`, `pnpm lint`: all exit 0. `dispatch-gates --ran`: 58
derived, 57 run green, 1 not measured (`check:dual-build-cjs-loads`
needs a whole-tree build), 0 unrun.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
https://claude.ai/code/session_016WV4d1Np3hU7RQnA13YZcL
Co-authored-by: Claude <noreply@anthropic.com>1 parent 50e894d commit 6d5c021
3 files changed
Lines changed: 143 additions & 2 deletions
File tree
- .changeset
- packages/connectors/connector-openapi/src
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
53 | 53 | | |
54 | 54 | | |
55 | 55 | | |
| 56 | + | |
| 57 | + | |
56 | 58 | | |
57 | 59 | | |
58 | 60 | | |
| |||
253 | 255 | | |
254 | 256 | | |
255 | 257 | | |
256 | | - | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
257 | 262 | | |
258 | 263 | | |
259 | 264 | | |
260 | 265 | | |
261 | 266 | | |
| 267 | + | |
262 | 268 | | |
263 | 269 | | |
264 | 270 | | |
265 | | - | |
| 271 | + | |
266 | 272 | | |
267 | 273 | | |
268 | 274 | | |
269 | 275 | | |
270 | 276 | | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
271 | 298 | | |
272 | 299 | | |
273 | 300 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
465 | 465 | | |
466 | 466 | | |
467 | 467 | | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
| 482 | + | |
| 483 | + | |
| 484 | + | |
| 485 | + | |
| 486 | + | |
| 487 | + | |
| 488 | + | |
| 489 | + | |
| 490 | + | |
| 491 | + | |
| 492 | + | |
| 493 | + | |
| 494 | + | |
| 495 | + | |
| 496 | + | |
| 497 | + | |
| 498 | + | |
| 499 | + | |
| 500 | + | |
| 501 | + | |
| 502 | + | |
| 503 | + | |
| 504 | + | |
| 505 | + | |
| 506 | + | |
| 507 | + | |
| 508 | + | |
| 509 | + | |
| 510 | + | |
| 511 | + | |
| 512 | + | |
| 513 | + | |
| 514 | + | |
| 515 | + | |
| 516 | + | |
| 517 | + | |
| 518 | + | |
| 519 | + | |
| 520 | + | |
| 521 | + | |
| 522 | + | |
| 523 | + | |
| 524 | + | |
| 525 | + | |
| 526 | + | |
| 527 | + | |
| 528 | + | |
| 529 | + | |
| 530 | + | |
| 531 | + | |
| 532 | + | |
| 533 | + | |
| 534 | + | |
| 535 | + | |
| 536 | + | |
| 537 | + | |
| 538 | + | |
| 539 | + | |
| 540 | + | |
| 541 | + | |
| 542 | + | |
| 543 | + | |
| 544 | + | |
| 545 | + | |
| 546 | + | |
| 547 | + | |
| 548 | + | |
| 549 | + | |
| 550 | + | |
| 551 | + | |
| 552 | + | |
| 553 | + | |
| 554 | + | |
| 555 | + | |
| 556 | + | |
| 557 | + | |
| 558 | + | |
| 559 | + | |
| 560 | + | |
| 561 | + | |
| 562 | + | |
| 563 | + | |
| 564 | + | |
| 565 | + | |
| 566 | + | |
| 567 | + | |
| 568 | + | |
0 commit comments