Breaking Changes
Code Generation Changes
- Models with
unevaluatedPropertiesnow generate extra field configuration - JSON Schemas containingunevaluatedProperties: falsewill now generate models withextra='forbid'(Pydantic v2) orextra = Extra.forbid(Pydantic v1), and schemas withunevaluatedProperties: truewill generateextra='allow'. Previously this keyword was ignored. This may cause validation errors for data that was previously accepted. (#2797)
Example - a schema like:Previously generated:{ "title": "Resource", "type": "object", "properties": { "name": { "type": "string" } }, "unevaluatedProperties": false }Now generates:class Resource(BaseModel): name: str | None = None
class Resource(BaseModel): model_config = ConfigDict(extra='forbid') name: str | None = None
Default Behavior Changes
- Default encoding changed from system locale to UTF-8 - The default encoding for reading input files and writing output is now always
utf-8instead of the system's locale-preferred encoding (e.g.,cp1252on Windows). Users who rely on locale-specific encoding must now explicitly use--encodingto specify their desired encoding (#2802)
What's Changed
- Fix missing model_config in query parameter classes by @koxudaxi in #2795
- Escape backslash and triple quotes in docstrings by @koxudaxi in #2796
- Add unevaluatedProperties support by @koxudaxi in #2797
- Expose schema $id and path to template context by @koxudaxi in #2798
- Improve CLI startup time with lazy imports by @koxudaxi in #2799
- Use UTF-8 as default encoding instead of locale-preferred by @koxudaxi in #2802
- Add model-level json_schema_extra support for Pydantic v2 by @koxudaxi in #2803
- Add input_model field support to cli_doc marker by @koxudaxi in #2805
- Add dict input support for generate() function by @koxudaxi in #2806
- Optimize extra_template_data copy in DataModel init by @koxudaxi in #2811
- Add LRU cache for file loading and path existence checks by @koxudaxi in #2810
- Optimize JSON/YAML loading with auto-detection and json.load by @koxudaxi in #2809
- Migrate docs deployment to Cloudflare Pages by @koxudaxi in #2812
- Optimize CI workflow with tox cache and remove dev check by @koxudaxi in #2815
- Fix superfluous None when using $ref with nullable type aliases by @koxudaxi in #2814
- Remove tox cache that breaks Windows CI by @koxudaxi in #2816
- Add --input-model option for Pydantic models and dicts by @koxudaxi in #2804
- Add ReadOnly support for TypedDict with --use-frozen-field by @koxudaxi in #2813
- Exclude perf tests from regular test runs by @koxudaxi in #2817
- Add extreme-scale performance tests with dynamic schema generation by @koxudaxi in #2818
- Add ULID type support by @ahmetveburak in #2820
- Add --enum-field-as-literal-map option and x-enum-field-as-literal schema extension by @koxudaxi in #2821
- Fix propertyNames constraint ignored when using $ref to enum definition by @koxudaxi in #2824
- Reduce CodSpeed benchmark tests for faster CI by @koxudaxi in #2826
- Optimize propertyNames $ref handling by calling get_ref_data_type directly by @koxudaxi in #2825
- Add missing path and ulid type mappings to TypedDict type manager by @koxudaxi in #2828
- Fix --check to use output path's pyproject.toml settings by @koxudaxi in #2831
New Contributors
- @ahmetveburak made their first contribution in #2820
Full Changelog: 0.49.0...0.50.0