Skip to content

feat(connector-openapi): OpenAPI 3.x → Connector generator (ADR-0023)#1425

Merged
os-zhuang merged 3 commits into
mainfrom
claude/funny-pasteur-cppKR
Jun 1, 2026
Merged

feat(connector-openapi): OpenAPI 3.x → Connector generator (ADR-0023)#1425
os-zhuang merged 3 commits into
mainfrom
claude/funny-pasteur-cppKR

Conversation

@os-zhuang

@os-zhuang os-zhuang commented May 31, 2026

Copy link
Copy Markdown
Contributor

Summary

Implements the core of ADR-0023: a new open-source package @objectstack/connector-openapi that turns a declarative OpenAPI 3.x document into a Connector — one operation → one action — plus a generic handler per action.

It adds no new runtime abstraction and is self-contained (depends only on @objectstack/core + @objectstack/spec, like every sibling connector). Each generated action drives one shared static-auth HTTP transport that mirrors @objectstack/connector-rest (build URL from base+path+query, apply static auth, JSON-encode the body, normalise the response to { status, ok, body }). The generator returns the { def, handlers } shape consumed by engine.registerConnector(def, handlers) — exactly like the hand-written, REST, and MCP connectors.

What's in here

  • createOpenApiConnector — flattens paths × methods into actions; action key = operationId with a deterministic slug fallback and de-duping; inputSchema assembled as { path, query, header, body } from parameters + requestBody; outputSchema from the 200/2xx/default JSON response. Each handler interpolates path params and forwards query/header/body through the shared transport.
  • Static auth (none/api-key/basic/bearer) supplied by the caller, reflected in the connector definition.
  • include allowlist to trim large specs to a usable subset.
  • registerOpenApiConnector helper mirroring the sibling connectors' registration.
  • Added @objectstack/connector-openapi to the changesets fixed group + a changeset entry; lockfile refreshed.

Open-source / enterprise boundary (ADR-0023 §4)

Static auth only. Managed OAuth2, credential vault, per-tenant lifecycle, and curated catalogs remain enterprise (ADR-0015/0022).

Testing (all green locally)

  • 10/10 unit tests pass (metadata, key/slug fallback, schema assembly, output schema, auth, allowlist, handler path/query/body dispatch, missing-base-URL error, engine registration).
  • turbo run build (esm + cjs + dts), eslint, check-changeset-fixed.mjs, and pnpm install --frozen-lockfile all clean.

Remaining follow-ups (noted in the ADR)

  • openapi-to-connector CLI emitting a reviewable *.connector.json (needs a multi-entry build; every connector package currently uses the shared single-entry tsup config).
  • A worked example under examples/ (GitHub/Stripe subset).
  • YAML spec input and a $ref deref pass.

https://claude.ai/code/session_01UW43Uzua3azgNKoLGkkUde

Add @objectstack/connector-openapi, mirroring connector-rest / connector-mcp:

- createOpenApiConnector turns an OpenAPI 3.x document into a Connector
  definition + handler map (one operation -> one action). It reuses
  @objectstack/connector-rest's request handler for the HTTP/auth transport
  (one shared implementation, per ADR-0022) and returns the same
  { definition, handlers } shape consumed by engine.registerConnector — no new
  engine surface.
- Input schemas assembled as { path, query, header, body } from parameters +
  requestBody; output schema from the 200/2xx/default JSON response; action
  names from operationId with a deterministic slug fallback and de-duping.
- Auth inferred from components.securitySchemes when no credentials are
  supplied; supplied RestAuth is reflected in the definition metadata.
- include allowlist for trimming large specs.
- registerOpenApiConnector plugin mirroring registerRestConnector /
  registerMcpConnector.
- 12 unit tests (metadata, name/slug fallback, schema assembly, output schema,
  auth inference, allowlist, handler path/query/body dispatch, missing-base-URL
  error, engine registration).

Updates ADR-0023 status to mark the generator package implemented; the CLI and
worked example remain noted follow-ups.
@vercel

vercel Bot commented May 31, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
spec Ready Ready Preview, Comment May 31, 2026 11:58pm

Request Review

@github-actions github-actions Bot added documentation Improvements or additions to documentation dependencies Pull requests that update a dependency file tests tooling size/l labels May 31, 2026
claude added 2 commits May 31, 2026 23:42
Make @objectstack/connector-openapi self-contained and correct against the
real connector/spec APIs (fixes the initial scaffold):

- Drop the @objectstack/connector-rest dependency; inline the static-auth HTTP
  transport (build URL, apply auth, JSON-encode body, normalise to
  { status, ok, body }) mirroring connector-rest, so the package depends only
  on @objectstack/core + @objectstack/spec like every sibling connector.
- Use the real ConnectorAction `key` field, the `{ type }` auth discriminator,
  import Connector from @objectstack/spec/integration, and return { def,
  handlers } — matching the registry contract used by connector-rest/mcp.
- Fix tsconfig (rootDir/outDir/types) so dts builds.

Resolves the "Validate Package Dependencies" failure: add
@objectstack/connector-openapi to the changesets `fixed` group, add a changeset
entry, and refresh pnpm-lock.yaml. Update ADR-0023 to describe the
self-contained transport. Merge latest main.

Verified locally: turbo build (esm+cjs+dts), 10/10 vitest tests, eslint,
check-changeset-fixed.mjs, and pnpm install --frozen-lockfile all pass.

/** Build the request URL from base + path + query, encoding query params. */
function buildUrl(baseUrl: string, path: string, query: Record<string, string>): string {
const base = baseUrl.replace(/\/+$/, '');
@os-zhuang os-zhuang marked this pull request as ready for review June 1, 2026 00:00
@os-zhuang os-zhuang merged commit 71d8ae1 into main Jun 1, 2026
11 of 13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dependencies Pull requests that update a dependency file documentation Improvements or additions to documentation size/l tests tooling

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants