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: docs/configuration.md
+13-5Lines changed: 13 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -138,6 +138,11 @@ By default, OpenAPI follows JSON Schema behavior: when an object schema omits `a
138
138
139
139
If you want stricter behavior, enable `strict_additional_properties`. In this mode, omitted `additionalProperties` is treated as `false`.
140
140
141
+
This mode is particularly useful for:
142
+
-**Preventing data leaks**: Ensuring your API doesn't accidentally expose internal or sensitive fields in responses that aren't explicitly documented.
143
+
-**Strict client validation**: Rejecting client requests that contain typos, extraneous data, or unsupported fields, forcing clients to adhere exactly to the defined schema.
144
+
-**Contract tightening**: Enforcing the exact shape of objects across your API boundaries.
145
+
141
146
```python hl_lines="4"
142
147
from openapi_core import Config
143
148
from openapi_core import OpenAPI
@@ -153,24 +158,27 @@ When strict mode is enabled:
153
158
- object schema with omitted `additionalProperties` rejects unknown fields
154
159
- object schema with `additionalProperties: true` still allows unknown fields
155
160
156
-
## Strict Response Properties
161
+
## Response Properties Policy
157
162
158
163
By default, OpenAPI follows JSON Schema behavior for `required`: response object properties are optional unless explicitly listed in `required`.
159
164
160
-
If you want stricter response checks, enable `strict_response_properties`. In this mode, response object schemas are validated as if all documented properties were required, except properties marked as `writeOnly`.
165
+
If you want stricter response checks, change `response_properties_default_policy` to `required`. In this mode, response object schemas are validated as if all documented properties were required (except properties marked as `writeOnly` in OpenAPI 3.0).
166
+
167
+
This mode is intentionally stricter than the OpenAPI default. It is particularly useful for:
168
+
-**Contract completeness checks in tests**: Ensuring that the backend actually returns all the properties documented in the OpenAPI specification.
169
+
-**Detecting API drift**: Catching bugs where a database schema change or serializer update inadvertently drops fields from the response.
170
+
-**Preventing silent failures**: Making sure clients aren't broken by missing data that they expect to be present according to the API documentation.
This mode is intentionally stricter than the OpenAPI default and is useful for contract completeness checks in tests.
173
-
174
182
## Extra Format Validators
175
183
176
184
OpenAPI defines a `format` keyword that hints at how a value should be interpreted. For example, a `string` with the format `date` should conform to the RFC 3339 date format.
0 commit comments