Files
dify/knowledge-fs/packages/api/src/openapi-handler-utils.test.ts
Jyong 4ee43b8afc chore: migrate knowledge-fs source tree
Import the committed KnowledgeFS snapshot dc4072ee302317145612087ce7440851dc329fd0 under knowledge-fs/ without its Git history, local IDE settings, or build artifacts.
2026-07-20 04:54:20 -04:00

24 lines
750 B
TypeScript

import { describe, expect, it } from "vitest";
import { asLooseOpenApiContext, openApiHandler } from "./openapi-handler-utils";
describe("OpenAPI handler utilities", () => {
it("casts OpenAPI contexts without changing the runtime object", () => {
const context = {
get: (name: "subject" | "traceId") => name,
json: (body: unknown, status?: number) => new Response(JSON.stringify({ body, status })),
req: {
valid: (target: "json" | "param" | "query") => ({ target }),
},
};
expect(asLooseOpenApiContext(context)).toBe(context);
});
it("casts handlers without wrapping them", () => {
const handler = async () => new Response("ok");
expect(openApiHandler(handler)).toBe(handler);
});
});