Support array unpacking in `AliasPath` for `validation_alias`
Author: gbdlinCreated Sep 9, 2026Updated Sep 17, 2026
Labelsfeature request
Initial Checks
- I have searched Google & GitHub for similar requests and couldn't find anything
- I have read and followed the docs and still think this feature is missing
Description
Allow for syntax that will result in unpacking a field from array of objects, presenting it as a simple array to the underlying object.
For example, given the data:
{
"name": "Blog entry",
"authors": [
{"name": "Alice"}
{"name": "Bob"}
]
}there could be a simple way to parse it into an object structured as:
Blog(name="Blog entry", authors=["Alice", "Bob"])Such syntax could look like:
class Blog(BaseModel):
name: str
authors: Annotated[list[str], Field(validation_alias=AliasPath("authors", ..., "name"))]This syntax could be expanded into multiple iteration levels to "flatten" nested arrays, simply by using ... multiple times in AliasPath.
Affected Components
- Compatibility between releases
- Data validation/parsing
- Data serialization -
.model_dump()and.model_dump_json() - JSON Schema
- Dataclasses
- Model Config
- Field Types - adding or changing a particular data type
- Function validation decorator
- Generic Models
- Other Model behaviour -
model_construct(), pickling, private attributes, ORM mode - Plugins and integration with other tools - mypy, FastAPI, python-devtools, Hypothesis, VS Code, PyCharm, etc.
Source: pydantic/pydantic