Skip to content
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

Merged

Conversation

vm-001
Copy link
Contributor

@vm-001 vm-001 commented May 22, 2024

@codecov-commenter
Copy link

codecov-commenter commented May 22, 2024

Codecov Report

Attention: Patch coverage is 54.54545% with 5 lines in your changes are missing coverage. Please review.

Project coverage is 67.76%. Comparing base (8ffe079) to head (adda33f).
Report is 2 commits behind head on main.

Files Patch % Lines
openapi2kong/validator.go 54.54% 3 Missing and 2 partials ⚠️
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.
📢 Have feedback on the report? Share it here.

if strings.Contains(strings.ToLower(contentType), "application/json") {
typ, subtype, err := parseMediaType(contentType)
if err != nil {
panic(err)
Copy link
Member

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:

  1. use logbasics and log a message at Info level that the mediatype found is invalid and will be ignored
  2. bubble up the error to the caller.

Copy link
Member

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.

Copy link
Contributor Author

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

@Tieske Tieske changed the title fix: request-validator plugin cannot be created when using +json suffix fix(o2k): request-validator support +json suffix for schemas May 23, 2024
@Tieske Tieske merged commit f85e616 into Kong:main May 23, 2024
3 checks passed
@vm-001 vm-001 deleted the fix/request-validator-structured-syntax-suffix branch May 27, 2024 02:51
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.

3 participants