You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is your feature request related to a problem? Please describe.
Not really a problem per say. But many of our current models are frozen dataclasses. We try to keep them immutable by default. But unfortunately theres not a flag for it when generating through this tool.
We will probably still explore generating these just as not frozen to start, so not really a blocker. But it would be awesome if we could bring that in soon.
Describe the solution you'd like
It seems like it would be straightforward to utilize the already available --enable-faux-immutability flag.
Describe alternatives you've considered
Could add another flag of --frozen-dataclasses or similar.
Additional context
Nothin that I can think of. If I have time I will try to get a PR up if desired :)
The text was updated successfully, but these errors were encountered:
Hi @JakeSummers, In this case specifically we're talking about python's dataclasses module. Which you can generate by passing --output-model-type dataclasses.dataclass. Which gives you this
@dataclassclassMyTHing:
...
Theres a frozen param you can pass to the decorator to lock all the fields, making it immutable. But datamodel-code-generator doesn't support this currently.
@dataclass(frozen=True)classMyTHing:
...
This second one is what I'm specifically trying to accomplish
Is your feature request related to a problem? Please describe.
Not really a problem per say. But many of our current models are frozen dataclasses. We try to keep them immutable by default. But unfortunately theres not a flag for it when generating through this tool.
We will probably still explore generating these just as not frozen to start, so not really a blocker. But it would be awesome if we could bring that in soon.
Describe the solution you'd like
It seems like it would be straightforward to utilize the already available
--enable-faux-immutability
flag.Describe alternatives you've considered
Could add another flag of
--frozen-dataclasses
or similar.Additional context
Nothin that I can think of. If I have time I will try to get a PR up if desired :)
The text was updated successfully, but these errors were encountered: