Coverage for apps/kwai-api/src/kwai_api/v1/auth/authors/schemas.py: 100%
10 statements
« prev ^ index » next coverage.py v7.11.0, created at 2024-01-01 00:00 +0000
« prev ^ index » next coverage.py v7.11.0, created at 2024-01-01 00:00 +0000
1"""Module for defining schemas for an author resource."""
3from typing import Literal
5from kwai_core.json_api import (
6 Meta,
7 ResourceIdentifier,
8 ResourceMeta,
9)
10from pydantic import BaseModel, Field
13class AuthorResourceIdentifier(ResourceIdentifier):
14 """A JSON:API resource identifier for an author."""
16 type: Literal["authors"] = "authors"
19class AuthorAttributes(BaseModel):
20 """Attributes for an author."""
22 name: str
23 remark: str
24 active: bool
25 editor: bool
28class AuthorResource(AuthorResourceIdentifier):
29 """A JSON:API resource for an author."""
31 meta: ResourceMeta
32 attributes: AuthorAttributes
35class AuthorDocument(BaseModel):
36 """A JSON:API document for an author entity."""
38 data: AuthorResource
41class AuthorsDocument(BaseModel):
42 """A JSON:API document for multiple author entities."""
44 meta: Meta
45 data: list[AuthorResource] = Field(default_factory=list)