erdantic icon indicating copy to clipboard operation
erdantic copied to clipboard

Support pydantic field's alias

Open igoose1 opened this issue 1 year ago • 0 comments

I suggest to support pydantic.Field.alias field. Currently erdantic ignores it.

That's an example with simple Gift class:

from pydantic import BaseModel, Field


class Gift(BaseModel):
    for_: str = Field(alias="for")

erdantic produces:

image

Although, pydantic displays a field as for:

>>> Gift.schema()
{'title': 'Gift', 'type': 'object', 'properties': {'for': {'title': 'For', 'type': 'string'}},
'required': ['for']}

Libraries like FastAPI use that schema in Swagger generations.

igoose1 avatar May 25 '23 16:05 igoose1