diff --git a/ninja/orm/fields.py b/ninja/orm/fields.py index 444e8275..bbdf2c59 100644 --- a/ninja/orm/fields.py +++ b/ninja/orm/fields.py @@ -65,6 +65,7 @@ def validate(cls, value: Any, _: Any) -> Any: "PositiveIntegerField": int, "PositiveSmallIntegerField": int, "SlugField": str, + "SmallAutoField": int, "SmallIntegerField": int, "TextField": str, "TimeField": datetime.time, diff --git a/tests/test_orm_schemas.py b/tests/test_orm_schemas.py index 07df9fa1..5897fba2 100644 --- a/tests/test_orm_schemas.py +++ b/tests/test_orm_schemas.py @@ -191,24 +191,27 @@ class Meta: } -def test_bigautofield(): - class ModelBigAuto(models.Model): - bigautofiled = models.BigAutoField(primary_key=True) +@pytest.mark.parametrize( + "field", + [ + models.BigAutoField, + models.SmallAutoField, + ] +) +def test_altautofield(field: type): + class ModelAltAuto(models.Model): + altautofield = field(primary_key=True) class Meta: app_label = "tests" - SchemaCls = create_schema(ModelBigAuto) + SchemaCls = create_schema(ModelAltAuto) # print(SchemaCls.json_schema()) - assert SchemaCls.json_schema() == { - "type": "object", - "properties": { - "bigautofiled": { - "anyOf": [{"type": "integer"}, {"type": "null"}], - "title": "Bigautofiled", - } - }, - "title": "ModelBigAuto", + assert SchemaCls.json_schema()["properties"] == { + "altautofield": { + "anyOf": [{"type": "integer"}, {"type": "null"}], + "title": "Altautofield", + } }