hiranthaR / Json-to-Dart-Model

Json to Dart Model extension can convert JSON objects into Dart data classes. It supports pure Dart class conversion, Flutter-recommended JSON serialization using annotations, Freezed support, Effective Dart:Style, and many more features. Currently, it has more than 135,000 installs.
https://marketplace.visualstudio.com/items?itemName=hirantha.json-to-dart
MIT License
93 stars 18 forks source link

[BUG] Models not overridden when you re-run Build Models #59

Closed Prn-Ice closed 3 years ago

Prn-Ice commented 3 years ago

Is there an existing issue for this?

Current Behavior

Say I have the following in my models.jsonc

{
        "__className": "db_options",
        "__path": "/lib/app/core/data/models/db_options",
        "d@biometricsEnabled": false,
        "d@fontScalingEnabled": true,
        "d@liteModeEnabled": false,
        "d@showBiometricsDialog": true,
        "d@token": ""
    },

If I added a new field to the above json and rerun build models, I get told that db_options.dart already exists. I then have to delete the previously generated file and rerun the command for it to build successfully.

Expected Behavior

The previously generated file should be overriden.

Steps To Reproduce

No response

Version

3.3.6

Relevant JSON syntax

{
        "__className": "db_options",
        "__path": "/lib/app/core/data/models/db_options",
        "d@biometricsEnabled": false,
        "d@fontScalingEnabled": true,
        "d@liteModeEnabled": false,
        "d@showBiometricsDialog": true,
        "d@token": ""
    },

Anything else?

No response

iamarnas commented 3 years ago

@Prn-Ice Hi :wave:

Here is not a bug, the generator work with duplicates files in this way and guarantees to not override old files. Because this generator split the big nested JSON objects into separate files and is a big risk to override some important files by mistake. For example, hand modified or well documented. And it's documented that if you want to update files you need to delete old ones. And I think it does not happen so often, that's safer to delete it manually.

Prn-Ice commented 3 years ago

I see, thanks.