refactor: replace Option wrappers with serde(default) attribute#382
Conversation
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## main #382 +/- ##
==========================================
- Coverage 82.44% 82.35% -0.09%
==========================================
Files 46 46
Lines 4142 4104 -38
==========================================
- Hits 3415 3380 -35
+ Misses 727 724 -3
☔ View full report in Codecov by Sentry. |
|
I've tried to replace as much properties as possible but changing some fields (like in Http) breaks tests as now deserialization of config to sdl outputs more types that were initially provided. That requires either changing tests itself or how identity is compared |
|
Identity tests are required because there are use cases where we generate a new config using open API or Adobe other format. Some times we want to merge two config into one. I don't think we should change it. |
Could you please point out to some examples or documentation about this to better understand current usage? Identity tests should stay I agree, but to be able to replace Option to default we could:
|
|
Think about
I hope this makes sense. Let me know if it doesn't, happy to talk more about the architecture and the reason behind it. Feel free to connect with us on [discord] if you prefer a more real time collaboration :) |
|
The identity tests, guarantee that we always generate the most minimal and compact configuration that's possible. This is one of the reasons why we started with the |
It's not |
In case we want to generate as minimal configuration as possible from Config I have a suggestion to use serde's skip_serializing. In that case fields with that attribute won't appear in the output if they have a default value. Please, look at my latest commit that shows the example of usage. One possible side effect of this is that some input settings could disappear from the output if they are equal to the default value |
|
I think this is going in the right right direction. We have a few pending |
c420727 to
1fab23d
Compare
Updated other fields that has clear defaults. Please, note the comment why some |
1fab23d to
6396689
Compare
|
/tip $50 @meskill |
|
🎉🎈 @meskill has been awarded $50! 🎈🎊 |
Summary:
Instead of
Option<bool>etc use#[serde(default)]to mark fields as optional with some default value.These changes simplifies the code and prevents possible bugs when utilizing Option
Issue Reference(s):
Fixes #371
/claim #371
Build & Testing:
cargo testsuccessfully../lint.shto address and fix linting issues.Checklist: