Skip to content

Ensure request body availability after openapi3 filter validation #22

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 3 commits into from

Conversation

ikattey
Copy link

@ikattey ikattey commented Jul 25, 2024

This PR addresses an issue originally reported in the kin-openapi project (getkin/kin-openapi#743), where the request body was not available to handlers after being processed by the openapi3 filter.

This change:

  • makes a copy of the original request body before validation.
  • resets it afterwards using the copy, ensuring it's available for subsequent processing.

Existing tests cover this functionality but don't reproduce the issue. It's also not clear why the issue occurs, as openapi3filter.ValidateRequest() appears to reset the request body.

In any case, this approach makes request handling more robust – regardless of how the openapi3 filter or any future updates to it might handle the body.

@ikattey ikattey requested a review from a team as a code owner July 25, 2024 09:31
@jamietanna
Copy link
Member

Thanks - will try and have a look soon, and then make sure that this is consistent across all middlewares :)

@jamietanna
Copy link
Member

jamietanna commented Apr 7, 2025

Just coming back to review this (sorry for the delay!) and I'm going to see if I can spot anything upstream to see if we can fix it in kin-openapi 🤞 (but if not after ~1 hour, I'll get this merged + consistent across middlewares)

@jamietanna
Copy link
Member

This should be resolved upstream in getkin/kin-openapi#1064

@jamietanna jamietanna marked this pull request as draft April 24, 2025 15:58
@jamietanna jamietanna added this to the v1.2.0 milestone Apr 25, 2025
@jamietanna jamietanna closed this Apr 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants