Skip to content

ModelSchema Field in fields list and model representation #1563

@pinguin999

Description

@pinguin999
class AuthorSchema(ModelSchema):
    if TYPE_CHECKING:
        id: int
        name: str
        role: str
        image: str

    class Meta:
        model = Author
        fields = ["id", "name", "role", "image"]


class TipSchema(ModelSchema):
    if TYPE_CHECKING:
        id: int
        name: str
        text: str

    author: AuthorSchema

    class Meta:
        model = Tip
        fields = ["id", "name", "text", "author"]

In this Code author is in author: AuthorSchema and in the fields list.
What is the expected behaviour? Returning the id or an object to type AuthorSchema?

Maybe the checker could raise an error that this configuration is not allowed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions