Skip to content

fix(validation): match content-type with MIME parameters#426

Merged
fredbi merged 1 commit intogo-openapi:masterfrom
fredbi:fix/136-mime-param
May 4, 2026
Merged

fix(validation): match content-type with MIME parameters#426
fredbi merged 1 commit intogo-openapi:masterfrom
fredbi:fix/136-mime-param

Conversation

@fredbi
Copy link
Copy Markdown
Member

@fredbi fredbi commented May 4, 2026

consumes entries that carry MIME parameters (e.g. text/plain;charset=utf-8) were rejecting all client content types because validation compared the bare parsed media type against the raw allowed string. Parse both sides and accept when the bare types match and every client parameter is present on the allowed entry with the same value (allowed entry may carry extra parameters; an entry without parameters accepts any).

Fixes #136

Change type

Please select: 🆕 New feature or enhancement|🔧 Bug fix'|📃 Documentation update

Short description

Fixes

Full description

Checklist

  • I have signed all my commits with my name and email (see DCO. This does not require a PGP-signed commit
  • I have rebased and squashed my work, so only one commit remains
  • I have added tests to cover my changes.
  • I have properly enriched go doc comments in code.
  • I have properly documented any breaking change.

`consumes` entries that carry MIME parameters (e.g. `text/plain;charset=utf-8`)
were rejecting all client content types because validation compared the bare
parsed media type against the raw allowed string. Parse both sides and accept
when the bare types match and every client parameter is present on the allowed
entry with the same value (allowed entry may carry extra parameters; an entry
without parameters accepts any).

Fixes go-openapi#136

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Signed-off-by: Frédéric BIDON <fredbi@yahoo.com>
@codecov
Copy link
Copy Markdown

codecov Bot commented May 4, 2026

Codecov Report

❌ Patch coverage is 91.66667% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 81.71%. Comparing base (dd5f9c7) to head (3215b9f).
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
middleware/validation.go 91.66% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #426      +/-   ##
==========================================
+ Coverage   81.69%   81.71%   +0.02%     
==========================================
  Files          50       50              
  Lines        3381     3397      +16     
==========================================
+ Hits         2762     2776      +14     
- Misses        507      508       +1     
- Partials      112      113       +1     

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

@fredbi fredbi merged commit c69b34d into go-openapi:master May 4, 2026
21 checks passed
@fredbi fredbi deleted the fix/136-mime-param branch May 4, 2026 20:31
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.

consumes with mime type parameters blocks all content types

1 participant