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
Add default to JSON schema when const is True #4152
Add default to JSON schema when const is True #4152
Conversation
please review |
The |
IMO the |
Not sure if I understand correctly but this will not include a class Test(BaseModel):
x: Literal[10] {"title": "Test", "type": "object", "properties": {"x": {"title": "X", "enum": [10], "type": "integer"}}, "required": ["x"]} But this will which I'm not sure if is correct: class Test(BaseModel):
x: Literal[10] = Field(default=10) {"title": "Test", "type": "object", "properties": {"x": {"title": "X", "default": 10, "enum": [10], "type": "integer"}}} |
And about the |
I think what @PrettyWood means is that |
thanks so much for this. |
Change Summary
Right now for the following Model:
The JSON schema is:
Which will include the
default
:I couldn't find the reason why it was introduced in #2094 but seems like the main purpose was something else.
Related issue number
Fixes #4031
Checklist
changes/<pull request or issue id>-<github username>.md
file added describing change(see changes/README.md for details)