diff --git a/src/index.ts b/src/index.ts index 8ac6c04..728cbf6 100644 --- a/src/index.ts +++ b/src/index.ts @@ -6,7 +6,7 @@ import { prettyJSON } from "hono/pretty-json"; import { config } from "./config"; import { API_PREFIX, AUTH_PREFIX, DOCS_PREFIX } from "./constants"; import { redis } from "./core/RedisClient"; -import { openApiSpec, securityScheme } from "./openapi"; +import { openApiSpec, securityScheme, tenantIdScheme } from "./openapi"; import { apiRoutes } from "./routes/api"; import { authRoutes } from "./routes/auth"; import { configRoutes } from "./routes/config"; @@ -17,6 +17,7 @@ const app = new OpenAPIHono({ strict: false }); // OpenAPI specs app.doc(`${DOCS_PREFIX}/openapi.json`, openApiSpec); app.openAPIRegistry.registerComponent("securitySchemes", "API_KEY", securityScheme); +app.openAPIRegistry.registerComponent("securitySchemes", "TENANT_ID", tenantIdScheme); // Scalar API Reference app.get( diff --git a/src/openapi.ts b/src/openapi.ts index 2f6902f..54809bf 100644 --- a/src/openapi.ts +++ b/src/openapi.ts @@ -22,10 +22,17 @@ export const openApiSpec = { description: "System-level OAuth2 handshake and callback processing.", }, ], - security: [{ API_KEY: [] }], + security: [{ API_KEY: [], TENANT_ID: [] }], }; export const securityScheme = { type: "http", scheme: "bearer", } as const; + +export const tenantIdScheme = { + type: "apiKey", + in: "header", + name: "X-Tenant-ID", + description: "The unique identifier for the tenant (user or organization).", +} as const; diff --git a/src/routes/api.ts b/src/routes/api.ts index 3057413..fec6e04 100644 --- a/src/routes/api.ts +++ b/src/routes/api.ts @@ -54,7 +54,7 @@ const ErrorSchema = z const statusRoute = createRoute({ method: "get", path: "/status", - security: [{ API_KEY: [] }], + security: [{ API_KEY: [], TENANT_ID: [] }], tags: ["Tokens"], request: { headers: z.object({ @@ -72,7 +72,7 @@ const statusRoute = createRoute({ const tokenRoute = createRoute({ method: "get", path: "/token/{provider}", - security: [{ API_KEY: [] }], + security: [{ API_KEY: [], TENANT_ID: [] }], tags: ["Tokens"], request: { params: z.object({ @@ -97,7 +97,7 @@ const tokenRoute = createRoute({ const refreshRoute = createRoute({ method: "post", path: "/refresh/{provider}", - security: [{ API_KEY: [] }], + security: [{ API_KEY: [], TENANT_ID: [] }], tags: ["Tokens"], request: { params: z.object({