-
Notifications
You must be signed in to change notification settings - Fork 270
New issue
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
Pydantic computed fields are not appearing in the schema #1354
Comments
Hey, I just added a computed property to the tests and it works as expected. Are you sure you are using spectacular 0.28.0? Also we generate the schema slightly differently with model_json_schema(self.target, ref_template="#/components/schemas/{model}", mode="serialization") but we also set to mode to Please see the PR, which is passing. Don't mind the broken build, it is due to another lib changing currently. |
@tfranzel . I'm using 0.27.2. I think I need to upgrade. I'll close the issue now. |
add pydantic computed field to tests #1354
Describe the bug
If your create a pydantic basemodel which has computed fields as fields, those fields don't appear when you pass it to drf-spectacular as a serializer.
To Reproduce
Create any Pydantic model with computer fields and pass it as a serializer to the
extend_schema
decorator orget_serializer
method.Expected behavior
The computed fields should apppear.
I did find that, in the pydantic extension. Setting the model_dump_schema(mode='serialization') fixes the issue
The text was updated successfully, but these errors were encountered: