piccolo_api icon indicating copy to clipboard operation
piccolo_api copied to clipboard

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

Open hoosnick opened this issue 2 years ago • 1 comments

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 avatar Jul 29 '23 14:07 hoosnick

#248

hoosnick avatar Jul 29 '23 15:07 hoosnick