Skip to content

APR-191: Add OpenAPI direct discovery path, remove UTCP Tool[] from core pipeline#41

Open
JacobSampson wants to merge 1 commit into
mainfrom
APR-191/add-openapi-discovery
Open

APR-191: Add OpenAPI direct discovery path, remove UTCP Tool[] from core pipeline#41
JacobSampson wants to merge 1 commit into
mainfrom
APR-191/add-openapi-discovery

Conversation

@JacobSampson

Copy link
Copy Markdown
Contributor

Summary

  • Introduces DiscoveredOperation as a unified pointer type replacing UTCP's Tool[] across all type-generation functions — buildClientToolMap, buildPublicTypeMap, and toClientTools
  • Adds discoverOperationsFromOpenApi() in openapi-discovery.ts that walks document.paths directly without UTCP, fixing the ~80% of providers that currently fail UTCP conversion
  • Keeps UTCP as an optional fast-path: when UTCP succeeds, its tools are converted via toolsToDiscoveredOperations; when it fails or returns empty, the direct parser runs as fallback

Changes

  • packages/bundler/src/openapi-discovery.ts (new): defines DiscoveredOperation type and discoverOperationsFromOpenApi() function
  • packages/bundler/src/openapi-discovery.test.ts (new): 18 tests covering discovery, content-type selection, server base-path computation, and description/tag extraction
  • packages/bundler/src/client-api.ts: buildClientToolMap accepts DiscoveredOperation[]; getOperationContext resolves by op.path key directly instead of URL parsing
  • packages/bundler/src/openapi.ts: buildPublicTypeMap accepts DiscoveredOperation[]; fixes pre-existing any cast
  • packages/bundler/src/render.ts: toClientTools, renderProviderTypes, renderProviderGroupTypes, renderProviderTypesIndex accept DiscoveredOperation[]
  • packages/bundler/src/docs/augment.ts: AugmentProviderDocsOptions replaces tools with operations and adds publicTypeMap
  • packages/bundler/src/utcp.ts: exports toolsToDiscoveredOperations adapter
  • packages/bundler/src/index.ts: both generateRegistryTypes and augmentRegistryProviderDocs use UTCP-first with direct-discovery fallback
  • Test files updated to use DiscoveredOperation factory instead of UTCP Tool factory

Test Plan

  • All 185 unit tests pass (pnpm test)
  • Lint clean with zero warnings (eslint --max-warnings 0)
  • No new TypeScript errors introduced
  • 18 new tests for openapi-discovery.ts covering all edge cases

Closes: APR-191

🤖 Generated with Claude Code

… pipeline

Introduces `DiscoveredOperation` as a unified pointer type that replaces
UTCP's `Tool[]` across `buildClientToolMap`, `buildPublicTypeMap`, and
`toClientTools`.  All downstream schema resolution and type generation
continues to read directly from the OpenAPI document.

Key changes:
- `openapi-discovery.ts` (new): walks `document.paths` and enumerates
  operations as `DiscoveredOperation[]` without UTCP.
- `client-api.ts`: `buildClientToolMap` now accepts `DiscoveredOperation[]`;
  `getOperationContext` resolves by `op.path` directly instead of URL parsing.
- `openapi.ts`: `buildPublicTypeMap` now accepts `DiscoveredOperation[]`.
- `render.ts`: `toClientTools`, `renderProviderTypes`, `renderProviderGroupTypes`,
  `renderProviderTypesIndex` all accept `DiscoveredOperation[]`.
- `docs/augment.ts`: `AugmentProviderDocsOptions` switches `tools` to
  `operations`, adds `publicTypeMap`; `buildOperationLookup` updated.
- `utcp.ts`: exports `toolsToDiscoveredOperations` to convert UTCP output
  for the UTCP-success path.
- `index.ts`: `generateRegistryTypes` and `augmentRegistryProviderDocs` try
  UTCP first; fall back to `discoverOperationsFromOpenApi` when UTCP returns
  empty.

All 185 tests pass; lint clean.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant