Repository navigation
This release enables openapi3filter.Options.KeepValidatedValue by default. It was meant to ship in v1.2.0 together with the kin-openapi v0.152.0 update, but was merged after that release was published.
With it on, the validator leaves the request body readable exactly as before and additionally keeps the decoded, validated JSON value on the body, reachable through its ValidatedValue() any method. Upcoming oapi-codegen strict server templates use this to bind the value that was actually validated instead of decoding the body a second time, which closes the gap described in oapi-codegen/oapi-codegen#2605 (encoding/json matches member names case-insensitively, so a second decode can pick up a member the validator never saw).
Handlers that read the body see no difference. The only costs are that the decoded value stays in memory for the lifetime of the request, and that the body no longer implements optional interfaces such as io.WriterTo.
To opt out, set DiscardValidatedValue: true in this middleware's Options. This setting overrides KeepValidatedValue in the embedded openapi3filter.Options. Middleware that replaces the request body must run before the validator, otherwise the validated value is lost.
🚀 New features and improvements
- Keep the validated request body value by default (#68) @mromaszewicz
Sponsors
We would like to thank our sponsors for their support during this release.
New contributors
- No new contributors