Function Description
The request-validation
plugin is used to validate requests forwarded to upstream services in advance. This plugin utilizes the JSON Schema
mechanism for data validation, capable of validating both the body and header data of requests.
Execution Attributes
Plugin Execution Phase: Authentication Phase
Plugin Execution Priority: 220
Configuration Fields
Name | Data Type | Requirements | Default Value | Description |
---|---|---|---|---|
header_schema | object | Optional | - | Configuration for JSON Schema to validate request headers |
body_schema | object | Optional | - | Configuration for JSON Schema to validate request body |
rejected_code | number | Optional | 403 | HTTP status code returned when the request is rejected |
rejected_msg | string | Optional | - | HTTP response body returned when the request is rejected |
enable_swagger | bool | Optional | false | Configuration to enable Swagger documentation validation |
enable_oas3 | bool | Optional | false | Configuration to enable OAS3 documentation validation |
Validation rules for header and body are the same, below is an example using body.