-
Notifications
You must be signed in to change notification settings - Fork 10
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
fix(o2k): request-validator support +json suffix for schemas #175
fix(o2k): request-validator support +json suffix for schemas #175
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #175 +/- ##
==========================================
- Coverage 67.79% 67.76% -0.04%
==========================================
Files 23 23
Lines 2481 2491 +10
==========================================
+ Hits 1682 1688 +6
- Misses 641 643 +2
- Partials 158 160 +2 ☔ View full report in Codecov by Sentry. |
openapi2kong/validator.go
Outdated
if strings.Contains(strings.ToLower(contentType), "application/json") { | ||
typ, subtype, err := parseMediaType(contentType) | ||
if err != nil { | ||
panic(err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do not panic here, this is a library and it shouldn't bail out but return the error.
Imho 2 options:
- use
logbasics
and log a message atInfo
level that the mediatype found is invalid and will be ignored - bubble up the error to the caller.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fyi in the entire library, only the Must...
methods/functions will ever panic. everything else will return an error.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This sounds good to me. I print an Info log when the mediatype failed to be parsed
#174