()
| 121 | |
| 122 | |
| 123 | def test_by_alias(): |
| 124 | class ApplePie(BaseModel): |
| 125 | model_config = ConfigDict(title='Apple Pie') |
| 126 | a: float = Field(alias='Snap') |
| 127 | b: int = Field(10, alias='Crackle') |
| 128 | |
| 129 | assert ApplePie.model_json_schema() == { |
| 130 | 'type': 'object', |
| 131 | 'title': 'Apple Pie', |
| 132 | 'properties': { |
| 133 | 'Snap': {'type': 'number', 'title': 'Snap'}, |
| 134 | 'Crackle': {'type': 'integer', 'title': 'Crackle', 'default': 10}, |
| 135 | }, |
| 136 | 'required': ['Snap'], |
| 137 | } |
| 138 | assert list(ApplePie.model_json_schema(by_alias=True)['properties'].keys()) == ['Snap', 'Crackle'] |
| 139 | assert list(ApplePie.model_json_schema(by_alias=False)['properties'].keys()) == ['a', 'b'] |
| 140 | |
| 141 | |
| 142 | def test_ref_template(): |
nothing calls this directly
no test coverage detected