Initial Checks
Description
In the example below, bar will always have a value, so should be included in required, but it's not.
Example Code
from pydantic import BaseModel
class Foobar(BaseModel):
foo: int
bar: int = 1
print(Foobar.model_json_schema(mode='serialization'))
"""
{
'properties': {
'foo': {
'title': 'Foo',
'type': 'integer',
},
'bar': {
'default': 1,
'title': 'Bar',
'type': 'integer',
},
},
'required': ['foo'],
'title': 'Foobar',
'type': 'object',
}
"""
Python, Pydantic & OS Version
pydantic version: 2.5.2
pydantic-core version: 2.14.5
pydantic-core build: profile=release pgo=true
install path: /Users/samuel/code/fastui/env311/lib/python3.11/site-packages/pydantic
python version: 3.11.5 (main, Aug 26 2023, 13:55:09) [Clang 14.0.3 (clang-1403.0.22.14.1)]
platform: macOS-14.1-arm64-arm-64bit
related packages: typing_extensions-4.9.0 pyright-1.1.335 fastapi-0.104.1 mypy-1.7.0 email-validator-2.1.0.post1
Initial Checks
Description
In the example below,
barwill always have a value, so should be included inrequired, but it's not.Example Code
Python, Pydantic & OS Version