Skip to content

Commit 4c5ebc1

Browse files
authored
Fix changelog breaking changes notice (#961)
The breaking change included in entry (2024-08-31) was not added correctly. Fix it.
1 parent acbdcbe commit 4c5ebc1

File tree

1 file changed

+19
-10
lines changed

1 file changed

+19
-10
lines changed

CHANGE_HISTORY.md

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,25 @@
77

88
### breaking change
99

10-
* by defaulting to `true` when not defined by the user.
11-
12-
Add tests:
13-
1. Make sure `AjvOptions` sets the value appropriately based on whether
14-
the end user defined `allErrors` or not.
15-
2. When validating requests, make sure the number of errors reported
16-
(when multiple occur) is 1 when `allErrors` is `false`.
17-
18-
The `allErrors` configuration for OpenAPISchemaValidator is not changed
19-
by this commit since that validation is for trusted content.
10+
By default, request and response validation now stops after the first failure. Only one error will be reported even when multiple may exist. This follows best practices from AJV:
11+
- [Security risks of trusted schemas](https://ajv.js.org/security.html#security-risks-of-trusted-schemas)
12+
- [`allErrors` option](https://ajv.js.org/options.html#allerrors)
13+
14+
To report all validation errors (only recommended in development), option `allErrors` can be set in options `validateRequests` and/or `validateResponses`. For example:
15+
16+
```ts
17+
app.use(
18+
OpenApiValidator.middleware({
19+
apiSpec: 'path/to/openapi.json',
20+
validateRequests: {
21+
allErrors: true,
22+
},
23+
validateResponses: {
24+
allErrors: true,
25+
},
26+
})
27+
);
28+
```
2029

2130

2231
## (2024-08-24)

0 commit comments

Comments
 (0)