koxudaxi / datamodel-code-generator

Pydantic model and dataclasses.dataclass generator for easy conversion of JSON, OpenAPI, JSON Schema, and YAML data sources.
https://koxudaxi.github.io/datamodel-code-generator/
MIT License
2.78k stars 305 forks source link

Support for frozen dataclasses #2143

Open Sheemap opened 2 weeks ago

Sheemap commented 2 weeks ago

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 :)

Iddodo commented 2 weeks ago

My team could also use the addition of such feature (more in the context of Pydantic dataclasses, but I suspect that those would be related).