Skip to content

Conversation

@swlynch99
Copy link
Contributor

This is mostly a copy-paste from the support for schemars v0.8. There are a couple of changes which make the v0.9 support a bit more messy, but otherwise it's not bad. This commit also duplicates the existing tests, which all pass. Once schemars v1.0 gets released it should hopefully require fewer changes to add support again.

The big changes in schemars that cascade out to support here are

  • Schema is now just a very thin wrapper around serde_json::Value. This is rather convenient for defining schemas, less convenient for the transformations we need to make here.
  • Some of the trait methods on the JsonSchema trait have had their definitions change.

It's possible the schemars::transform module could be used to make this cleaner. I haven't looked too deeply into what that would involve.

Fixes #842

This is mostly a copy-paste from the support for schemars v0.8. There
are a couple of changes which make the v0.9 support a bit more messy,
but otherwise it's not bad. This commit also duplicates the existing
tests, which all pass. Once schemars v1.0 gets released it should
hopefully require fewer changes to add support again.

The big changes in schemars that cascade out to support here are
- Schema is now just a very thin wrapper around serde_json::Value. This
  is rather convenient for defining schemas, less convenient for the
  transformations we need to make here.
- Some of the trait methods on the JsonSchema trait have had their
  definitions change.

It's possible the schemars::transform module could be used to make this
cleaner. I haven't looked too deeply into what that would involve.
@swlynch99
Copy link
Contributor Author

CI seems to be failing since schemars v0.9 has a MSRV of 1.74. What's the best way to make this work? I'm guessing this is the first dependency that has a no versions compatible with 1.71

@jonasbb
Copy link
Owner

jonasbb commented Jun 6, 2025

Thank you for preparing this :) Feel free to bump the MSRV to 1.74. Here is an example of such a previous change: 2c6c51b

@swlynch99
Copy link
Contributor Author

I've bumped MSRV to 1.74 and added appropriate release notes.

@codecov
Copy link

codecov bot commented Jun 6, 2025

Codecov Report

Attention: Patch coverage is 79.48718% with 96 lines in your changes missing coverage. Please review.

Project coverage is 67.36%. Comparing base (038d8a6) to head (c9b08af).
Report is 9 commits behind head on master.

Files with missing lines Patch % Lines
serde_with/src/schemars_0_9.rs 79.34% 94 Missing ⚠️
serde_with/src/schemars_0_8.rs 90.90% 1 Missing ⚠️
serde_with_macros/src/lib.rs 50.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #849      +/-   ##
==========================================
+ Coverage   66.70%   67.36%   +0.65%     
==========================================
  Files          34       35       +1     
  Lines        8227     8683     +456     
==========================================
+ Hits         5488     5849     +361     
- Misses       2739     2834      +95     

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@swlynch99
Copy link
Contributor Author

It took a few tries to fix all the clippy warnings (+ one bug that I have added a test case for) but this should now be ready for review.

@jonasbb
Copy link
Owner

jonasbb commented Jun 14, 2025

Thank you for the great PR. This looks mostly like mechanical changes to adapt to the new JsonSchema and removal of SchemaObject by replacing it with the serde_json::Value type.

  • Including String -> Cow<'static, str> transition
  • is_referenceable -> inline_schema transition by negating the default value
  • Lots of json_schema! instead of SchemaObject
  • Feature gating some implementations behind std since schemars v0.9 only requires alloc.

One notes:

  • c14ced8 (#849)
    This seems like a pre-existing issue with the schemars v0.8 implementation. I guess that should be fixed for that too.

@jonasbb jonasbb merged commit 4dd13f2 into jonasbb:master Jun 14, 2025
26 checks passed
jonasbb added a commit that referenced this pull request Jun 14, 2025
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.

Support for schemars 0.9.0 / 1.0.0

2 participants