This is an automated email from the ASF dual-hosted git repository.
kayx23 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 533dc2e61 docs: fix mocking config note and invalid JSON in
elasticsearch-logger examples (#13543)
533dc2e61 is described below
commit 533dc2e61f7368e505355a042a11cfb746b86693
Author: AlinsRan <[email protected]>
AuthorDate: Mon Jun 15 18:08:06 2026 +0800
docs: fix mocking config note and invalid JSON in elasticsearch-logger
examples (#13543)
* docs: fix mocking config note and invalid JSON in elasticsearch-logger
examples
- mocking: the docs say response_example and response_schema must not be
configured together, but the schema uses anyOf (at least one) and the
plugin prefers response_example when both are set. Correct the en/zh
description accordingly.
- elasticsearch-logger: the Admin API examples had a trailing comma after
the only field ("index": "gateway",), making the JSON invalid for
copy-paste. Remove it (en + zh, two places each).
Signed-off-by: AlinsRan <[email protected]>
* docs(mocking): clarify response_example/response_schema are not mutually
exclusive
The Required column said 'One of this or ...' / '二选一', implying the two
fields are mutually exclusive, but the schema uses anyOf (at least one) and
the
plugin accepts both with response_example taking precedence. Align the
column
with that behavior.
Signed-off-by: AlinsRan <[email protected]>
---------
Signed-off-by: AlinsRan <[email protected]>
---
docs/en/latest/plugins/elasticsearch-logger.md | 4 ++--
docs/en/latest/plugins/mocking.md | 4 ++--
docs/zh/latest/plugins/elasticsearch-logger.md | 4 ++--
docs/zh/latest/plugins/mocking.md | 6 +++---
4 files changed, 9 insertions(+), 9 deletions(-)
diff --git a/docs/en/latest/plugins/elasticsearch-logger.md
b/docs/en/latest/plugins/elasticsearch-logger.md
index 97a8727ba..0e4a5dfd4 100644
--- a/docs/en/latest/plugins/elasticsearch-logger.md
+++ b/docs/en/latest/plugins/elasticsearch-logger.md
@@ -125,7 +125,7 @@ curl "http://127.0.0.1:9180/apisix/admin/routes" -X PUT \
"elasticsearch-logger": {
"endpoint_addrs": ["http://elasticsearch:9200"],
"field": {
- "index": "gateway",
+ "index": "gateway"
}
}
},
@@ -288,7 +288,7 @@ curl "http://127.0.0.1:9180/apisix/admin/routes" -X PUT \
"elasticsearch-logger": {
"endpoint_addrs": ["http://elasticsearch:9200"],
"field": {
- "index": "gateway",
+ "index": "gateway"
},
"include_req_body": true,
"include_req_body_expr": [["arg_log_body", "==", "yes"]]
diff --git a/docs/en/latest/plugins/mocking.md
b/docs/en/latest/plugins/mocking.md
index 3a2a4edb7..deb0f9e2e 100644
--- a/docs/en/latest/plugins/mocking.md
+++ b/docs/en/latest/plugins/mocking.md
@@ -43,8 +43,8 @@ The `mocking` Plugin allows you to simulate API responses
without forwarding req
| delay | integer | False | 0
| Response delay in seconds.
|
| response_status | integer | False | 200
| HTTP status code of the response.
|
| content_type | string | False |
application/json;charset=utf8 | `Content-Type` header value of the response.
|
-| response_example | string | One of this or `response_schema` |
| Body of the response. Supports [NGINX
variables](https://nginx.org/en/docs/http/ngx_http_core_module.html), such as
`$remote_addr`. One of `response_example` or `response_schema` must be
configured, and they must not be configured together. |
-| response_schema | object | One of this or `response_example` |
| A [JSON schema](https://json-schema.org) object to generate
a random mock response body. One of `response_schema` or `response_example`
must be configured, and they must not be configured together. |
+| response_example | string | At least one of this or `response_schema` |
| Body of the response. Supports [NGINX
variables](https://nginx.org/en/docs/http/ngx_http_core_module.html), such as
`$remote_addr`. At least one of `response_example` or `response_schema` must be
configured. If both are configured, `response_example` takes precedence and
`response_schema` is ignored. |
+| response_schema | object | At least one of this or `response_example` |
| A [JSON schema](https://json-schema.org) object to
generate a random mock response body. At least one of `response_schema` or
`response_example` must be configured. If both are configured,
`response_example` takes precedence and `response_schema` is ignored. |
| with_mock_header | boolean | False | true
| When set to `true`, adds a response header `x-mock-by:
APISIX/{version}`.
|
| response_headers | object | False |
| Headers to be added in the mocked response. For example:
`{"X-Foo": "bar"}`.
|
diff --git a/docs/zh/latest/plugins/elasticsearch-logger.md
b/docs/zh/latest/plugins/elasticsearch-logger.md
index 015821054..38c72ebee 100644
--- a/docs/zh/latest/plugins/elasticsearch-logger.md
+++ b/docs/zh/latest/plugins/elasticsearch-logger.md
@@ -126,7 +126,7 @@ curl "http://127.0.0.1:9180/apisix/admin/routes" -X PUT \
"elasticsearch-logger": {
"endpoint_addrs": ["http://elasticsearch:9200"],
"field": {
- "index": "gateway",
+ "index": "gateway"
}
}
},
@@ -289,7 +289,7 @@ curl "http://127.0.0.1:9180/apisix/admin/routes" -X PUT \
"elasticsearch-logger": {
"endpoint_addrs": ["http://elasticsearch:9200"],
"field": {
- "index": "gateway",
+ "index": "gateway"
},
"include_req_body": true,
"include_req_body_expr": [["arg_log_body", "==", "yes"]]
diff --git a/docs/zh/latest/plugins/mocking.md
b/docs/zh/latest/plugins/mocking.md
index 2c7880a7e..e7a0d3374 100644
--- a/docs/zh/latest/plugins/mocking.md
+++ b/docs/zh/latest/plugins/mocking.md
@@ -43,13 +43,13 @@ description: mocking 插件无需转发请求到上游服务即可模拟 API 响
| delay | integer | 否 | 0 |
延迟返回响应的时间,单位为秒。
|
| response_status | integer | 否 | 200 | 响应的
HTTP 状态码。
|
| content_type | string | 否 | application/json;charset=utf8 | 响应的
`Content-Type` 标头值。
|
-| response_example | string | 二选一 | | 响应体内容。支持
[NGINX 变量](https://nginx.org/en/docs/http/ngx_http_core_module.html),例如
`$remote_addr`。与 `response_schema` 二选一,且至少配置其中一个,不能同时配置。 |
-| response_schema | object | 二选一 | |
用于生成随机模拟响应体的 [JSON Schema](https://json-schema.org) 对象。与 `response_example`
二选一,且至少配置其中一个,不能同时配置。 |
+| response_example | string | 二者至少其一 | |
响应体内容。支持 [NGINX
变量](https://nginx.org/en/docs/http/ngx_http_core_module.html),例如
`$remote_addr`。`response_example` 与 `response_schema` 至少配置其中一个;若同时配置,以
`response_example` 为准,`response_schema` 将被忽略。 |
+| response_schema | object | 二者至少其一 | |
用于生成随机模拟响应体的 [JSON Schema](https://json-schema.org) 对象。`response_schema` 与
`response_example` 至少配置其中一个;若同时配置,以 `response_example` 为准,`response_schema`
将被忽略。 |
| with_mock_header | boolean | 否 | true | 设置为
`true` 时,将添加响应头 `x-mock-by: APISIX/{version}`。
|
| response_headers | object | 否 | |
要添加到模拟响应中的标头。例如:`{"X-Foo": "bar"}`。
|
:::note
-`response_example` 与 `response_schema` 不能同时配置,且至少需要配置其中一个,否则插件配置将无法通过校验。
+必须配置 `response_example` 或 `response_schema` 其中之一,否则插件配置将无法通过校验;若同时配置,以
`response_example` 为准,`response_schema` 将被忽略。
:::
`response_schema` 支持以下字段类型: