You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: articles/api-management/validation-policies.md
+6-5Lines changed: 6 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,7 +6,7 @@ documentationcenter: ''
6
6
author: dlepow
7
7
ms.service: api-management
8
8
ms.topic: reference
9
-
ms.date: 06/07/2022
9
+
ms.date: 09/09/2022
10
10
ms.author: danlep
11
11
---
12
12
@@ -79,7 +79,7 @@ The following table shows the schema formats and request or response content typ
79
79
The policy validates the following content in the request or response against the schema:
80
80
81
81
* Presence of all required properties.
82
-
*Absence of additional properties, if the schema has the `additionalProperties` field set to `false`.
82
+
*Presence or absence of additional properties, if the schema has the `additionalProperties` field set. May be overriden with the `allow-additional-properties` attribute.
83
83
* Types of all properties. For example, if a schema specifies a property as an integer, the request (or response) must include an integer and not another type, such as a string.
84
84
* The format of the properties, if specified in the schema - for example, regex (if the `pattern` keyword is specified), `minimum` for integers, and so on.
85
85
@@ -93,22 +93,22 @@ The policy validates the following content in the request or response against th
93
93
<content-type-mapany-content-type-value="content type string"missing-content-type-value="content type string">
94
94
<type from|when="content type string"to="content type string" />
95
95
</content-type-map>
96
-
<contenttype="content type string" validate-as="json|xml|soap"schema-id="schema id"schema-ref="#/local/reference/path"action="ignore|prevent|detect" />
96
+
<contenttype="content type string" validate-as="json|xml|soap"schema-id="schema id"schema-ref="#/local/reference/path"action="ignore|prevent|detect"allow-additional-properties="true|false"/>
97
97
</validate-content>
98
98
```
99
99
100
100
### Examples
101
101
102
102
#### JSON schema validation
103
103
104
-
In the following example, API Management interprets requests with an empty content type header or requests with a content type header `application/hal+json` as requests with the content type `application/json`. Then, API Management performs the validation in the detection mode against a schema defined for the `application/json` content type in the API definition. Messages with payloads larger than 100 KB are blocked.
104
+
In the following example, API Management interprets requests with an empty content type header or requests with a content type header `application/hal+json` as requests with the content type `application/json`. Then, API Management performs the validation in the detection mode against a schema defined for the `application/json` content type in the API definition. Messages with payloads larger than 100 KB are blocked. Requests containing additional properties are blocked, even if the schema's `additionalProperties` field is configured to allow additional properties.
@@ -147,6 +147,7 @@ In the following example, API Management interprets any request as a request wit
147
147
| schema-id | Name of an existing schema that was [added](#schemas-for-content-validation) to the API Management instance for content validation. If not specified, the default schema from the API definition is used. | No | N/A |
148
148
| schema-ref| For a JSON schema specified in `schema-id`, optional reference to a valid local reference path in the JSON document. Example: `#/components/schemas/address`. The attribute should return a JSON object that API Management handles as a valid JSON schema.<br/><br/> For an XML schema, `schema-ref` isn't supported, and any top-level schema element can be used as the root of the XML request or response payload. The validation checks that all elements starting from the XML request or response payload root adhere to the provided XML schema. | No | N/A |
149
149
| action |[Action](#actions) to perform for requests or responses whose body doesn't match the specified content type. | Yes | N/A |
150
+
| allow-additional-properties | Boolean. For a JSON schema, specifies whether to implement a runtime override of the `additionalProperties` value configured in the schema: <br> - `true`: allow additional properties in the request or response body, even if the JSON schema's `additionalProperties` field is configured to not allow additional properties. <br> - `false`: do not allow additional properties in the request or response body, even if the JSON schema's `additionalProperties` field is configured to allow additional properties.<br/><br/>If the attribute isn't specified, the policy validates additional properties according to configuration of the `additionalProperties` field in the schema. | No | N/A |
0 commit comments