We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
DataclassDTO (and potentially other DTO types--I only tested with a Dataclass) don't seem to support properties.
# /// script # requires-python = ">=3.13" # dependencies = [ # "litestar", # "uvicorn", # ] # /// from dataclasses import dataclass import uvicorn from litestar import Litestar, get from litestar.dto import DataclassDTO, DTOConfig @dataclass class User: name: str @property def name_upper(self) -> str: return self.name.upper() class UserDTO(DataclassDTO[User]): config = DTOConfig( include={"name_upper"}, # Doesn't work ) @get("/", dto=UserDTO) async def get_user() -> User: return User(name="Alice") app = Litestar(route_handlers=[get_user]) if __name__ == "__main__": uvicorn.run(app)
$ uv run repro.py $ curl http://127.0.0.1:8000
Expected:
{"name_upper": "ALICE"}
Actual:
{}
No response
The text was updated successfully, but these errors were encountered:
Thanks for bringing this up @sloria, this should definitely be supported! :)
Sorry, something went wrong.
@property
No branches or pull requests
Summary
DataclassDTO (and potentially other DTO types--I only tested with a Dataclass) don't seem to support properties.
Basic Example
Expected:
Actual:
Drawbacks and Impact
No response
Unresolved questions
No response
The text was updated successfully, but these errors were encountered: