History

Merge pull request #17 from bam4564/codex/openapi-endpoint

Expose the control plane OpenAPI spec at /v1/openapi.json

Rhys Sullivan committed 8 months ago

Commit 0ba02202 parents 904b64e 581e0522 files · +22 −1Browse files

Unified · Split

2 files
  1. apps/executor/src/server/server.test.ts +19 −0
  2. packages/server/src/index.ts +3 −1
apps/executor/src/server/server.test.ts+19−0
@@ -17,6 +17,7 @@ import { startMcpElicitationDemoServer } from "@executor/mcp-elicitation-demo"; · 16 unmodified lines
17import { makeToolInvokerFromTools, toTool } from "@executor/codemode-core";17import { makeToolInvokerFromTools, toTool } from "@executor/codemode-core";
18import {18import {
19 createControlPlaneClient,19 createControlPlaneClient,
20 controlPlaneOpenApiSpec,
20 type ControlPlaneClient,21 type ControlPlaneClient,
21 type ResolveExecutionEnvironment,22 type ResolveExecutionEnvironment,
22 SourceIdSchema,23 SourceIdSchema,
@@ -601,6 +602,24 @@ const waitForExecutionCompletion = (input: { · 578 unmodified lines
601 });602 });
602 603
603describe("local-executor-server", () => {604describe("local-executor-server", () => {
605 it.scoped("serves the control-plane OpenAPI spec at /v1/openapi.json", () =>
606 Effect.gen(function* () {
607 const server = yield* makeServer;
608 const response = yield* Effect.promise(() =>
609 fetch(`${server.baseUrl}/v1/openapi.json`, {
610 headers: {
611 accept: "application/json",
612 },
613 }),
614 );
615 const spec = yield* Effect.promise(() => response.json());
616
617 expect(response.status).toBe(200);
618 expect(response.headers.get("content-type")).toContain("application/json");
619 expect(spec).toEqual(controlPlaneOpenApiSpec);
620 }),
621 );
622
604 it.scoped("serves the control-plane API and executes code", () =>623 it.scoped("serves the control-plane API and executes code", () =>
605 Effect.gen(function* () {624 Effect.gen(function* () {
606 const server = yield* makeServer;625 const server = yield* makeServer;
packages/server/src/index.ts+3−1
@@ -212,7 +212,9 @@ const createControlPlaneWebHandler = (runtime: SqlControlPlaneRuntime) => · 211 unmodified lines
212 Effect.sync(() =>212 Effect.sync(() =>
213 HttpApiBuilder.toWebHandler(213 HttpApiBuilder.toWebHandler(
214 Layer.merge(214 Layer.merge(
215 createControlPlaneApiLayer(runtime.runtimeLayer),215 HttpApiBuilder.middlewareOpenApi({ path: "/v1/openapi.json" }).pipe(
216 Layer.provideMerge(createControlPlaneApiLayer(runtime.runtimeLayer))
217 ),
216 HttpServer.layerContext,218 HttpServer.layerContext,
217 ),219 ),
218 ),220 ),