()
| 176 | |
| 177 | |
| 178 | def test_by_alias_generator(): |
| 179 | class ApplePie(BaseModel): |
| 180 | model_config = ConfigDict(alias_generator=lambda x: x.upper()) |
| 181 | a: float |
| 182 | b: int = 10 |
| 183 | |
| 184 | assert ApplePie.model_json_schema() == { |
| 185 | 'title': 'ApplePie', |
| 186 | 'type': 'object', |
| 187 | 'properties': {'A': {'title': 'A', 'type': 'number'}, 'B': {'title': 'B', 'default': 10, 'type': 'integer'}}, |
| 188 | 'required': ['A'], |
| 189 | } |
| 190 | assert ApplePie.model_json_schema(by_alias=False)['properties'].keys() == {'a', 'b'} |
| 191 | |
| 192 | |
| 193 | def test_sub_model(): |
nothing calls this directly
no test coverage detected