We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
$ gh repo clone pydantic/pydantic-extra-types $ cd pydantic-extra-types $ python3.12 -m venv _e $ . _e/bin/activate (_e) $ pip install -e .[all] (_e) $ pip install -r requirements/testing.in (_e) $ python -m pytest […] =================================================================================================== FAILURES =================================================================================================== _______________________________________________________________________________________________ test_json_schema _______________________________________________________________________________________________ def test_json_schema(): class Model(BaseModel): value: Coordinate assert Model.model_json_schema(mode='validation')['$defs']['Coordinate'] == { 'properties': { 'latitude': {'maximum': 90.0, 'minimum': -90.0, 'title': 'Latitude', 'type': 'number'}, 'longitude': {'maximum': 180.0, 'minimum': -180.0, 'title': 'Longitude', 'type': 'number'}, }, 'required': ['latitude', 'longitude'], 'title': 'Coordinate', 'type': 'object', } assert Model.model_json_schema(mode='validation')['properties']['value'] == { 'anyOf': [ {'$ref': '#/$defs/Coordinate'}, { 'maxItems': 2, 'minItems': 2, 'prefixItems': [{'type': 'number'}, {'type': 'number'}], 'type': 'array', }, {'type': 'string'}, ], 'title': 'Value', } > assert Model.model_json_schema(mode='serialization') == { '$defs': { 'Coordinate': { 'properties': { 'latitude': {'maximum': 90.0, 'minimum': -90.0, 'title': 'Latitude', 'type': 'number'}, 'longitude': {'maximum': 180.0, 'minimum': -180.0, 'title': 'Longitude', 'type': 'number'}, }, 'required': ['latitude', 'longitude'], 'title': 'Coordinate', 'type': 'object', } }, 'properties': {'value': {'allOf': [{'$ref': '#/$defs/Coordinate'}], 'title': 'Value'}}, 'required': ['value'], 'title': 'Model', 'type': 'object', } E AssertionError: assert {'$defs': {'C... 'Model', ...} == {'$defs': {'C... 'Model', ...} E E Omitting 4 identical items, use -vv to show E Differing items: E {'properties': {'value': {'$ref': '#/$defs/Coordinate', 'title': 'Value'}}} != {'properties': {'value': { E E ...Full output truncated (2 lines hidden), use '-vv' to show tests/test_coordinate.py:180: AssertionError Summary of Failures ┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━┓ ┃ File ┃ Function ┃ Function Line ┃ Error Line ┃ Error ┃ ┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━┩ │ tests/test_coordinate.py │ test_json_schema │ 154 │ 180 │ AssertionError │ └────────────────────────────┴────────────────────┴─────────────────┴──────────────┴──────────────────┘ Results (5.50s): 1 failed 13056 passed (_e) $ pip install pydantic==2.8.2 (_e) $ python -m pytest […] Results (5.60s): 13057 passed
The text was updated successfully, but these errors were encountered:
Looking at
E Differing items: E {'properties': {'value': {'$ref': '#/$defs/Coordinate', 'title': 'Value'}}} != {'properties': {'value': {'allOf': [{'$ref': '#/$defs/Coordinate'}], 'title': 'Value'}}}
it seems the schemas are not identical, but are equivalent.
Sorry, something went wrong.
Adjust test_json_schema() for Pydantic 2.9
b8a0629
Fixes pydantic#213.
58db4b0
Successfully merging a pull request may close this issue.
The text was updated successfully, but these errors were encountered: