From 6ce986f11f797e8dace8104a407911e0a6083a3b Mon Sep 17 00:00:00 2001 From: fuomag9 <1580624+fuomag9@users.noreply.github.com> Date: Sat, 28 Mar 2026 15:01:50 +0100 Subject: [PATCH] feat: add LocationRule to OpenAPI spec and fix response_headers example - Add LocationRule schema with path and upstreams fields - Add location_rules to ProxyHost and ProxyHostInput schemas - Fix response_headers using concrete example instead of generic additionalProperties Co-Authored-By: Claude Sonnet 4.6 --- app/api/v1/openapi.json/route.ts | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/app/api/v1/openapi.json/route.ts b/app/api/v1/openapi.json/route.ts index f172c09f..06824fde 100644 --- a/app/api/v1/openapi.json/route.ts +++ b/app/api/v1/openapi.json/route.ts @@ -1321,7 +1321,7 @@ const spec = { fail_closed: { type: "boolean", description: "Block when client IP cannot be determined" }, response_status: { type: "integer", example: 403 }, response_body: { type: "string", example: "Forbidden" }, - response_headers: { type: "object", additionalProperties: { type: "string" } }, + response_headers: { type: "object", additionalProperties: { type: "string" }, example: { "Content-Type": "text/plain", "X-Custom": "blocked" }, description: "Custom response headers (header name → value)" }, redirect_url: { type: "string", description: "If set, 302 redirect instead of status/body" }, }, }, @@ -1363,6 +1363,15 @@ const spec = { }, required: ["path_prefix"], }, + LocationRule: { + type: "object", + description: "Route a path pattern to specific upstream servers (like nginx location blocks)", + properties: { + path: { type: "string", example: "/ws/*", description: "Caddy path pattern to match" }, + upstreams: { type: "array", items: { type: "string" }, example: ["ws-backend:8080", "ws-backend2:8080"], description: "Upstream servers for this path" }, + }, + required: ["path", "upstreams"], + }, // ── Main resource schemas ─────────────────────────────────── ProxyHost: { @@ -1395,6 +1404,7 @@ const spec = { mtls: { oneOf: [{ $ref: "#/components/schemas/MtlsConfig" }, { type: "null" }] }, redirects: { type: "array", items: { $ref: "#/components/schemas/RedirectRule" } }, rewrite: { oneOf: [{ $ref: "#/components/schemas/RewriteConfig" }, { type: "null" }] }, + location_rules: { type: "array", items: { $ref: "#/components/schemas/LocationRule" }, description: "Path-based routing rules (routes specific paths to different upstreams)" }, }, required: ["id", "name", "domains", "upstreams", "enabled", "created_at", "updated_at"], }, @@ -1425,6 +1435,7 @@ const spec = { mtls: { oneOf: [{ $ref: "#/components/schemas/MtlsConfig" }, { type: "null" }] }, redirects: { type: "array", items: { $ref: "#/components/schemas/RedirectRule" } }, rewrite: { oneOf: [{ $ref: "#/components/schemas/RewriteConfig" }, { type: "null" }] }, + location_rules: { type: "array", items: { $ref: "#/components/schemas/LocationRule" }, description: "Path-based routing rules (routes specific paths to different upstreams)" }, }, required: ["name", "domains", "upstreams"], },