fix(openapi): make unsupported-method warning reachable

Merged
H3
5mo ago
+19-6

Problem

P3 dead-code bug introduced in #88. convert() pre-filtered operations to SUPPORTED_HTTP_METHODS:

if method.upper() in SUPPORTED_HTTP_METHODS:
    tool = self._create_tool(...)

So unsupported verbs (options/head/trace) never reached _create_tool, making its validation guard — and the intended skip warning — unreachable dead code.

Root cause

The method check was duplicated: once in the loop filter, once in _create_tool. The loop filter excluded exactly the methods the inner guard was meant to warn about.

Fix

Split into two sets:

  • OPENAPI_OPERATION_METHODS (get/put/post/delete/options/head/patch/trace) — used by the loop only to tell operations apart from non-operation path-item keys (parameters, summary, $ref, servers).
  • SUPPORTED_HTTP_METHODS (the call-template subset) — _create_tool validates against this and warns+skips anything else.

Now unsupported operations reach _create_tool and emit the warning instead of being silently dropped.

Tests

Strengthened test_openapi_converter_skips_unsupported_methods to assert the warning is actually emitted (via capsys), not just that the tools are absent. Full converter suite: 5 passed.

Bumps utcp-http 1.1.8 → 1.1.9.

Note: the same bug was ported to typescript-utcp; fixed there in PR #27.

🤖 Generated with Claude Code


Summary by cubic

Fixes a dead-code path in the OpenAPI converter so unsupported HTTP methods emit a warning instead of being silently dropped. Ensures all OpenAPI operations reach validation while still skipping non-operation keys.

  • Bug Fixes
    • Introduced OPENAPI_OPERATION_METHODS for loop filtering; kept SUPPORTED_HTTP_METHODS for _create_tool validation.
    • Loop now filters on method.lower() against OpenAPI operations; _create_tool warns and skips options, head, and trace.
    • Strengthened test_openapi_converter_skips_unsupported_methods to assert the warning via capsys.
    • Bumped utcp-http to 1.1.9.