datamodel-code-generator
datamodel-code-generator copied to clipboard
Extend parsing of Scientific Notation to JSON capabilites
Solves Issues https://github.com/koxudaxi/datamodel-code-generator/issues/1955#issue-2290971596 and https://github.com/koxudaxi/datamodel-code-generator/issues/1952#issue-2287818185
It boils down to yaml vs. json floating point parsing. The SafeLoader of yaml has to be extended to allow for the same range of float notations like json.
See here for more background.
I copied the SO-solution and it does work (for me)
Codecov Report
All modified and coverable lines are covered by tests :white_check_mark:
Project coverage is 100.00%. Comparing base (
8eccc15) to head (0120a77). Report is 21 commits behind head on main.
Additional details and impacted files
@@ Coverage Diff @@
## main #1956 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 38 38
Lines 4285 4287 +2
Branches 987 987
=========================================
+ Hits 4285 4287 +2
| Flag | Coverage Δ | |
|---|---|---|
| unittests | 99.67% <100.00%> (+<0.01%) |
:arrow_up: |
Flags with carried forward coverage won't be shown. Click here to find out more.
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
CodSpeed Performance Report
Merging #1956 will not alter performance
Comparing maximilian-tech:Fix_parsing_scientific_notation (0120a77) with main (8eccc15)
Summary
✅ 30 untouched benchmarks
@maximilian-tech I'm sorry for my late reply. Thank you for creating the PR. The PR looks good. But Can we add your changes as a CLI option? Because I avoid to change the default behavior for existing users.
Hi,
I like your consideration towards older users by not breaking the current behavior.
However, I am not sure how such a flag should be called:
--parse-json-as-json or --extend-yaml-scientifc-notation?
I really think, that this is a bug, as only now JSON is parsed correctly, and should be the new default behavior.
However, I would be happy either way :)
Thanks for this nice tool!
Thank you for agreeing with our opinion.
I prefer --extend-yaml-scientifc-notation.
Of course, the cli help should explain it a bit more.
I really think, that this is a bug, as only now JSON is parsed correctly, and should be the new default behavior.
I agree that this is the case in most cases, but the problem is that being right often gets someone in trouble 😅 It would be appropriate to change to the default behavior as a breaking change during a major version upgrade. It is pretty legitimate.
It would be appropriate to change to the default behavior as a breaking change during a major version upgrade.
Agreed. 👍
I just wanted to know what the next steps would be. I really would like to have it in the main branch.
Seems stalled. If you pick itUp again and rebase it against main we can reopen.