feat: register X-Tenant-ID as a security scheme for Scalar UI
This commit is contained in:
+2
-1
@@ -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(
|
||||
|
||||
+8
-1
@@ -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;
|
||||
|
||||
+3
-3
@@ -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({
|
||||
|
||||
Reference in New Issue
Block a user