-
-
Notifications
You must be signed in to change notification settings - Fork 73
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 all forwarding schemars JsonSchema impls #676
Conversation
As it turns out the default schema for BTreeSet sets uniqueItems: true. This is fine for SetPreventDuplicates but is wrong for SetLastValueWins. To address this I've added a custom implementation for SetLastValueWins.
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## master #676 +/- ##
==========================================
- Coverage 65.26% 65.24% -0.02%
==========================================
Files 38 38
Lines 2240 2256 +16
==========================================
+ Hits 1462 1472 +10
- Misses 778 784 +6 ☔ View full report in Codecov by Sentry. |
I think the implementation of |
I'm curious, what is your plan with the support here? Do you want to extend the |
My plan was to at the very least submit everything in https://github.com/swlynch99/serde_with/tree/schemars-full. That includes a Having a new release with that includes this PR would be nice since most of the parts I need are included in this one. That being said, I will be continuing to submit the rest of the code in that branch one bit at a time.
My main use case in using jsonschema is for generating OpenAPI specifications in which case I do agree that this doesn't really make sense to do for |
Ok, that sounds good. I will prepare a release with the code including #679. |
Following up where #666 left off, this adds all the
JsonSchema
impls forserde_with
adapters whose implementation can be just aforward_schema!(...)
. I have also included test cases covering most of the new impls. These are mainly snapshot tests since those are the easiest to write but where appropriate I've included more detailed tests.Detailed Changes
JsonSchema
forBorrowCow
,Bytes
,DefaultOnError
,DefaultOnNull
,FromInto
,FromIntoRef
,TryFromInto
,TryFromIntoRef
,Map
,MapFirstKeyWins
,MapPreventDuplicates
,SetLastValueWins
,SetPreventDuplicates
,StringWithSeparator
, andVecSkipError
.The only non-forwarded implementation is
SetLastValueWins
. It was originally forwarded but after looking at the snapshot I realized that wasn't quite right.Open Questions
DefaultOnError
can technically take any json value as input. I haven't done this so far but you could represent this asVecSkipOnError
.