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

Add JsonSchema impls for BytesOrString and BoolFromInt #683

Merged
merged 7 commits into from
Jan 23, 2024

Conversation

swlynch99
Copy link
Contributor

This PR continues where #679 left off. Since the impls get more complicated as we go on I will be chunking them up into smaller PRs so that reviewing them stays manageable. I also don't plan on doing more than 1 or maybe 2 PRs concurrently. I just considered #682 important enough that it should jump the queue.

Details

  • JsonSchemaFor impls for both BytesOrString and BoolFromInt
  • Tests for both of the above

Notes

  • BytesOrString's schema is represented as an enum that can be either a string or an array of bytes. The one difference is that the string representation is marked as "writeOnly" as it is never emitted.
  • I originally also did something similar for BoolFromInt<Flexible> but I didn't think that this was useful compared to the extra confusion when reading the schema. I have changed it so it's schema is just that of an integer.

The additional constraints don't really give that much when compared
with loss of clarity as to what this actually serializes to.
Copy link

codecov bot commented Jan 22, 2024

Codecov Report

Attention: 6 lines in your changes are missing coverage. Please review.

Comparison is base (88e9879) 65.16% compared to head (cc9a723) 65.19%.

Files Patch % Lines
serde_with/src/schemars_0_8.rs 68.42% 6 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #683      +/-   ##
==========================================
+ Coverage   65.16%   65.19%   +0.02%     
==========================================
  Files          38       38              
  Lines        2268     2287      +19     
==========================================
+ Hits         1478     1491      +13     
- Misses        790      796       +6     

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

serde_with/src/schemars_0_8.rs Show resolved Hide resolved
serde_with/src/schemars_0_8.rs Show resolved Hide resolved
@jonasbb jonasbb merged commit 1bdbe72 into jonasbb:master Jan 23, 2024
22 checks passed
@swlynch99 swlynch99 deleted the schemars-2 branch January 23, 2024 20:58
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