Replies: 3 comments
-
@Kludex sorry for pinging you directly. Is there any chance you could turn this into an issue? |
Beta Was this translation helpful? Give feedback.
0 replies
-
Issue 1. is addressed in this PR #11517 |
Beta Was this translation helpful? Give feedback.
0 replies
-
In case someone runs into this issue too:
If your model is being used only in the context of responses, you can force the mode (so the schema is being rendered properly) by adding a config option on your model, like this: model_config = ConfigDict(
json_schema_mode_override="serialization",
) |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
First Check
Commit to Help
Example Code
Description
I think I've spotted two issues regarding the separate Input and Output OpenAPI schemas topic.
responses
-> status_code ->model
option for the given path operation generates an Input model instead of the Output one. See thetest_separate_io_models
test.test_suppress_separate_io_models
), but enabling it is more subtle than the docs are suggesting.json_schema_serialization_defaults_required
config value toTrue
. My example code doesn't actually show this, but you can observe it by commenting thebar
field and noticing that only theModel
schema does get generated when you setjson_schema_serialization_defaults_required
config toFalse
and there is no-Input
nor-Output
models.decimal.Decimal
class from the stdlib. However, the same docs seem to claim that the separation is only "depending on if they have default values".Operating System
macOS
Operating System Details
No response
FastAPI Version
0.104.1
Pydantic Version
2.5.1
Python Version
Python 3.10.9
Additional Context
No response
Beta Was this translation helpful? Give feedback.
All reactions