datamodel-code-generator icon indicating copy to clipboard operation
datamodel-code-generator copied to clipboard

Add prefix to all generated classes

Open fzyzcjy opened this issue 2 years ago • 1 comments

Hi thanks for the library! It would be great it a user-defined prefix could be added to all generated classes, because my downstream code generators rely on the class name to be unique etc.

fzyzcjy avatar Jun 30 '23 07:06 fzyzcjy

This might be more important than it seems.

I have a schema that leads to the following models.

For some reason, whenever both field name and class name match, optional nullable fields get clobbered, and I get a Input should be None whenever I validate valid data.

class Elem(BaseModel):
    model_config = ConfigDict(
        extra='allow',
    )
    temp: str


class TestModel(BaseModel):
    model_config = ConfigDict(
        extra='allow',
    )
    Elem: List[Elem] | None = None

ostefano avatar Jul 04 '24 16:07 ostefano