This is an automated email from the ASF dual-hosted git repository.
moonming pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/apisix.git
The following commit(s) were added to refs/heads/master by this push:
new 9b4e4ca249 docs: correct Admin API schema metadata (#14206)
9b4e4ca249 is described below
commit 9b4e4ca24993b70fa8541066e7e21ad6d2bfde1d
Author: Traky Deng <[email protected]>
AuthorDate: Wed Nov 18 22:47:56 2026 +0800
docs: correct Admin API schema metadata (#14206)
---
docs/en/latest/admin-api.json | 285 +++++++++++++++++++--
.../components/schemas/ConfigValidationRoute.yaml | 1 +
.../schemas/ConfigValidationStreamRoute.yaml | 1 +
.../admin-api/components/schemas/Route.yaml | 7 +-
.../admin-api/components/schemas/RoutePatch.yaml | 1 +
.../admin-api/components/schemas/RouteRead.yaml | 7 +-
docs/openapi/admin-api/components/schemas/SSL.yaml | 10 +-
.../admin-api/components/schemas/SSLRead.yaml | 10 +-
.../admin-api/components/schemas/SecretPatch.yaml | 109 +++++++-
.../admin-api/components/schemas/StreamRoute.yaml | 1 +
.../components/schemas/StreamRouteRead.yaml | 1 +
.../admin-api/components/schemas/Upstream.yaml | 26 +-
.../admin-api/components/schemas/UpstreamRead.yaml | 26 +-
t/openapi/test_validator.py | 43 ++++
utils/validate-admin-api.py | 9 +
15 files changed, 501 insertions(+), 36 deletions(-)
diff --git a/docs/en/latest/admin-api.json b/docs/en/latest/admin-api.json
index 48f1f84965..aa3103371b 100644
--- a/docs/en/latest/admin-api.json
+++ b/docs/en/latest/admin-api.json
@@ -9727,7 +9727,7 @@
"type": {
"default": "roundrobin",
"type": "string",
- "description": "algorithms of load balancing"
+ "description": "Load balancing algorithm. Built-in values are
`roundrobin`, `chash`, `ewma`, and `least_conn`; user-defined balancers can
provide other values."
},
"pass_host": {
"default": "pass",
@@ -9737,7 +9737,12 @@
"rewrite"
],
"type": "string",
- "description": "mod of host passing"
+ "description": "How to set the `Host` header when proxying to the
upstream.",
+ "x-enumDescriptions": {
+ "pass": "Forward the client's original `Host` header.",
+ "node": "Use the upstream node's hostname.",
+ "rewrite": "Use the value of `upstream_host`."
+ }
},
"scheme": {
"description": "The scheme of the upstream. For L7 proxy, it can
be one of grpc/grpcs/http/https/ws/wss. For L4 proxy, it can be one of
tcp/tls/udp. For specific protocols, it can be kafka.",
@@ -9753,7 +9758,19 @@
"ws",
"wss"
],
- "default": "http"
+ "default": "http",
+ "x-enumDescriptions": {
+ "grpc": "Layer 7 gRPC.",
+ "grpcs": "Layer 7 gRPC over TLS.",
+ "http": "Layer 7 HTTP.",
+ "https": "Layer 7 HTTP over TLS.",
+ "tcp": "Layer 4 TCP.",
+ "tls": "Layer 4 TCP over TLS.",
+ "udp": "Layer 4 UDP.",
+ "kafka": "Apache Kafka protocol.",
+ "ws": "Frame-aware WebSocket proxying; `enable_websocket` is
ignored.",
+ "wss": "Frame-aware WebSocket proxying over TLS; uses the shared
CA trust store, not `tls.ca_certs`."
+ }
},
"upstream_host": {
"pattern": "^\\*$|^\\*?[0-9a-zA-Z-._\\[\\]:]+$",
@@ -9839,7 +9856,15 @@
"vars_combinations"
],
"default": "vars",
- "type": "string"
+ "type": "string",
+ "description": "What to hash on when `type` is `chash`.",
+ "x-enumDescriptions": {
+ "vars": "Hash on an NGINX variable specified by `key`.",
+ "header": "Hash on a request header specified by `key`.",
+ "cookie": "Hash on a cookie value specified by `key`.",
+ "consumer": "Hash on the authenticated consumer name.",
+ "vars_combinations": "Hash on a combination of variables."
+ }
},
"keepalive_pool": {
"properties": {
@@ -10272,7 +10297,7 @@
"type": {
"default": "roundrobin",
"type": "string",
- "description": "algorithms of load balancing"
+ "description": "Load balancing algorithm. Built-in values are
`roundrobin`, `chash`, `ewma`, and `least_conn`; user-defined balancers can
provide other values."
},
"pass_host": {
"default": "pass",
@@ -10282,7 +10307,12 @@
"rewrite"
],
"type": "string",
- "description": "mod of host passing"
+ "description": "How to set the `Host` header when proxying to the
upstream.",
+ "x-enumDescriptions": {
+ "pass": "Forward the client's original `Host` header.",
+ "node": "Use the upstream node's hostname.",
+ "rewrite": "Use the value of `upstream_host`."
+ }
},
"scheme": {
"description": "The scheme of the upstream. For L7 proxy, it can
be one of grpc/grpcs/http/https/ws/wss. For L4 proxy, it can be one of
tcp/tls/udp. For specific protocols, it can be kafka.",
@@ -10298,7 +10328,19 @@
"ws",
"wss"
],
- "default": "http"
+ "default": "http",
+ "x-enumDescriptions": {
+ "grpc": "Layer 7 gRPC.",
+ "grpcs": "Layer 7 gRPC over TLS.",
+ "http": "Layer 7 HTTP.",
+ "https": "Layer 7 HTTP over TLS.",
+ "tcp": "Layer 4 TCP.",
+ "tls": "Layer 4 TCP over TLS.",
+ "udp": "Layer 4 UDP.",
+ "kafka": "Apache Kafka protocol.",
+ "ws": "Frame-aware WebSocket proxying; `enable_websocket` is
ignored.",
+ "wss": "Frame-aware WebSocket proxying over TLS; uses the shared
CA trust store, not `tls.ca_certs`."
+ }
},
"upstream_host": {
"pattern": "^\\*$|^\\*?[0-9a-zA-Z-._\\[\\]:]+$",
@@ -10384,7 +10426,15 @@
"vars_combinations"
],
"default": "vars",
- "type": "string"
+ "type": "string",
+ "description": "What to hash on when `type` is `chash`.",
+ "x-enumDescriptions": {
+ "vars": "Hash on an NGINX variable specified by `key`.",
+ "header": "Hash on a request header specified by `key`.",
+ "cookie": "Hash on a cookie value specified by `key`.",
+ "consumer": "Hash on the authenticated consumer name.",
+ "vars_combinations": "Hash on a combination of variables."
+ }
},
"keepalive_pool": {
"properties": {
@@ -10702,7 +10752,9 @@
"readOnly": true
},
"vars": {
- "type": "array"
+ "type": "array",
+ "items": {},
+ "description": "Custom matching conditions using APISIX
expressions. Each condition is an array of `[variable, operator, value]`."
},
"plugins": {
"type": "object"
@@ -10728,7 +10780,11 @@
0
],
"type": "integer",
- "description": "route status, 1 to enable, 0 to disable"
+ "description": "Route status.",
+ "x-enumDescriptions": {
+ "0": "Disabled.",
+ "1": "Enabled (default)."
+ }
},
"enable_websocket": {
"type": "boolean",
@@ -11718,7 +11774,9 @@
"readOnly": true
},
"vars": {
- "type": "array"
+ "type": "array",
+ "items": {},
+ "description": "Custom matching conditions using APISIX
expressions. Each condition is an array of `[variable, operator, value]`."
},
"plugins": {
"type": "object"
@@ -11744,7 +11802,11 @@
0
],
"type": "integer",
- "description": "route status, 1 to enable, 0 to disable"
+ "description": "Route status.",
+ "x-enumDescriptions": {
+ "0": "Disabled.",
+ "1": "Enabled (default)."
+ }
},
"enable_websocket": {
"type": "boolean",
@@ -12895,12 +12957,16 @@
},
"status": {
"default": 1,
- "description": "ssl status, 1 to enable, 0 to disable",
+ "description": "SSL status.",
"enum": [
1,
0
],
- "type": "integer"
+ "type": "integer",
+ "x-enumDescriptions": {
+ "0": "Disabled.",
+ "1": "Enabled (default)."
+ }
},
"cert": {
"$ref": "#/components/schemas/CertificateOrReference",
@@ -12960,9 +13026,13 @@
"server",
"client"
],
- "description": "ssl certificate type, server to server
certificate, client to client certificate for upstream",
+ "description": "Certificate type.",
"default": "server",
- "type": "string"
+ "type": "string",
+ "x-enumDescriptions": {
+ "server": "HTTPS termination matched by SNI.",
+ "client": "Client certificate for mTLS with upstream services."
+ }
}
},
"type": "object",
@@ -13347,6 +13417,7 @@
},
"filter": {
"type": "array",
+ "items": {},
"description": "logger filter rules"
},
"conf": {
@@ -14162,6 +14233,7 @@
},
"filter": {
"type": "array",
+ "items": {},
"description": "logger filter rules"
},
"conf": {
@@ -14287,12 +14359,16 @@
},
"status": {
"default": 1,
- "description": "ssl status, 1 to enable, 0 to disable",
+ "description": "SSL status.",
"enum": [
1,
0
],
- "type": "integer"
+ "type": "integer",
+ "x-enumDescriptions": {
+ "0": "Disabled.",
+ "1": "Enabled (default)."
+ }
},
"cert": {
"$ref": "#/components/schemas/CertificateOrReference",
@@ -14346,9 +14422,13 @@
"server",
"client"
],
- "description": "ssl certificate type, server to server
certificate, client to client certificate for upstream",
+ "description": "Certificate type.",
"default": "server",
- "type": "string"
+ "type": "string",
+ "x-enumDescriptions": {
+ "server": "HTTPS termination matched by SNI.",
+ "client": "Client certificate for mTLS with upstream services."
+ }
}
},
"type": "object",
@@ -16130,7 +16210,8 @@
"vars": {
"anyOf": [
{
- "type": "array"
+ "type": "array",
+ "items": {}
},
{
"type": "null"
@@ -18595,8 +18676,162 @@
"description": "Recursive merge fragment. Null deletes object fields;
arrays are replaced. APISIX validates the resulting resource, including plugin
and reference checks."
},
"SecretPatch": {
- "type": "object",
- "description": "Manager-specific recursive merge fragment. The
resulting configuration must match the selected secret manager schema."
+ "description": "Partial update for an existing `Secret`. APISIX
recursively merges object fields, replaces arrays, and removes an object field
when its value is `null`. The merged resource is then validated against the
complete `Secret` schema.",
+ "anyOf": [
+ {
+ "type": "object",
+ "title": "HashiCorp Vault",
+ "description": "HashiCorp Vault secret-manager configuration.",
+ "properties": {
+ "uri": {
+ "type": [
+ "string",
+ "null"
+ ],
+ "format": "uri",
+ "description": "Vault server URI."
+ },
+ "prefix": {
+ "type": [
+ "string",
+ "null"
+ ],
+ "description": "Path prefix for secrets in Vault."
+ },
+ "token": {
+ "type": [
+ "string",
+ "null"
+ ],
+ "description": "Vault authentication token or
environment-variable URI."
+ },
+ "namespace": {
+ "type": [
+ "string",
+ "null"
+ ],
+ "description": "Vault Enterprise or HCP Vault namespace."
+ }
+ }
+ },
+ {
+ "type": "object",
+ "title": "AWS Secrets Manager",
+ "description": "AWS Secrets Manager configuration.",
+ "properties": {
+ "access_key_id": {
+ "type": [
+ "string",
+ "null"
+ ],
+ "description": "AWS access key ID or environment-variable URI."
+ },
+ "secret_access_key": {
+ "type": [
+ "string",
+ "null"
+ ],
+ "description": "AWS secret access key or environment-variable
URI."
+ },
+ "session_token": {
+ "type": [
+ "string",
+ "null"
+ ],
+ "description": "Optional AWS session token or
environment-variable URI."
+ },
+ "region": {
+ "type": [
+ "string",
+ "null"
+ ],
+ "default": "us-east-1",
+ "description": "AWS region."
+ },
+ "endpoint_url": {
+ "type": [
+ "string",
+ "null"
+ ],
+ "format": "uri",
+ "description": "Custom AWS Secrets Manager endpoint."
+ }
+ }
+ },
+ {
+ "type": "object",
+ "title": "Google Cloud Secret Manager",
+ "description": "Google Cloud Secret Manager configuration.",
+ "properties": {
+ "auth_config": {
+ "type": [
+ "object",
+ "null"
+ ],
+ "properties": {
+ "client_email": {
+ "type": [
+ "string",
+ "null"
+ ]
+ },
+ "private_key": {
+ "type": [
+ "string",
+ "null"
+ ]
+ },
+ "project_id": {
+ "type": [
+ "string",
+ "null"
+ ]
+ },
+ "token_uri": {
+ "type": [
+ "string",
+ "null"
+ ],
+ "default": "https://oauth2.googleapis.com/token"
+ },
+ "scope": {
+ "type": [
+ "array",
+ "null"
+ ],
+ "items": {
+ "type": "string"
+ },
+ "default": [
+ "https://www.googleapis.com/auth/cloud-platform"
+ ]
+ },
+ "entries_uri": {
+ "type": [
+ "string",
+ "null"
+ ],
+ "default": "https://secretmanager.googleapis.com/v1"
+ }
+ }
+ },
+ "ssl_verify": {
+ "type": [
+ "boolean",
+ "null"
+ ],
+ "default": true
+ },
+ "auth_file": {
+ "type": [
+ "string",
+ "null"
+ ],
+ "description": "Path to a Google service-account JSON file."
+ }
+ }
+ }
+ ]
},
"ConfigValidationDocument": {
"type": "object",
@@ -19165,7 +19400,8 @@
"type": "string"
},
"vars": {
- "type": "array"
+ "type": "array",
+ "items": {}
},
"name": {
"minLength": 1,
@@ -19632,6 +19868,7 @@
},
"filter": {
"type": "array",
+ "items": {},
"description": "logger filter rules"
}
},
diff --git
a/docs/openapi/admin-api/components/schemas/ConfigValidationRoute.yaml
b/docs/openapi/admin-api/components/schemas/ConfigValidationRoute.yaml
index c80da9199c..7c293ea2b9 100644
--- a/docs/openapi/admin-api/components/schemas/ConfigValidationRoute.yaml
+++ b/docs/openapi/admin-api/components/schemas/ConfigValidationRoute.yaml
@@ -195,6 +195,7 @@ properties:
type: string
vars:
type: array
+ items: {}
name:
minLength: 1
maxLength: 256
diff --git
a/docs/openapi/admin-api/components/schemas/ConfigValidationStreamRoute.yaml
b/docs/openapi/admin-api/components/schemas/ConfigValidationStreamRoute.yaml
index 34629ab8e9..6b530cf7dc 100644
--- a/docs/openapi/admin-api/components/schemas/ConfigValidationStreamRoute.yaml
+++ b/docs/openapi/admin-api/components/schemas/ConfigValidationStreamRoute.yaml
@@ -38,6 +38,7 @@ properties:
description: logger plugin configuration
filter:
type: array
+ items: {}
description: logger filter rules
dependentRequired:
name:
diff --git a/docs/openapi/admin-api/components/schemas/Route.yaml
b/docs/openapi/admin-api/components/schemas/Route.yaml
index 917bca7d0e..34b2452f71 100644
--- a/docs/openapi/admin-api/components/schemas/Route.yaml
+++ b/docs/openapi/admin-api/components/schemas/Route.yaml
@@ -121,6 +121,8 @@ properties:
readOnly: true
vars:
type: array
+ items: {}
+ description: Custom matching conditions using APISIX expressions. Each
condition is an array of `[variable, operator, value]`.
plugins:
type: object
id:
@@ -137,7 +139,10 @@ properties:
- 1
- 0
type: integer
- description: route status, 1 to enable, 0 to disable
+ description: Route status.
+ x-enumDescriptions:
+ "0": Disabled.
+ "1": Enabled (default).
enable_websocket:
type: boolean
description: enable websocket for request
diff --git a/docs/openapi/admin-api/components/schemas/RoutePatch.yaml
b/docs/openapi/admin-api/components/schemas/RoutePatch.yaml
index 5e2f7dc030..060b08020f 100644
--- a/docs/openapi/admin-api/components/schemas/RoutePatch.yaml
+++ b/docs/openapi/admin-api/components/schemas/RoutePatch.yaml
@@ -646,6 +646,7 @@ properties:
vars:
anyOf:
- type: array
+ items: {}
- type: "null"
name:
anyOf:
diff --git a/docs/openapi/admin-api/components/schemas/RouteRead.yaml
b/docs/openapi/admin-api/components/schemas/RouteRead.yaml
index 31a0bfa312..ab65e3453d 100644
--- a/docs/openapi/admin-api/components/schemas/RouteRead.yaml
+++ b/docs/openapi/admin-api/components/schemas/RouteRead.yaml
@@ -121,6 +121,8 @@ properties:
readOnly: true
vars:
type: array
+ items: {}
+ description: Custom matching conditions using APISIX expressions. Each
condition is an array of `[variable, operator, value]`.
plugins:
type: object
id:
@@ -137,7 +139,10 @@ properties:
- 1
- 0
type: integer
- description: route status, 1 to enable, 0 to disable
+ description: Route status.
+ x-enumDescriptions:
+ "0": Disabled.
+ "1": Enabled (default).
enable_websocket:
type: boolean
description: enable websocket for request
diff --git a/docs/openapi/admin-api/components/schemas/SSL.yaml
b/docs/openapi/admin-api/components/schemas/SSL.yaml
index 21c13af439..408221b4f1 100644
--- a/docs/openapi/admin-api/components/schemas/SSL.yaml
+++ b/docs/openapi/admin-api/components/schemas/SSL.yaml
@@ -64,11 +64,14 @@ properties:
$ref: ./Labels.yaml
status:
default: 1
- description: ssl status, 1 to enable, 0 to disable
+ description: SSL status.
enum:
- 1
- 0
type: integer
+ x-enumDescriptions:
+ "0": Disabled.
+ "1": Enabled (default).
cert:
$ref: ./CertificateOrReference.yaml
description: PEM-encoded certificate or an APISIX secret/environment
reference.
@@ -111,8 +114,11 @@ properties:
enum:
- server
- client
- description: ssl certificate type, server to server certificate, client to
client certificate for upstream
+ description: Certificate type.
default: server
type: string
+ x-enumDescriptions:
+ server: HTTPS termination matched by SNI.
+ client: Client certificate for mTLS with upstream services.
type: object
x-source: apisix/schema_def.lua
diff --git a/docs/openapi/admin-api/components/schemas/SSLRead.yaml
b/docs/openapi/admin-api/components/schemas/SSLRead.yaml
index e501061d4d..5545d24c32 100644
--- a/docs/openapi/admin-api/components/schemas/SSLRead.yaml
+++ b/docs/openapi/admin-api/components/schemas/SSLRead.yaml
@@ -42,11 +42,14 @@ properties:
$ref: ./Labels.yaml
status:
default: 1
- description: ssl status, 1 to enable, 0 to disable
+ description: SSL status.
enum:
- 1
- 0
type: integer
+ x-enumDescriptions:
+ "0": Disabled.
+ "1": Enabled (default).
cert:
$ref: ./CertificateOrReference.yaml
description: Stored PEM certificate or APISIX secret/environment reference.
@@ -85,9 +88,12 @@ properties:
enum:
- server
- client
- description: ssl certificate type, server to server certificate, client to
client certificate for upstream
+ description: Certificate type.
default: server
type: string
+ x-enumDescriptions:
+ server: HTTPS termination matched by SNI.
+ client: Client certificate for mTLS with upstream services.
type: object
x-source: apisix/schema_def.lua
description: SSL read-response representation. Private-key fields are omitted
from GET responses.
diff --git a/docs/openapi/admin-api/components/schemas/SecretPatch.yaml
b/docs/openapi/admin-api/components/schemas/SecretPatch.yaml
index b71f264659..4b85c02e6f 100644
--- a/docs/openapi/admin-api/components/schemas/SecretPatch.yaml
+++ b/docs/openapi/admin-api/components/schemas/SecretPatch.yaml
@@ -14,5 +14,110 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
-type: object
-description: Manager-specific recursive merge fragment. The resulting
configuration must match the selected secret manager schema.
+description: Partial update for an existing `Secret`. APISIX recursively
merges object fields, replaces arrays, and removes an object field when its
value is `null`. The merged resource is then validated against the complete
`Secret` schema.
+anyOf:
+ - type: object
+ title: HashiCorp Vault
+ description: HashiCorp Vault secret-manager configuration.
+ properties:
+ uri:
+ type:
+ - string
+ - "null"
+ format: uri
+ description: Vault server URI.
+ prefix:
+ type:
+ - string
+ - "null"
+ description: Path prefix for secrets in Vault.
+ token:
+ type:
+ - string
+ - "null"
+ description: Vault authentication token or environment-variable URI.
+ namespace:
+ type:
+ - string
+ - "null"
+ description: Vault Enterprise or HCP Vault namespace.
+ - type: object
+ title: AWS Secrets Manager
+ description: AWS Secrets Manager configuration.
+ properties:
+ access_key_id:
+ type:
+ - string
+ - "null"
+ description: AWS access key ID or environment-variable URI.
+ secret_access_key:
+ type:
+ - string
+ - "null"
+ description: AWS secret access key or environment-variable URI.
+ session_token:
+ type:
+ - string
+ - "null"
+ description: Optional AWS session token or environment-variable URI.
+ region:
+ type:
+ - string
+ - "null"
+ default: us-east-1
+ description: AWS region.
+ endpoint_url:
+ type:
+ - string
+ - "null"
+ format: uri
+ description: Custom AWS Secrets Manager endpoint.
+ - type: object
+ title: Google Cloud Secret Manager
+ description: Google Cloud Secret Manager configuration.
+ properties:
+ auth_config:
+ type:
+ - object
+ - "null"
+ properties:
+ client_email:
+ type:
+ - string
+ - "null"
+ private_key:
+ type:
+ - string
+ - "null"
+ project_id:
+ type:
+ - string
+ - "null"
+ token_uri:
+ type:
+ - string
+ - "null"
+ default: https://oauth2.googleapis.com/token
+ scope:
+ type:
+ - array
+ - "null"
+ items:
+ type: string
+ default:
+ - https://www.googleapis.com/auth/cloud-platform
+ entries_uri:
+ type:
+ - string
+ - "null"
+ default: https://secretmanager.googleapis.com/v1
+ ssl_verify:
+ type:
+ - boolean
+ - "null"
+ default: true
+ auth_file:
+ type:
+ - string
+ - "null"
+ description: Path to a Google service-account JSON file.
diff --git a/docs/openapi/admin-api/components/schemas/StreamRoute.yaml
b/docs/openapi/admin-api/components/schemas/StreamRoute.yaml
index 66e2d31674..a63dc13500 100644
--- a/docs/openapi/admin-api/components/schemas/StreamRoute.yaml
+++ b/docs/openapi/admin-api/components/schemas/StreamRoute.yaml
@@ -128,6 +128,7 @@ properties:
type: string
filter:
type: array
+ items: {}
description: logger filter rules
conf:
type: object
diff --git a/docs/openapi/admin-api/components/schemas/StreamRouteRead.yaml
b/docs/openapi/admin-api/components/schemas/StreamRouteRead.yaml
index 041026d149..49e1d0c0ef 100644
--- a/docs/openapi/admin-api/components/schemas/StreamRouteRead.yaml
+++ b/docs/openapi/admin-api/components/schemas/StreamRouteRead.yaml
@@ -128,6 +128,7 @@ properties:
type: string
filter:
type: array
+ items: {}
description: logger filter rules
conf:
type: object
diff --git a/docs/openapi/admin-api/components/schemas/Upstream.yaml
b/docs/openapi/admin-api/components/schemas/Upstream.yaml
index a263f95798..7fc2f652fa 100644
--- a/docs/openapi/admin-api/components/schemas/Upstream.yaml
+++ b/docs/openapi/admin-api/components/schemas/Upstream.yaml
@@ -304,7 +304,7 @@ properties:
type:
default: roundrobin
type: string
- description: algorithms of load balancing
+ description: Load balancing algorithm. Built-in values are `roundrobin`,
`chash`, `ewma`, and `least_conn`; user-defined balancers can provide other
values.
pass_host:
default: pass
enum:
@@ -312,7 +312,11 @@ properties:
- node
- rewrite
type: string
- description: mod of host passing
+ description: How to set the `Host` header when proxying to the upstream.
+ x-enumDescriptions:
+ pass: Forward the client's original `Host` header.
+ node: Use the upstream node's hostname.
+ rewrite: Use the value of `upstream_host`.
scheme:
description: The scheme of the upstream. For L7 proxy, it can be one of
grpc/grpcs/http/https/ws/wss. For L4 proxy, it can be one of tcp/tls/udp. For
specific protocols, it can be kafka.
enum:
@@ -327,6 +331,17 @@ properties:
- ws
- wss
default: http
+ x-enumDescriptions:
+ grpc: Layer 7 gRPC.
+ grpcs: Layer 7 gRPC over TLS.
+ http: Layer 7 HTTP.
+ https: Layer 7 HTTP over TLS.
+ tcp: Layer 4 TCP.
+ tls: Layer 4 TCP over TLS.
+ udp: Layer 4 UDP.
+ kafka: Apache Kafka protocol.
+ ws: Frame-aware WebSocket proxying; `enable_websocket` is ignored.
+ wss: Frame-aware WebSocket proxying over TLS; uses the shared CA trust
store, not `tls.ca_certs`.
upstream_host:
pattern: ^\*$|^\*?[0-9a-zA-Z-._\[\]:]+$
type: string
@@ -394,6 +409,13 @@ properties:
- vars_combinations
default: vars
type: string
+ description: What to hash on when `type` is `chash`.
+ x-enumDescriptions:
+ vars: Hash on an NGINX variable specified by `key`.
+ header: Hash on a request header specified by `key`.
+ cookie: Hash on a cookie value specified by `key`.
+ consumer: Hash on the authenticated consumer name.
+ vars_combinations: Hash on a combination of variables.
keepalive_pool:
properties:
requests:
diff --git a/docs/openapi/admin-api/components/schemas/UpstreamRead.yaml
b/docs/openapi/admin-api/components/schemas/UpstreamRead.yaml
index 901d1c8a86..170f06b741 100644
--- a/docs/openapi/admin-api/components/schemas/UpstreamRead.yaml
+++ b/docs/openapi/admin-api/components/schemas/UpstreamRead.yaml
@@ -270,7 +270,7 @@ properties:
type:
default: roundrobin
type: string
- description: algorithms of load balancing
+ description: Load balancing algorithm. Built-in values are `roundrobin`,
`chash`, `ewma`, and `least_conn`; user-defined balancers can provide other
values.
pass_host:
default: pass
enum:
@@ -278,7 +278,11 @@ properties:
- node
- rewrite
type: string
- description: mod of host passing
+ description: How to set the `Host` header when proxying to the upstream.
+ x-enumDescriptions:
+ pass: Forward the client's original `Host` header.
+ node: Use the upstream node's hostname.
+ rewrite: Use the value of `upstream_host`.
scheme:
description: The scheme of the upstream. For L7 proxy, it can be one of
grpc/grpcs/http/https/ws/wss. For L4 proxy, it can be one of tcp/tls/udp. For
specific protocols, it can be kafka.
enum:
@@ -293,6 +297,17 @@ properties:
- ws
- wss
default: http
+ x-enumDescriptions:
+ grpc: Layer 7 gRPC.
+ grpcs: Layer 7 gRPC over TLS.
+ http: Layer 7 HTTP.
+ https: Layer 7 HTTP over TLS.
+ tcp: Layer 4 TCP.
+ tls: Layer 4 TCP over TLS.
+ udp: Layer 4 UDP.
+ kafka: Apache Kafka protocol.
+ ws: Frame-aware WebSocket proxying; `enable_websocket` is ignored.
+ wss: Frame-aware WebSocket proxying over TLS; uses the shared CA trust
store, not `tls.ca_certs`.
upstream_host:
pattern: ^\*$|^\*?[0-9a-zA-Z-._\[\]:]+$
type: string
@@ -360,6 +375,13 @@ properties:
- vars_combinations
default: vars
type: string
+ description: What to hash on when `type` is `chash`.
+ x-enumDescriptions:
+ vars: Hash on an NGINX variable specified by `key`.
+ header: Hash on a request header specified by `key`.
+ cookie: Hash on a cookie value specified by `key`.
+ consumer: Hash on the authenticated consumer name.
+ vars_combinations: Hash on a combination of variables.
keepalive_pool:
properties:
requests:
diff --git a/t/openapi/test_validator.py b/t/openapi/test_validator.py
index 05afb9afb9..52c0f337a1 100644
--- a/t/openapi/test_validator.py
+++ b/t/openapi/test_validator.py
@@ -92,6 +92,49 @@ class ContractValidationTest(unittest.TestCase):
'properties']['field_path']['pattern'] = '^incorrect$'
self.assertTrue(validator.validate_source(document, ROOT))
+ def test_admin_reference_metadata(self):
+ schemas = self.document['components']['schemas']
+
+ upstream_type = schemas['Upstream']['properties']['type']
+ self.assertNotIn('enum', upstream_type)
+ self.assertIn('user-defined balancers', upstream_type['description'])
+
+ enum_fields = {
+ 'Upstream': ('hash_on', 'scheme', 'pass_host'),
+ 'Route': ('status',),
+ 'SSL': ('type', 'status'),
+ 'SSLRead': ('type', 'status'),
+ }
+ for schema_name, property_names in enum_fields.items():
+ for property_name in property_names:
+ prop = schemas[schema_name]['properties'][property_name]
+ self.assertEqual(
+ {str(value) for value in prop['enum']},
+ set(prop['x-enumDescriptions']),
+ )
+
+ secret_patch = schemas['SecretPatch']
+ self.assertEqual(3, len(secret_patch['anyOf']))
+ self.assertEqual(
+ {'HashiCorp Vault', 'AWS Secrets Manager',
+ 'Google Cloud Secret Manager'},
+ {branch['title'] for branch in secret_patch['anyOf']},
+ )
+ for value in (
+ {'token': None},
+ {'session_token': None},
+ {'auth_config': {'client_email': None}}):
+ errors =
validator.Draft202012Validator(secret_patch).iter_errors(value)
+ self.assertFalse(list(errors))
+
+ def test_unconstrained_array_items_are_explicit(self):
+ document = deepcopy(self.document)
+ del document['components']['schemas']['Route'][
+ 'properties']['vars']['items']
+ errors = validator.validate(document, self.versions)
+ self.assertTrue(any(
+ 'array schema must declare items' in error for error in errors))
+
if __name__ == '__main__':
unittest.main()
diff --git a/utils/validate-admin-api.py b/utils/validate-admin-api.py
index 3c46250ec5..aec44355af 100644
--- a/utils/validate-admin-api.py
+++ b/utils/validate-admin-api.py
@@ -107,6 +107,13 @@ def validate(document, versions):
errors.append(f'{path}: {exc}')
if '$id' in obj:
errors.append(f'{path}: embedded $id changes local ref scope; use
document pointers')
+ schema_type = obj.get('type')
+ is_array = schema_type == 'array' or (
+ isinstance(schema_type, list) and 'array' in schema_type)
+ if is_array and 'items' not in obj:
+ errors.append(
+ f'{path}: array schema must declare items; '
+ 'use an empty object for unconstrained elements')
if errors:
return errors
@@ -257,6 +264,8 @@ def validate_source(document, root):
result = {k: constraints(v) for k, v in value.items()
if k not in {'description', 'title', 'readOnly', 'examples',
'example'}
and not k.startswith('x-')}
+ if result.get('items') == {}:
+ result.pop('items')
# APISIX's JSON Schema validator skips structural validation for
# $secret:// and $env:// values. OpenAPI models that runtime hook