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

Implement JsonSchemaAs for PickFirst #721

Merged
merged 2 commits into from
Apr 7, 2024

Conversation

swlynch99
Copy link
Contributor

This is the second-to-last type that I've got an implementation queued up for. The only one left after this is Seq.

This one is pretty straightforward: we put the involved schemas in an anyOf subschema. All the schemas except the first are annotated with writeOnly: true to indicate that they are only accepted when deserializing and not emitted when serializing. The one extra detail is that I've used an internal allOf in each element so that setting writeOnly: true works even if the schema of the type is a reference to an external schema.

I have also included tests and a snapshot test to show that everything works.

Copy link

codecov bot commented Apr 7, 2024

Codecov Report

Attention: Patch coverage is 92.00000% with 2 lines in your changes are missing coverage. Please review.

Project coverage is 66.49%. Comparing base (5e36083) to head (f4145e3).
Report is 11 commits behind head on master.

Files Patch % Lines
serde_with/src/schemars_0_8.rs 92.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #721      +/-   ##
==========================================
+ Coverage   66.21%   66.49%   +0.27%     
==========================================
  Files          38       38              
  Lines        2445     2468      +23     
==========================================
+ Hits         1619     1641      +22     
- Misses        826      827       +1     

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

@jonasbb jonasbb merged commit 9e15ac3 into jonasbb:master Apr 7, 2024
22 checks passed
@jonasbb
Copy link
Owner

jonasbb commented Apr 7, 2024

Thanks, the implementation looks good :) Like all your PRs

@swlynch99 swlynch99 deleted the schemars-pickfirst branch April 8, 2024 12:52
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