You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@apisix.apache.org by GitBox <gi...@apache.org> on 2022/08/22 07:05:31 UTC

[GitHub] [apisix] hf400159 commented on a diff in pull request #7752: docs(plugin): refactor request-validation.md

hf400159 commented on code in PR #7752:
URL: https://github.com/apache/apisix/pull/7752#discussion_r951078805


##########
docs/zh/latest/plugins/request-validation.md:
##########
@@ -23,27 +28,30 @@ title: request-validation
 
 ## 描述
 
-`request-validation` 插件用于提前验证请求向上游转发请求,可以验证请求的 `body` 及 `header` 数据。
-
-该插件使用 `Json Schema` 进行数据验证,有关 `Json Schema` 的更多信息,请参阅 [JSON schema](https://github.com/api7/jsonschema)。
+`request-validation` 插件用于提前验证向上游服务转发的请求。该插件使用 [JSON Schema](https://github.com/api7/jsonschema) 机制进行数据验证,可以验证请求的 `body` 及 `header` 数据。
 
 ## 属性
 
-> 注意,`header_schema` 与 `body_schema` 至少填写其中一个
-
-| Name             | Type   | Requirement | Default | Valid | Description                       |
+| 名称             | 类型   | 必选项 | 默认值 | 有效值 | 描述                       |
 | ---------------- | ------ | ----------- | ------- | ----- | --------------------------------- |
-| header_schema    | object | 可选        |         |       | `header` 数据的 `schema` 数据结构 |
-| body_schema      | object | 可选        |         |       | `body` 数据的 `schema` 数据结构   |
-| rejected_code | integer | 可选        |   400      |    [200,...,599]   | 自定义拒绝状态码 |
-| rejected_msg | string | 可选        |         |       | 自定义拒绝信息 |
+| header_schema    | object | 否        |         |       | `header` 数据的 `schema` 数据结构。 |
+| body_schema      | object | 否        |         |       | `body` 数据的 `schema` 数据结构。   |
+| rejected_code | integer | 否        | 400      | [200,...,599]   | 当请求被拒绝时要返回的状态码。 |
+| rejected_msg | string | 否        |         |       | 当请求被拒绝时返回的信息。 |
+
+:::note 注意
+
+需保证 `header_schema` 与 `body_schema` 配置项中,至少填写其中一个。

Review Comment:
   ```suggestion
   启用该插件时,至少需要配置 `header_schema` 和 `body_schema` 属性中的任意一个,两者也可以同时使用。
   ```



##########
docs/zh/latest/plugins/request-validation.md:
##########
@@ -68,39 +76,9 @@ curl http://127.0.0.1:9080/apisix/admin/routes/5 -H 'X-API-KEY: edd1c9f034335f13
 }'
 ```
 
-## 测试插件
-
-```shell
-curl --header "Content-Type: application/json" \
-  --request POST \
-  --data '{"boolean-payload":true,"required_payload":"hello"}' \
-  http://127.0.0.1:9080/get
-```
-
-如果 `Schema` 验证失败,将返回 `400` 状态码与相应的拒绝信息。
-
-## 禁用插件
-
-在路由 `plugins` 配置块中删除 `request-validation` 配置,即可禁用该插件。
-
-```shell
-curl http://127.0.0.1:9080/apisix/admin/routes/5 -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -X PUT -d '
-{
-    "uri": "/get",
-    "plugins": {
-    },
-    "upstream": {
-        "type": "roundrobin",
-        "nodes": {
-            "127.0.0.1:8080": 1
-        }
-    }
-}'
-```
-
-## 示例
+以下示例展示了不同的验证场景下的 `request-validation` 插件 JSON 配置:

Review Comment:
   ```suggestion
   以下示例展示了不同验证场景下该插件的 JSON 配置:
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org