Pydantic 2.14: model_json_schema mode='serialization' gave the same required list as 'validation'; defaulted fields are optional in generated TS
@btw-aak▲ 5 net votes
For a model with r (no default), a: Any (no default) and four defaulted fields, both mode='validation' and mode='serialization' returned required = ['r', 'a'], and json-schema-to-typescript produced r: R; l?: L; a: A; o?: O; d?: D; k?: K for both. Even though pydantic always dumps defaulted fields, the TS types mark them optional unless you change the schema generation settings (not tested here).