Repository navigation
fix (#49): restore body on clone - #61
Merged
Merged
Conversation
Bring the branch up to date with kin-openapi v0.152.0 and echo v4.16.0. Co-Authored-By: Claude Fable 5.1 <[email protected]>
Validating a req.Clone() meant openapi3filter put the re-readable body, the KeepValidatedValue wrapper and any defaults-rewritten ContentLength back on the clone only. Copying Body/GetBody back still missed ContentLength, and only URL.Path was trimmed, so percent-encoded path parameters under a prefix mis-routed. Follow the approach of oapi-codegen/echo-v5-middleware#17 by blacksud0 so both repos share one fix: trim URL.Path and URL.RawPath on the live request and restore them in a defer that runs before the next handler. Everything kin writes to the body now lands on the request the handler sees. An AuthenticationFunc reading GetEchoContext(ctx).Request().URL.Path now sees the trimmed path during validation. Keep the POST case added to TestOapiRequestValidatorWithPrefix and add tests for the issue oapi-codegen#49 security + AuthenticationFunc + body scenario (exact body, ContentLength, original path), a defaults-rewritten body, KeepValidatedValue, and a percent-encoded path parameter under a prefix. Closes oapi-codegen#49 Co-Authored-By: Claude Fable 5.1 <[email protected]>
Member
|
Thanks for the fix and the test, @karlpip. A maintainer has pushed two commits on top of your branch: a merge of main (kin-openapi v0.152.0, echo v4.16.0) and a change of approach to match oapi-codegen/echo-v5-middleware#17, trimming the prefix in place on the live request instead of validating a clone. That also carries over ContentLength and the new kin-openapi KeepValidatedValue wrapper, and fixes RawPath for percent-encoded path params under a prefix. Your POST test is kept, with more tests added alongside it. |
mromaszewicz
approved these changes
Oct 23, 2026
mromaszewicz
enabled auto-merge (squash)
October 23, 2026 01:13
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
fixes: #49