History

Expose control plane OpenAPI spec

TBIQ committed 8 months ago

Commit 581e0521 parent 3348e182 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,
@@ -599,6 +600,24 @@ const waitForExecutionCompletion = (input: { · 576 unmodified lines
599 });600 });
600 601
601describe("local-executor-server", () => {602describe("local-executor-server", () => {
603 it.scoped("serves the control-plane OpenAPI spec at /v1/openapi.json", () =>
604 Effect.gen(function* () {
605 const server = yield* makeServer;
606 const response = yield* Effect.promise(() =>
607 fetch(`${server.baseUrl}/v1/openapi.json`, {
608 headers: {
609 accept: "application/json",
610 },
611 }),
612 );
613 const spec = yield* Effect.promise(() => response.json());
614
615 expect(response.status).toBe(200);
616 expect(response.headers.get("content-type")).toContain("application/json");
617 expect(spec).toEqual(controlPlaneOpenApiSpec);
618 }),
619 );
620
602 it.scoped("serves the control-plane API and executes code", () =>621 it.scoped("serves the control-plane API and executes code", () =>
603 Effect.gen(function* () {622 Effect.gen(function* () {
604 const server = yield* makeServer;623 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 ),