Skip to content

Commit

Permalink
Remove json schema generator from PyObjectId
Browse files Browse the repository at this point in the history
This is not required
  • Loading branch information
samarpan1738 committed Dec 22, 2024
1 parent 1b1e09f commit 4e2625b
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 9 deletions.
4 changes: 0 additions & 4 deletions todo/models/common/pyobjectid.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,3 @@ def validate(cls, value, field=None):
if value is not None and ObjectId.is_valid(value):
return ObjectId(value)
raise ValueError(f"Invalid ObjectId: {value}")

@classmethod
def __get_pydantic_json_schema__(cls, field_schema):
field_schema.update(type="string")
5 changes: 0 additions & 5 deletions todo/tests/unit/models/common/test_pyobjectid.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,6 @@ def test_validate_invalid_objectid(self):
def test_validate_none(self):
self.assertIsNone(PyObjectId.validate(None))

def test_pydantic_json_schema(self):
field_schema = {}
PyObjectId.__get_pydantic_json_schema__(field_schema)
self.assertEqual(field_schema["type"], "string")

def test_integration_with_pydantic_model(self):
class TestModel(BaseModel):
id: PyObjectId
Expand Down

0 comments on commit 4e2625b

Please sign in to comment.