django-ninja icon indicating copy to clipboard operation
django-ninja copied to clipboard

[BUG] `ModelSchema` produces `id > (integer | null)` openapi

Open viktorvsk opened this issue 1 year ago • 2 comments

Describe the bug

Having this model definition:

class MyModel(ModelSchema):
    class Meta:
        model = MyModel
        fields = ["id"]

Produces next definition on Swagger: id > (integer | null).

However this definition:

class MyModel(ModelSchema):
    id: int
    class Meta:
        model = MyModel

Produces id* integer as expected. SQL is default — id bigint NOT NULL

Versions (please complete the following information):

  • Python version: 3.12.2
  • Django version: 5.0.2
  • Django-Ninja version: 1.1.0
  • Pydantic version: 2.6.4

Probably a duplicate of https://github.com/vitalik/django-ninja/issues/907

viktorvsk avatar May 10 '24 09:05 viktorvsk

What does your MyModel orm model look like?

pmdevita avatar May 14 '24 15:05 pmdevita