JSON Validator
Use the JSON Validator policy to validate a request against a JSON schema. You can specify limits on various JSON structures, such as arrays and strings. This capability minimizes the risk posed by content-level attacks. The policy gets applied and is executed only if the Content-Type of the request or response header is set to application/json
.
Policy Execution Order
This JSON Validator policy executes after the request has been authenticated.
Â
Expression Enabled Fields in API Policies
All expression enabled fields take expressions from the SnapLogic Expression Language and the API Policy Manager functions.
Parameter Name | Description | Default Value | Example |
---|---|---|---|
Label | Required. The name for the API policy. | JSON Validator | Task JSON Validator |
When this policy should be applied | An expression enabled field that determines the condition to be fulfilled for the API policy to execute. For example, if the value in this field is request.method == "POST", the API policy is executed only if the request method is a POST. | True | request.method == "POST" |
Edit JSON | Launches the JSON editor which allows you to define JSON. The editor loads an existing JSON document if defined previously. The editor lets you save JSON in SnapLogic's file system or import existing JSON documents from it. | Empty JSON file | {
"$schema": "http://json-schema.org/draft-06/schema#",
"type": "object",
"properties": {
"foo": {
"type": "integer"
},
"bar": {
"type": "string"
}
}
} |
Hide/Render WhiteSpace: Formats JSON with watermarked dots or plain white space between the characters. | Â | Â | |
Format Code: Formats text in JSON | Â | Â | |
Status | Indicates whether the API policy is enabled or disabled. | Enabled | Disabled |
Troubleshooting Policy Violations
The JSON Validator policy now returns the actual policy violation error to the API caller. Each error type is parameterized and added to the response in the "SL_Policy_Error"
header.
The following image provides an example of a policy violation error.
First, a required field (productID
) is missing a value. Secondly, the value for the price
field is invalid.
Have feedback? Email documentation@snaplogic.com | Ask a question in the SnapLogic Community
© 2017-2024 SnapLogic, Inc.