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

1"""Module for defining schemas for an author resource.""" 

2 

3from typing import Literal 

4 

5from kwai_core.json_api import ( 

6 Meta, 

7 ResourceIdentifier, 

8 ResourceMeta, 

9) 

10from pydantic import BaseModel, Field 

11 

12 

13class AuthorResourceIdentifier(ResourceIdentifier): 

14 """A JSON:API resource identifier for an author.""" 

15 

16 type: Literal["authors"] = "authors" 

17 

18 

19class AuthorAttributes(BaseModel): 

20 """Attributes for an author.""" 

21 

22 name: str 

23 remark: str 

24 active: bool 

25 editor: bool 

26 

27 

28class AuthorResource(AuthorResourceIdentifier): 

29 """A JSON:API resource for an author.""" 

30 

31 meta: ResourceMeta 

32 attributes: AuthorAttributes 

33 

34 

35class AuthorDocument(BaseModel): 

36 """A JSON:API document for an author entity.""" 

37 

38 data: AuthorResource 

39 

40 

41class AuthorsDocument(BaseModel): 

42 """A JSON:API document for multiple author entities.""" 

43 

44 meta: Meta 

45 data: list[AuthorResource] = Field(default_factory=list)