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: pass validator config options when validating OpenAPI doc #132

Merged

Conversation

reversearrow
Copy link
Contributor

@reversearrow reversearrow commented Apr 1, 2025

Currently, when initializing validator.NewValidator with a custom regex engine, that engine is not passed down to the ValidateDocument() function.

For example:

validator, errs := validator.NewValidator(doc, config.WithRegexEngine(customRegexEngine))
if len(errs) > 0 {
	log.Fatal(errs)
	return 
}
docValid, valErrors := validator.ValidateDocument()
if len(valErrors) > 0 {
	log.Fatal(valErrors)
	return
}

In this case, although config.WithRegexEngine(customRegexEngine) is provided during initialization, it is not used during validation, because ValidateDocument() does not forward the option.

This PR resolves the issue by ensuring v.options.RegexEngine is passed into ValidateOpenAPIDocument using the config.WithRegexEngine option. This ensures that any custom regex engine specified during initialization is correctly applied when validating OpenAPI documents.

@reversearrow
Copy link
Contributor Author

@daveshanley Can you provide some feedback on this PR?

@reversearrow reversearrow changed the title fix: pass config validator options when validation openapi document fix: pass validator config options when validating OpenAPI document Apr 1, 2025
@reversearrow reversearrow changed the title fix: pass validator config options when validating OpenAPI document fix: pass validator config options when validating OpenAPI doc Apr 1, 2025
Copy link
Member

@daveshanley daveshanley left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is good, thank you for finding this gap!

Copy link

codecov bot commented Apr 8, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Please upload report for BASE (main@9a731fd). Learn more about missing BASE report.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #132   +/-   ##
=======================================
  Coverage        ?   99.74%           
=======================================
  Files           ?       29           
  Lines           ?     3167           
  Branches        ?        0           
=======================================
  Hits            ?     3159           
  Misses          ?        8           
  Partials        ?        0           
Flag Coverage Δ
unittests 99.74% <100.00%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@daveshanley
Copy link
Member

LGTM, resolve the conflict with the go.mod (I just merged in some dependabot PRs). Thank you for your contribution!

@reversearrow reversearrow force-pushed the fix/pass-regex-validation-options branch from df7e605 to 510d30d Compare April 8, 2025 21:26
@reversearrow
Copy link
Contributor Author

reversearrow commented Apr 8, 2025

@daveshanley updated. Thank you!

@daveshanley daveshanley merged commit 224827e into pb33f:main Apr 8, 2025
@reversearrow reversearrow deleted the fix/pass-regex-validation-options branch April 8, 2025 21:30
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.

2 participants