fix middleware schemas

This commit is contained in:
yusing 2025-01-17 14:33:47 +08:00
parent 6a07a63c34
commit 1a83c739d4
7 changed files with 112 additions and 515 deletions

View file

@ -406,12 +406,6 @@
}, },
"type": "object" "type": "object"
}, },
"Partial<CustomErrorPage>": {
"type": "object"
},
"Partial<HideXForwarded>": {
"type": "object"
},
"Partial<ModifyRequest>": { "Partial<ModifyRequest>": {
"properties": { "properties": {
"add_headers": { "add_headers": {
@ -438,6 +432,9 @@
}, },
"type": "object" "type": "object"
}, },
"Partial<Null>": {
"type": "object"
},
"Partial<OIDC>": { "Partial<OIDC>": {
"properties": { "properties": {
"allowed_groups": { "allowed_groups": {
@ -499,12 +496,6 @@
}, },
"type": "object" "type": "object"
}, },
"Partial<RedirectHTTP>": {
"type": "object"
},
"Partial<SetXForwarded>": {
"type": "object"
},
"StatusCode": { "StatusCode": {
"anyOf": [ "anyOf": [
{ {
@ -949,7 +940,7 @@
"type": "object" "type": "object"
}, },
{ {
"$ref": "#/definitions/Partial<RedirectHTTP>" "$ref": "#/definitions/Partial<Null>"
} }
] ]
}, },
@ -1069,180 +1060,6 @@
} }
] ]
}, },
{
"allOf": [
{
"properties": {
"use": {
"enum": [
"CIDRWhitelist",
"CloudflareRealIP",
"CustomErrorPage",
"HideXForwarded",
"ModifyRequest",
"ModifyResponse",
"OIDC",
"RateLimit",
"RealIP",
"RedirectHTTP",
"Request",
"Response",
"SetXForwarded",
"cidrWhitelist",
"cidr_whitelist",
"cloudflareRealIP",
"cloudflare_real_ip",
"customErrorPage",
"custom_error_page",
"errorPage",
"error_page",
"hideXForwarded",
"hide_x_forwarded",
"modifyRequest",
"modifyResponse",
"modify_request",
"modify_response",
"oidc",
"rateLimit",
"rate_limit",
"realIP",
"real_ip",
"redirectHTTP",
"redirect_http",
"request",
"response",
"setXForwarded",
"set_x_forwarded"
],
"type": "string"
}
},
"required": [
"use"
],
"type": "object"
},
{
"$ref": "#/definitions/Partial<SetXForwarded>"
}
]
},
{
"allOf": [
{
"properties": {
"use": {
"enum": [
"CIDRWhitelist",
"CloudflareRealIP",
"CustomErrorPage",
"HideXForwarded",
"ModifyRequest",
"ModifyResponse",
"OIDC",
"RateLimit",
"RealIP",
"RedirectHTTP",
"Request",
"Response",
"SetXForwarded",
"cidrWhitelist",
"cidr_whitelist",
"cloudflareRealIP",
"cloudflare_real_ip",
"customErrorPage",
"custom_error_page",
"errorPage",
"error_page",
"hideXForwarded",
"hide_x_forwarded",
"modifyRequest",
"modifyResponse",
"modify_request",
"modify_response",
"oidc",
"rateLimit",
"rate_limit",
"realIP",
"real_ip",
"redirectHTTP",
"redirect_http",
"request",
"response",
"setXForwarded",
"set_x_forwarded"
],
"type": "string"
}
},
"required": [
"use"
],
"type": "object"
},
{
"$ref": "#/definitions/Partial<HideXForwarded>"
}
]
},
{
"allOf": [
{
"properties": {
"use": {
"enum": [
"CIDRWhitelist",
"CloudflareRealIP",
"CustomErrorPage",
"HideXForwarded",
"ModifyRequest",
"ModifyResponse",
"OIDC",
"RateLimit",
"RealIP",
"RedirectHTTP",
"Request",
"Response",
"SetXForwarded",
"cidrWhitelist",
"cidr_whitelist",
"cloudflareRealIP",
"cloudflare_real_ip",
"customErrorPage",
"custom_error_page",
"errorPage",
"error_page",
"hideXForwarded",
"hide_x_forwarded",
"modifyRequest",
"modifyResponse",
"modify_request",
"modify_response",
"oidc",
"rateLimit",
"rate_limit",
"realIP",
"real_ip",
"redirectHTTP",
"redirect_http",
"request",
"response",
"setXForwarded",
"set_x_forwarded"
],
"type": "string"
}
},
"required": [
"use"
],
"type": "object"
},
{
"$ref": "#/definitions/Partial<CustomErrorPage>"
}
]
},
{ {
"allOf": [ "allOf": [
{ {

View file

@ -61,12 +61,6 @@
}, },
"type": "object" "type": "object"
}, },
"Partial<CustomErrorPage>": {
"type": "object"
},
"Partial<HideXForwarded>": {
"type": "object"
},
"Partial<ModifyRequest>": { "Partial<ModifyRequest>": {
"properties": { "properties": {
"add_headers": { "add_headers": {
@ -93,6 +87,9 @@
}, },
"type": "object" "type": "object"
}, },
"Partial<Null>": {
"type": "object"
},
"Partial<OIDC>": { "Partial<OIDC>": {
"properties": { "properties": {
"allowed_groups": { "allowed_groups": {
@ -154,12 +151,6 @@
}, },
"type": "object" "type": "object"
}, },
"Partial<RedirectHTTP>": {
"type": "object"
},
"Partial<SetXForwarded>": {
"type": "object"
},
"StatusCode": { "StatusCode": {
"anyOf": [ "anyOf": [
{ {
@ -228,7 +219,7 @@
"type": "object" "type": "object"
}, },
{ {
"$ref": "#/definitions/Partial<RedirectHTTP>" "$ref": "#/definitions/Partial<Null>"
} }
] ]
}, },
@ -348,180 +339,6 @@
} }
] ]
}, },
{
"allOf": [
{
"properties": {
"use": {
"enum": [
"CIDRWhitelist",
"CloudflareRealIP",
"CustomErrorPage",
"HideXForwarded",
"ModifyRequest",
"ModifyResponse",
"OIDC",
"RateLimit",
"RealIP",
"RedirectHTTP",
"Request",
"Response",
"SetXForwarded",
"cidrWhitelist",
"cidr_whitelist",
"cloudflareRealIP",
"cloudflare_real_ip",
"customErrorPage",
"custom_error_page",
"errorPage",
"error_page",
"hideXForwarded",
"hide_x_forwarded",
"modifyRequest",
"modifyResponse",
"modify_request",
"modify_response",
"oidc",
"rateLimit",
"rate_limit",
"realIP",
"real_ip",
"redirectHTTP",
"redirect_http",
"request",
"response",
"setXForwarded",
"set_x_forwarded"
],
"type": "string"
}
},
"required": [
"use"
],
"type": "object"
},
{
"$ref": "#/definitions/Partial<SetXForwarded>"
}
]
},
{
"allOf": [
{
"properties": {
"use": {
"enum": [
"CIDRWhitelist",
"CloudflareRealIP",
"CustomErrorPage",
"HideXForwarded",
"ModifyRequest",
"ModifyResponse",
"OIDC",
"RateLimit",
"RealIP",
"RedirectHTTP",
"Request",
"Response",
"SetXForwarded",
"cidrWhitelist",
"cidr_whitelist",
"cloudflareRealIP",
"cloudflare_real_ip",
"customErrorPage",
"custom_error_page",
"errorPage",
"error_page",
"hideXForwarded",
"hide_x_forwarded",
"modifyRequest",
"modifyResponse",
"modify_request",
"modify_response",
"oidc",
"rateLimit",
"rate_limit",
"realIP",
"real_ip",
"redirectHTTP",
"redirect_http",
"request",
"response",
"setXForwarded",
"set_x_forwarded"
],
"type": "string"
}
},
"required": [
"use"
],
"type": "object"
},
{
"$ref": "#/definitions/Partial<HideXForwarded>"
}
]
},
{
"allOf": [
{
"properties": {
"use": {
"enum": [
"CIDRWhitelist",
"CloudflareRealIP",
"CustomErrorPage",
"HideXForwarded",
"ModifyRequest",
"ModifyResponse",
"OIDC",
"RateLimit",
"RealIP",
"RedirectHTTP",
"Request",
"Response",
"SetXForwarded",
"cidrWhitelist",
"cidr_whitelist",
"cloudflareRealIP",
"cloudflare_real_ip",
"customErrorPage",
"custom_error_page",
"errorPage",
"error_page",
"hideXForwarded",
"hide_x_forwarded",
"modifyRequest",
"modifyResponse",
"modify_request",
"modify_response",
"oidc",
"rateLimit",
"rate_limit",
"realIP",
"real_ip",
"redirectHTTP",
"redirect_http",
"request",
"response",
"setXForwarded",
"set_x_forwarded"
],
"type": "string"
}
},
"required": [
"use"
],
"type": "object"
},
{
"$ref": "#/definitions/Partial<CustomErrorPage>"
}
]
},
{ {
"allOf": [ "allOf": [
{ {

View file

@ -1,11 +1,14 @@
import * as types from "../types"; import * as types from "../types";
/**
* @additionalProperties false
*/
export type MiddlewaresMap = { export type MiddlewaresMap = {
redirect_http?: RedirectHTTP; redirect_http?: RedirectHTTP;
redirectHTTP?: RedirectHTTP; redirectHTTP?: RedirectHTTP;
RedirectHTTP?: RedirectHTTP; RedirectHTTP?: RedirectHTTP;
oidc?: OIDC; oidc?: types.Nullable<OIDC>;
OIDC?: OIDC; OIDC?: types.Nullable<OIDC>;
request?: ModifyRequest; request?: ModifyRequest;
Request?: ModifyRequest; Request?: ModifyRequest;
modify_request?: ModifyRequest; modify_request?: ModifyRequest;
@ -30,9 +33,9 @@ export type MiddlewaresMap = {
real_ip?: RealIP; real_ip?: RealIP;
realIP?: RealIP; realIP?: RealIP;
RealIP?: RealIP; RealIP?: RealIP;
cloudflare_real_ip?: CloudflareRealIP; cloudflare_real_ip?: types.Nullable<CloudflareRealIP>;
cloudflareRealIP?: CloudflareRealIP; cloudflareRealIP?: types.Nullable<CloudflareRealIP>;
CloudflareRealIP?: CloudflareRealIP; CloudflareRealIP?: types.Nullable<CloudflareRealIP>;
rate_limit?: RateLimit; rate_limit?: RateLimit;
rateLimit?: RateLimit; rateLimit?: RateLimit;
RateLimit?: RateLimit; RateLimit?: RateLimit;
@ -41,10 +44,10 @@ export type MiddlewaresMap = {
CIDRWhitelist?: CIDRWhitelist; CIDRWhitelist?: CIDRWhitelist;
}; };
/** export type CustomErrorPage = types.Null;
* @additionalProperties false export type RedirectHTTP = types.Null;
*/ export type SetXForwarded = types.Null;
export type CustomErrorPage = {}; export type HideXForwarded = types.Null;
/** /**
* @additionalProperties false * @additionalProperties false
@ -144,18 +147,3 @@ export type RealIP = {
*/ */
recursive: boolean; recursive: boolean;
}; };
/**
* @additionalProperties false
*/
export type RedirectHTTP = {};
/**
* @additionalProperties false
*/
export type SetXForwarded = {};
/**
* @additionalProperties false
*/
export type HideXForwarded = {};

View file

@ -4,8 +4,13 @@ import { URL } from "../types";
* @additionalProperties false * @additionalProperties false
*/ */
export type HomepageConfig = { export type HomepageConfig = {
/** Whether show in dashboard
*
* @default true
*/
show?: boolean;
/* Display name on dashboard */ /* Display name on dashboard */
name: string; name?: string;
/* Display icon on dashboard */ /* Display icon on dashboard */
icon?: URL | WalkxcodeIcon | TargetRelativeIconPath; icon?: URL | WalkxcodeIcon | TargetRelativeIconPath;
/* App description */ /* App description */

View file

@ -79,7 +79,7 @@ export type StreamRoute = {
* *
* @default tcp * @default tcp
*/ */
scheme?: StreamScheme; scheme: StreamScheme;
/** Stream host /** Stream host
* *
* @default localhost * @default localhost

View file

@ -199,6 +199,56 @@
} }
] ]
}, },
"Null": {
"type": "null"
},
"Nullable<CloudflareRealIP>": {
"anyOf": [
{
"$ref": "#/definitions/Null"
},
{
"additionalProperties": false,
"properties": {
"recursive": {
"default": false,
"description": "Recursively resolve the IP",
"type": "boolean"
}
},
"type": "object"
}
]
},
"Nullable<OIDC>": {
"anyOf": [
{
"$ref": "#/definitions/Null"
},
{
"additionalProperties": false,
"properties": {
"allowed_groups": {
"description": "Allowed groups",
"items": {
"type": "string"
},
"minItems": 1,
"type": "array"
},
"allowed_users": {
"description": "Allowed users",
"items": {
"type": "string"
},
"minItems": 1,
"type": "array"
}
},
"type": "object"
}
]
},
"ProxyScheme": { "ProxyScheme": {
"enum": [ "enum": [
"http", "http",
@ -506,6 +556,11 @@
"name": { "name": {
"type": "string" "type": "string"
}, },
"show": {
"default": true,
"description": "Whether show in dashboard",
"type": "boolean"
},
"url": { "url": {
"format": "uri", "format": "uri",
"type": "string" "type": "string"
@ -515,9 +570,6 @@
"type": "object" "type": "object"
} }
}, },
"required": [
"name"
],
"type": "object" "type": "object"
}, },
"host": { "host": {
@ -530,6 +582,7 @@
"description": "Load balance config" "description": "Load balance config"
}, },
"middlewares": { "middlewares": {
"additionalProperties": false,
"description": "Middlewares", "description": "Middlewares",
"properties": { "properties": {
"CIDRWhitelist": { "CIDRWhitelist": {
@ -558,25 +611,13 @@
"type": "object" "type": "object"
}, },
"CloudflareRealIP": { "CloudflareRealIP": {
"additionalProperties": false, "$ref": "#/definitions/Nullable<CloudflareRealIP>"
"properties": {
"recursive": {
"default": false,
"description": "Recursively resolve the IP",
"type": "boolean"
}
},
"type": "object"
}, },
"CustomErrorPage": { "CustomErrorPage": {
"additionalProperties": false, "$ref": "#/definitions/Null"
"properties": {},
"type": "object"
}, },
"HideXForwarded": { "HideXForwarded": {
"additionalProperties": false, "$ref": "#/definitions/Null"
"properties": {},
"type": "object"
}, },
"ModifyRequest": { "ModifyRequest": {
"additionalProperties": false, "additionalProperties": false,
@ -633,26 +674,7 @@
"type": "object" "type": "object"
}, },
"OIDC": { "OIDC": {
"additionalProperties": false, "$ref": "#/definitions/Nullable<OIDC>"
"properties": {
"allowed_groups": {
"description": "Allowed groups",
"items": {
"type": "string"
},
"minItems": 1,
"type": "array"
},
"allowed_users": {
"description": "Allowed users",
"items": {
"type": "string"
},
"minItems": 1,
"type": "array"
}
},
"type": "object"
}, },
"RateLimit": { "RateLimit": {
"additionalProperties": false, "additionalProperties": false,
@ -706,9 +728,7 @@
"type": "object" "type": "object"
}, },
"RedirectHTTP": { "RedirectHTTP": {
"additionalProperties": false, "$ref": "#/definitions/Null"
"properties": {},
"type": "object"
}, },
"Request": { "Request": {
"additionalProperties": false, "additionalProperties": false,
@ -765,9 +785,7 @@
"type": "object" "type": "object"
}, },
"SetXForwarded": { "SetXForwarded": {
"additionalProperties": false, "$ref": "#/definitions/Null"
"properties": {},
"type": "object"
}, },
"cidrWhitelist": { "cidrWhitelist": {
"additionalProperties": false, "additionalProperties": false,
@ -820,56 +838,28 @@
"type": "object" "type": "object"
}, },
"cloudflareRealIP": { "cloudflareRealIP": {
"additionalProperties": false, "$ref": "#/definitions/Nullable<CloudflareRealIP>"
"properties": {
"recursive": {
"default": false,
"description": "Recursively resolve the IP",
"type": "boolean"
}
},
"type": "object"
}, },
"cloudflare_real_ip": { "cloudflare_real_ip": {
"additionalProperties": false, "$ref": "#/definitions/Nullable<CloudflareRealIP>"
"properties": {
"recursive": {
"default": false,
"description": "Recursively resolve the IP",
"type": "boolean"
}
},
"type": "object"
}, },
"customErrorPage": { "customErrorPage": {
"additionalProperties": false, "$ref": "#/definitions/Null"
"properties": {},
"type": "object"
}, },
"custom_error_page": { "custom_error_page": {
"additionalProperties": false, "$ref": "#/definitions/Null"
"properties": {},
"type": "object"
}, },
"errorPage": { "errorPage": {
"additionalProperties": false, "$ref": "#/definitions/Null"
"properties": {},
"type": "object"
}, },
"error_page": { "error_page": {
"additionalProperties": false, "$ref": "#/definitions/Null"
"properties": {},
"type": "object"
}, },
"hideXForwarded": { "hideXForwarded": {
"additionalProperties": false, "$ref": "#/definitions/Null"
"properties": {},
"type": "object"
}, },
"hide_x_forwarded": { "hide_x_forwarded": {
"additionalProperties": false, "$ref": "#/definitions/Null"
"properties": {},
"type": "object"
}, },
"modifyRequest": { "modifyRequest": {
"additionalProperties": false, "additionalProperties": false,
@ -980,26 +970,7 @@
"type": "object" "type": "object"
}, },
"oidc": { "oidc": {
"additionalProperties": false, "$ref": "#/definitions/Nullable<OIDC>"
"properties": {
"allowed_groups": {
"description": "Allowed groups",
"items": {
"type": "string"
},
"minItems": 1,
"type": "array"
},
"allowed_users": {
"description": "Allowed users",
"items": {
"type": "string"
},
"minItems": 1,
"type": "array"
}
},
"type": "object"
}, },
"rateLimit": { "rateLimit": {
"additionalProperties": false, "additionalProperties": false,
@ -1104,14 +1075,10 @@
"type": "object" "type": "object"
}, },
"redirectHTTP": { "redirectHTTP": {
"additionalProperties": false, "$ref": "#/definitions/Null"
"properties": {},
"type": "object"
}, },
"redirect_http": { "redirect_http": {
"additionalProperties": false, "$ref": "#/definitions/Null"
"properties": {},
"type": "object"
}, },
"request": { "request": {
"additionalProperties": false, "additionalProperties": false,
@ -1168,14 +1135,10 @@
"type": "object" "type": "object"
}, },
"setXForwarded": { "setXForwarded": {
"additionalProperties": false, "$ref": "#/definitions/Null"
"properties": {},
"type": "object"
}, },
"set_x_forwarded": { "set_x_forwarded": {
"additionalProperties": false, "$ref": "#/definitions/Null"
"properties": {},
"type": "object"
} }
}, },
"type": "object" "type": "object"
@ -1256,7 +1219,7 @@
"type": "string" "type": "string"
}, },
"port": { "port": {
"pattern": "^\\d+\\:\\d+$", "pattern": "^\\d+:\\d+$",
"type": "string" "type": "string"
}, },
"scheme": { "scheme": {
@ -1266,7 +1229,8 @@
} }
}, },
"required": [ "required": [
"port" "port",
"scheme"
], ],
"type": "object" "type": "object"
} }

View file

@ -1,3 +1,9 @@
/**
* @type "null"
*/
export interface Null {}
export type Nullable<T> = T | Null;
export const HTTP_METHODS = [ export const HTTP_METHODS = [
"GET", "GET",
"POST", "POST",
@ -69,7 +75,7 @@ export type CIDR =
export type Port = number; export type Port = number;
/** /**
* @pattern ^\d+\:\d+$ * @pattern ^\d+:\d+$
*/ */
export type StreamPort = string; export type StreamPort = string;