piccolo-orm / piccolo_api

ASGI middleware for authentication, rate limiting, and building REST endpoints.
https://piccolo-api.readthedocs.io/en/latest/
MIT License
146 stars 27 forks source link

`schema_extra` param not passed to `pydantic_model_{output | optional | plural}` methods #246

Open hoosnick opened 1 year ago

hoosnick commented 1 year ago

https://github.com/piccolo-orm/piccolo_api/blob/e2f8ce83a29234d0e6a79b4add044be71b904637/piccolo_api/crud/endpoints.py#L294-L304 Why is schema_extra not passed to the following methods as in this method above?

pydantic_model_output
pydantic_model_optional
pydantic_model_plural

When I use my pydantic basic config it only works for ModelIn and others don't

def to_camel(string: str) -> str:
    string_split = string.split("_")
    return string_split[0] + "".join(word.capitalize() for word in string_split[1:])

class MyConfig(pydantic.BaseConfig):
    alias_generator = to_camel
    allow_population_by_field_name = True

chat_crud = PiccoloCRUD(
    table=Message,
    read_only=False,
    max_joins=2,
    schema_extra={
        'pydantic_config_class': MyConfig
    }
)

It is convenient for my frontend that every input and output field is in camelCase. As another solution, I could name each field in my Table as camelCase, but then I would have to change my backend structure.

hoosnick commented 1 year ago

248