Skip to content

Commit

Permalink
fix(fastapi): default on pydantic aliases to fix serialization (#4575)
Browse files Browse the repository at this point in the history
  • Loading branch information
dsinghvi authored Sep 7, 2024
1 parent ac52e16 commit dcb4059
Show file tree
Hide file tree
Showing 180 changed files with 831 additions and 1,844 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/lint-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ jobs:
seed
postman
ci
fastapi
spring
express
requireScope: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
11 changes: 11 additions & 0 deletions generators/python/fastapi/versions.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,15 @@
# For unreleased changes, use unreleased.yml
- version: 1.4.9
ir_version: 53
changelog_entry:
- type: fix
summary: Default on `pydantic aliases`
fixed:
- The previous version of the FastAPI generator defaulted on a setting
which removed pydantic aliases. Because FastAPI calls into the
pydantic serializers itself, the generated models must have
aliases.

- version: 1.4.8
ir_version: 53
changelog_entry:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ class FastApiPydanticModelCustomConfig(BasePydanticModelCustomConfig):
extra_fields: Optional[Literal["allow", "forbid"]] = "forbid"
use_str_enums: bool = False
enum_type: EnumTypes = "python_enums"
use_pydantic_field_aliases: bool = True


class FastAPICustomConfig(pydantic.BaseModel):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ class BasePydanticModelCustomConfig(pydantic.BaseModel):
```
"""

# Defaulted to false for all, then SDK custom config will override
use_pydantic_field_aliases: bool = False

@pydantic.model_validator(mode="after")
Expand Down
2 changes: 2 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 7 additions & 9 deletions seed/fastapi/audiences/resources/foo/service/find_request.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 4 additions & 12 deletions seed/fastapi/examples/resources/types/types/exception_info.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 1 addition & 3 deletions seed/fastapi/examples/resources/types/types/movie.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 2 additions & 6 deletions seed/fastapi/examples/resources/types/types/stunt_double.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit dcb4059

Please sign in to comment.