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 9 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 93.81443% with 6 lines in your changes missing coverage. Please review.

Project coverage is 99.56%. Comparing base (3d64c93) to head (b06c136).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
parameters/validate_parameter.go 80.00% 4 Missing ⚠️
helpers/schema_compiler.go 95.45% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #116      +/-   ##
==========================================
- Coverage   99.74%   99.56%   -0.19%     
==========================================
  Files          29       30       +1     
  Lines        3163     3203      +40     
==========================================
+ Hits         3155     3189      +34     
- Misses          8       14       +6     
Flag Coverage Δ
unittests 99.56% <93.81%> (-0.19%) ⬇️

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
@daveshanley
Copy link
Member

If you can bump those couple of lines, we can add this!

@JemDay
Copy link
Contributor Author

JemDay commented Feb 6, 2025

If you can bump those couple of lines, we can add this!

Will take a look.

How would I trigger those checks ... they seemed to trigger after the PR got approved

- Added more 'nil' protection
@JemDay
Copy link
Contributor Author

JemDay commented Feb 6, 2025

Let me know how far down this rabbit hole you'd like me to go.

If I'm ready this correctly the coverage failed coverage results from some very small edge-cases around error checks (where in the past there were no checks!) - coercing tests to get the desired coverage is presumably doable but is that a blocker ?

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