Skip to content

Inconsistent Parameter Validation Behavior in libopenapi-validator v0.4.0 #140

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

Open
wsqyouth opened this issue Apr 17, 2025 · 1 comment

Comments

@wsqyouth
Copy link

Description:

I've encountered an inconsistency in parameter validation when using libopenapi-validator version v0.4.0. Specifically, there are differences in how validation errors are reported for different types of illegal parameter scenarios:

  • Enum Value Mismatch:
    When providing parameter values that do not match the expected enum values, the validation error response is generated, but the ValidationError.SchemaValidationErrors field is empty.
    Image

  • Exceeding Maximum Range:
    Conversely, when a parameter exceeds its maximum allowable value, the validation error response includes details within the ValidationError.SchemaValidationErrors field.
    Image

Upon reviewing the source code, I noticed that within the validateSimpleParam method, there is preliminary validation only for illegal values, whereas other validation types utilize the ValidateSingleParameterSchema function. This discrepancy results in the ValidationError.SchemaValidationErrors field not being populated consistently.
github.com/pb33f/[email protected]/parameters/query_parameters.go:232
Image

Suggestion:

I believe that this inconsistent behavior can make it challenging for users to handle validation errors uniformly.
It would be beneficial to use ValidateSingleParameterSchema for all types of parameter validations, ensuring that the response behavior is consistent across different scenarios.

Your feedback and thoughts on this matter would be greatly appreciated.

@its-hammer-time
Copy link

its-hammer-time commented May 2, 2025

#130

Likely related to my issue above. Noticed that the max limit of a query param was being ignored.

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

No branches or pull requests

2 participants