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

Enable 'Format' and 'Content' assertions during schema validation #116

Open
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

JemDay
Copy link
Contributor

@JemDay JemDay commented Jan 3, 2025

Introduced more validation configuration options to apply during schema validation.

These changes have only currently been made to the query-parameter validation as a proof-of-concept, if this looks like an appropriate approach I will apply it more broadly - as such please don't merge at this time.

Included are some additional unit tests for query parameters to demonstrate the enforcement of 'date' and 'date-time' forma ts.

Copy link

codecov bot commented Jan 3, 2025

Codecov Report

Attention: Patch coverage is 95.23810% with 4 lines in your changes missing coverage. Please review.

Project coverage is 99.62%. Comparing base (3d64c93) to head (4b65d02).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
helpers/schema_compiler.go 95.55% 2 Missing ⚠️
parameters/validate_parameter.go 66.66% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #116      +/-   ##
==========================================
- Coverage   99.74%   99.62%   -0.13%     
==========================================
  Files          29       30       +1     
  Lines        3163     3194      +31     
==========================================
+ Hits         3155     3182      +27     
- Misses          8       12       +4     
Flag Coverage Δ
unittests 99.62% <95.23%> (-0.13%) ⬇️

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.

JemDay added 3 commits January 6, 2025 10:03
- Updated to cover all situations where JSON schema compilation occurs.
- A few new Unts tests to improve coverage.
config/config.go Outdated
Comment on lines 27 to 30
// Sanity
if opt != nil {
opt(o)
}

Choose a reason for hiding this comment

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

Maybe this

Suggested change
// Sanity
if opt != nil {
opt(o)
}
if opt == nil {
// Sanity
continue
}
opt(o)

The sanity is in the nil check. The comment is misleading otherwise

Copy link
Contributor Author

Choose a reason for hiding this comment

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

opted (no pun intended) to remove the comment but leave the logic as-is ... seemed more logical to me.

helpers/schema_compiler.go Outdated Show resolved Hide resolved
helpers/schema_compiler_test.go Outdated Show resolved Hide resolved
helpers/schema_compiler_test.go Outdated Show resolved Hide resolved
helpers/schema_compiler_test.go Outdated Show resolved Hide resolved
parameters/query_parameters_test.go Outdated Show resolved Hide resolved
parameters/query_parameters_test.go Outdated Show resolved Hide resolved
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