-
-
Notifications
You must be signed in to change notification settings - Fork 320
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
feat: support InputFileType.Json and InputFileType.Dict #2165
Conversation
CodSpeed Performance ReportMerging #2165 will not alter performanceComparing Summary
|
Looks like some tests are failing - will have a deeper look tomorrow. |
I've submitted a new commit which should fix the failing test. |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #2165 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 38 38
Lines 4288 4294 +6
Branches 988 990 +2
=========================================
+ Hits 4288 4294 +6
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
hmmmmm... Should I modify test cases to trigger the |
We should try to add the test case if it's not diffcult. |
@XieJiSS Will you write the unittest? or Should I pick up the task? |
Roger that, I'm trying to add a new test. If it goes smoothly I'll add another commit in ~1 hour, and if I met difficulties I'll come back and report it here. |
I've added a test for the direct dictionary input feature. My local |
@XieJiSS we should cover all cases. https://app.codecov.io/gh/koxudaxi/datamodel-code-generator/pull/2165 |
Hi @koxudaxi, I checked the codecov report and noticed that there's a "partial" warning flag for the Dict branch. I think my test case should have covered this branch - it tests direct dictionary input with input_file_type set to InputFileType.Dict. And there's already another test case which test InputFileType.Dict + path to file as input. IMO together they should have covered all possible cases of this branch? Not sure what I've missed here. |
This PR fixes supports for
InputFileType.Json
andInputFileType.Dict
.RAW_DATA_TYPES
is defined as:Currently, the code handles them in a
if input_file_type in RAW_DATA_TYPES:
branch. Due to theelse:
branch being too loose, onlyInputFileType.CSV
andInputFileType.Yaml
can be correctly parsed. Other input data types will be treated asInputFileType.Yaml
and hence triggering exceptions.PR tested locally using the following code:
Original traceback:
After applying this patch:
Reference:
https://github.com/koxudaxi/datamodel-code-generator/blob/f5c8852176270a3f01eb78a116140ab8cf26f853/datamodel_code_generator/__init__.py#L355..L381