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

Question about parameter validation: the validation error has been overwritten. #135

Open
FFFFFFatsLan opened this issue Apr 9, 2025 · 1 comment · May be fixed by #138
Open

Question about parameter validation: the validation error has been overwritten. #135

FFFFFFatsLan opened this issue Apr 9, 2025 · 1 comment · May be fixed by #138

Comments

@FFFFFFatsLan
Copy link

FFFFFFatsLan commented Apr 9, 2025

version:github.com/pb33f/libopenapi-validator v0.1.0

When using parameter validation, I encountered an issue where validation errors for earlier string-type fields in the parameters are being overwritten by the results of later field validations.

Upon reviewing the source code, I noticed that in the formatJsonSchemaValidationError method, the validationErrors object is reinitialized each time, which causes the validation errors in ValidateQueryParamsWithPathItem to be overwritten consistently.

I believe this could potentially be a bug.

The code I have questions about is located in the query_parameters.go file at line 121.

case helpers.String:
	validationErrors = v.validateSimpleParam(sch, ef, ef, params[p])

And I think the correct logic is that:

case helpers.String:
	validationErrors = append(validationErrors, v.validateSimpleParam(sch, ef, ef, params[p])...)
Image
@daveshanley
Copy link
Member

PRs are welcome!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants