-
-
Notifications
You must be signed in to change notification settings - Fork 357
Emit #[schemars(crate)]
attribute
#1764
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
Conversation
This fixes errors which occur when the schemars crate is not available at the top level (at (::)schemars). This is the case when users use custom imports via #[kube(crates(schemars))]. The JsonSchema derive macro then wrongly uses the top-level import. Adding this attribute will instruct JsonSchema to use the correct custom import instead. Signed-off-by: Techassi <git@techassi.dev>
Alright, I have noticed that we have to be a little cleverer and conditionally emit the attribute only when the schema mode is |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #1764 +/- ##
=======================================
+ Coverage 0 76.5% +76.5%
=======================================
Files 0 84 +84
Lines 0 7893 +7893
=======================================
+ Hits 0 6032 +6032
- Misses 0 1861 +1861
🚀 New features to boost your workflow:
|
Signed-off-by: Techassi <git@techassi.dev>
Both CI failures seem unrelated to my change... Let me know if there is anything I need to fix. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks all very reasonable to me. Thank you!
Integration test failure (clearly unrelated) seems to have become flaky somehow. The latter* test failure is my own fault for dropping openssl support in muslrust :/ Merging and fixing up CI after. |
#[schemars(crate)]
attribute
Thank you for the quick merge! |
Motivation
The
JsonSchema
derive macro will use an incorrect import ofschemars
which does not match the customized import via#[kube(crates(schemars = ...))]
. In my case, this was undiscovered until now, because previously,schemars
was available at the top-level through a dependency declaration inCargo.toml
.Solution
This PR simply adds the
#[schemars(crate = ...)]
attribute to the generated CRD struct.