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"
},
"Partial<CustomErrorPage>": {
"type": "object"
},
"Partial<HideXForwarded>": {
"type": "object"
},
"Partial<ModifyRequest>": {
"properties": {
"add_headers": {
@ -438,6 +432,9 @@
},
"type": "object"
},
"Partial<Null>": {
"type": "object"
},
"Partial<OIDC>": {
"properties": {
"allowed_groups": {
@ -499,12 +496,6 @@
},
"type": "object"
},
"Partial<RedirectHTTP>": {
"type": "object"
},
"Partial<SetXForwarded>": {
"type": "object"
},
"StatusCode": {
"anyOf": [
{
@ -949,7 +940,7 @@
"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": [
{

View file

@ -61,12 +61,6 @@
},
"type": "object"
},
"Partial<CustomErrorPage>": {
"type": "object"
},
"Partial<HideXForwarded>": {
"type": "object"
},
"Partial<ModifyRequest>": {
"properties": {
"add_headers": {
@ -93,6 +87,9 @@
},
"type": "object"
},
"Partial<Null>": {
"type": "object"
},
"Partial<OIDC>": {
"properties": {
"allowed_groups": {
@ -154,12 +151,6 @@
},
"type": "object"
},
"Partial<RedirectHTTP>": {
"type": "object"
},
"Partial<SetXForwarded>": {
"type": "object"
},
"StatusCode": {
"anyOf": [
{
@ -228,7 +219,7 @@
"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": [
{

View file

@ -1,11 +1,14 @@
import * as types from "../types";
/**
* @additionalProperties false
*/
export type MiddlewaresMap = {
redirect_http?: RedirectHTTP;
redirectHTTP?: RedirectHTTP;
RedirectHTTP?: RedirectHTTP;
oidc?: OIDC;
OIDC?: OIDC;
oidc?: types.Nullable<OIDC>;
OIDC?: types.Nullable<OIDC>;
request?: ModifyRequest;
Request?: ModifyRequest;
modify_request?: ModifyRequest;
@ -30,9 +33,9 @@ export type MiddlewaresMap = {
real_ip?: RealIP;
realIP?: RealIP;
RealIP?: RealIP;
cloudflare_real_ip?: CloudflareRealIP;
cloudflareRealIP?: CloudflareRealIP;
CloudflareRealIP?: CloudflareRealIP;
cloudflare_real_ip?: types.Nullable<CloudflareRealIP>;
cloudflareRealIP?: types.Nullable<CloudflareRealIP>;
CloudflareRealIP?: types.Nullable<CloudflareRealIP>;
rate_limit?: RateLimit;
rateLimit?: RateLimit;
RateLimit?: RateLimit;
@ -41,10 +44,10 @@ export type MiddlewaresMap = {
CIDRWhitelist?: CIDRWhitelist;
};
/**
* @additionalProperties false
*/
export type CustomErrorPage = {};
export type CustomErrorPage = types.Null;
export type RedirectHTTP = types.Null;
export type SetXForwarded = types.Null;
export type HideXForwarded = types.Null;
/**
* @additionalProperties false
@ -144,18 +147,3 @@ export type RealIP = {
*/
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
*/
export type HomepageConfig = {
/** Whether show in dashboard
*
* @default true
*/
show?: boolean;
/* Display name on dashboard */
name: string;
name?: string;
/* Display icon on dashboard */
icon?: URL | WalkxcodeIcon | TargetRelativeIconPath;
/* App description */

View file

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

View file

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