The OpenAPI plugin provides the integration layer for RESTful services defined by OpenAPI 3.x specifications. It handles the lifecycle of an API integration from specification parsing and tool extraction to authenticated execution and health monitoring.
The plugin transforms static OpenAPI documents into executable tools. It manages:
Sources: packages/plugins/openapi/src/sdk/index.ts1-46 packages/plugins/openapi/src/sdk/plugin.ts39-46
The plugin extracts tools by traversing the paths object of an OpenAPI document. Each operationId (or a derived slug from the method and path) becomes a tool name.
fetchSpecText function retrieves the document from a URL or blob packages/plugins/openapi/src/sdk/parse.ts1-10parse function validates the document structure packages/plugins/openapi/src/sdk/parse.ts1-10extract iterates over HTTP methods (GET, POST, etc.) to build ExtractedOperation objects packages/plugins/openapi/src/sdk/extract.ts46-55OpenapiStore to avoid re-parsing during invocation packages/plugins/openapi/src/sdk/store.ts12-25| System Name | Code Entity | Role |
|---|---|---|
| Spec Parser | parse | Validates OpenAPI 3.x syntax packages/plugins/openapi/src/sdk/parse.ts1-10 |
| Operation Binder | OperationBinding | Holds the method, path template, and parameters packages/plugins/openapi/src/sdk/types.ts168-175 |
| Plugin Store | OpenapiStore | Manages persistence of extracted operations packages/plugins/openapi/src/sdk/store.ts102-140 |
Sources: packages/plugins/openapi/src/sdk/extract.ts1-40 packages/plugins/openapi/src/sdk/store.ts49-58
The invocation pipeline transforms a tool call into a physical HTTP request.
The resolvePath function performs RFC 3986 template expansion packages/plugins/openapi/src/sdk/invoke.ts77-82 It supports:
allowReserved flags for path parameters packages/plugins/openapi/src/sdk/invoke.ts46-58pathParams or queryParams packages/plugins/openapi/src/sdk/invoke.ts21-41The plugin supports complex request body encodings beyond standard JSON:
Content-Type headers packages/plugins/openapi/src/sdk/invoke.ts168-178application/octet-stream for raw data transfer packages/plugins/openapi/src/sdk/invoke.ts179-180This diagram shows how invokeOpenApiBackedTool coordinates with the SDK's HTTP utilities.
Sources: packages/plugins/openapi/src/sdk/invoke.ts77-145 packages/plugins/openapi/src/sdk/backing.ts17-36
The plugin uses an "Auth Template" system to handle various security requirements.
During integration registration, detectedAuthenticationTemplates scans the spec's securitySchemes packages/plugins/openapi/src/react/AddOpenApiSource.tsx50-51
ApiKeyAuthTemplate defining where the key (header/query) should be placed packages/plugins/openapi/src/sdk/types.ts3-8authorizationCode and clientCredentials flows packages/plugins/openapi/src/sdk/preview.ts46-65For OAuth2 connections, the plugin handles automatic token refresh. When an invocation fails with a 401, the pipeline uses the refreshUrl (or the tokenUrl fallback) to obtain new credentials before retrying the request packages/plugins/openapi/src/sdk/preview.ts120-145
Sources: packages/plugins/openapi/src/sdk/types.ts11-24 packages/plugins/openapi/src/sdk/config.ts48-55
Health checks allow the system to verify connection viability. The plugin provides a list of HealthCheckCandidate operations packages/plugins/openapi/src/sdk/preview.ts5-8
id, email) to confirm the authenticated subject packages/plugins/openapi/src/react/AddOpenApiSource.tsx123-125Sources: packages/plugins/openapi/src/sdk/backing.ts18-26 packages/plugins/openapi/src/sdk/preview.ts22-33
The AddOpenApiSource component provides a progressive form for registering new integrations.
SpecPreviewSummary, including detected tools and auth methods packages/plugins/openapi/src/react/AddOpenApiSource.tsx104-109baseUrl, edit the description, and refine the authenticationTemplate packages/plugins/openapi/src/react/AddOpenApiSource.tsx147-175addOpenApiSpec (via an Effect atom) to register the integration and compile tool definitions packages/plugins/openapi/src/react/AddOpenApiSource.tsx128Sources: packages/plugins/openapi/src/react/AddOpenApiSource.tsx92-130 packages/plugins/openapi/src/react/auth-method-config.ts39-43
Refresh this wiki