Skip to content

Implement x-www-form-urlencoded validation#237

Open
ySnoopyDogy wants to merge 6 commits intopb33f:mainfrom
ySnoopyDogy:feat/urlencoded_validation
Open

Implement x-www-form-urlencoded validation#237
ySnoopyDogy wants to merge 6 commits intopb33f:mainfrom
ySnoopyDogy:feat/urlencoded_validation

Conversation

@ySnoopyDogy
Copy link
Contributor

This PR was made on top of #214, and closes #180.

The same idea from the XML validation was used for URLEncoded. We convert the data into a JSON structure matching the types from the Schema, so we can validate the JSON structure against the OpenAPI schema.

Created a new interface URLEncodedValidator with two functions for validating url encoded: ValidateURLEncodedString and ValidateURLEncodedStringWithVersion.

Added a new option to ValidationOptions: AllowURLEncodedBodyValidation to enable URL Encoded validations in request/response bodies (the default is false). Created a function WithURLEncodedBodyValidation to enable the new validator option.

No breaking changes with the new code, as the updated function was internal, and the URL Encoded body validation setting is false by default.

@codecov
Copy link

codecov bot commented Feb 12, 2026

Codecov Report

❌ Patch coverage is 99.48097% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 97.79%. Comparing base (0db7586) to head (723b2f9).
⚠️ Report is 8 commits behind head on main.

Files with missing lines Patch % Lines
schema_validation/validate_xml.go 98.65% 2 Missing ⚠️
responses/validate_body.go 97.14% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #237      +/-   ##
==========================================
+ Coverage   97.61%   97.79%   +0.18%     
==========================================
  Files          56       60       +4     
  Lines        5240     5769     +529     
==========================================
+ Hits         5115     5642     +527     
- Misses        125      127       +2     
Flag Coverage Δ
unittests 97.79% <99.48%> (+0.18%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@daveshanley
Copy link
Member

I need to add this to the docs, but I generally will hold all PRs that don't have full coverage, unless there is a solid reason. In this case, your code is solid! But some error paths have been uncovered. I know they are a pain to cover.

The problem is that every slight drop in coverage compounds with every submission. I am responsible for this code once it's merged, and I strongly believe in high coverage in core libraries.

Sorry to be pedantic, I hope you understand.

in this PR there are a few error cases uncovered, a few invalid object or nil tests would bump it up and we can all be happy!

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.

Support application/x-www-form-urlencoded payloads

2 participants