protobuf_to_pydantic
protobuf_to_pydantic copied to clipboard
feat: check_one_of also looks at field alias
Is your feature request related to a problem? Please describe.
The current check_one_of (PydanticV2 for instance) does not work if utilizing a field aliases. This is problematic if adding a plugin_config utilizing a custom base_model_class for example:
class CustomBaseSchema(BaseModel):
# override the ConfigDict to use PydanticV2 alias_generator
model_config = ConfigDict(
alias_generator=to_camel,
populate_by_name=True,
from_attributes=True,
)
base_model_class: Type[BaseModel] = CustomBaseSchema
Describe the solution you'd like For fields defined in in the one_of_dict, check if it has an alias.
// p2p: {"required": true, "oneof_extend": {"optional": ["some_nested_message"]}}
The above should also work with SomeNestedMessage.