vitalik / django-ninja

💨 Fast, Async-ready, Openapi, type hints based framework for building APIs
https://django-ninja.dev
MIT License
7.23k stars 429 forks source link

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

Open viktorvsk opened 6 months ago

viktorvsk commented 6 months ago

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):

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

pmdevita commented 5 months ago

What does your MyModel orm model look like?