Closed Prn-Ice closed 2 years ago
@Prn-Ice Hi 👋
By changing the path to the same object you tell to the generator that you want the same object in the different place.
In your case, your jsonc
should look like that:
{
"__className": "create_wallet_address_response",
"__path": "/lib/app/modules/deposit_withdraw/data/models/wallet_address_response",
"status": "success",
"data.walletAddress": {
"id": "4e252595-d326-4c26-89cc-f23d001ffa4a",
"account_id": "348e961f-899f-4790-b8e8-712616b74614",
"address": "1Msn2kMzveVCgX7i1ZpJWHGnEmNP7LBBL1",
"coin": "BTC"
}
},
{
"__className": "wallet_addresses_response",
"__path": "/lib/app/modules/deposit_withdraw/data/models/wallet_address_response",
"status": "success",
"data.walletAddress": [
{
"id": "4e252595-d326-4c26-89cc-f23d001ffa4a",
"account_id": "348e961f-899f-4790-b8e8-712616b74614",
"address": "1Msn2kMzveVCgX7i1ZpJWHGnEmNP7LBBL1",
"coin": "BTC"
}
]
}
You are welcome to describe more your opinion if I have not understood you correctly.
@Prn-Ice, @Miamoto-Musashi I need your opinion.
I see you work a lot with the jsonc
file and I need your opinion. What do you think if I move the path to the options object?
JSON
object options should look like this:"__options": {
"codeGenerator": "Default", // ['Default', 'JSON', 'Freezed']
"immutable": false,
"toString": "Default", // ['Default', 'Auto', 'Stringify', 'Dart']
"copyWith": false,
"equality": "Default", // ['Default', 'Equatable', 'Dart']
"targetDirectory": "/lib/src/models", // <- override path here
"runBuilder": false,
"sortConstructorsFirst": false,
"includeIfNull": false
},
Then you can use it in this way:
{
"__className": "user",
"__options": {
"toString": "Dart",
"equality": "Dart",
"targetDirectory": "/lib/src/models"
},
"name": "Name",
"id": 1010
}
This setup would allow configuring different output options for every JSON object.
@iamarnas Looks good.
@iamarnas thanks, your solution worked, I'll leave the issue open while we wait for @Miamoto-Mushashi to respond.
Hi @Prn-Ice and @iamarnas, in my experience you can have two patterns:
Best option should be to have a global setting overwritten, just in case, in the jsonc file.
I wouldn't pollute the jsonc file with options, but this is my opinion
@Miamoto-Musashi It should be two patterns. First if you not put options to the json object the default options automatically will read from settings. Second you can override by adding options to the object. User can decide how to owerride.
@Miamoto-Musashi I think if user have possibility create path to every module his can build clean architecture patterns self.
I made another issue that originates from this issue. Since this particular one is finished I will close the issue.
Thank you for your recommendations: @Miamoto-Musashi @Prn-Ice
Is there an existing issue for this?
Current Behavior
I have the following models declared in my
models.jsonc
After building models, the
data.walletAddress
class is generated twice, even though its the exact same model.Expected Behavior
Since the same model is declared twice, build only the first and reference it in the other.
Steps To Reproduce
No response
Version
Relevant JSON syntax
No response
Anything else?
No response