ktsn-ud commited on
Commit
adad91a
·
1 Parent(s): 6acd23e

型定義をTypedDictからpydanticに変更

Browse files
Files changed (2) hide show
  1. schemas/projects.py +6 -5
  2. schemas/tf_token.py +4 -4
schemas/projects.py CHANGED
@@ -1,7 +1,8 @@
1
- from typing import TypedDict, Optional, Literal
 
2
 
3
 
4
- class Project(TypedDict):
5
  """団体から提供された企画情報を格納するデータクラス。
6
  - `projectId`: 企画ID (unique)
7
  - `organization`: 団体名
@@ -55,7 +56,7 @@ class Project(TypedDict):
55
  reading: Optional[str]
56
 
57
 
58
- class ProjectSummary(TypedDict):
59
  """/api/projectsのレスポンス用データクラス。企画一覧に表示されるデータ。
60
  - `projectId`: 企画ID (unique)
61
  - `organization`: 団体名
@@ -85,7 +86,7 @@ class ProjectSummary(TypedDict):
85
  imageName: str
86
 
87
 
88
- class ProjectDetail(TypedDict):
89
  """/api/details?projectId=xxxのレスポンス用データクラス。企画詳細ページに表示されるデータ。
90
  - `projectId`: 企画ID (unique)
91
  - `organization`: 団体名
@@ -137,7 +138,7 @@ class ProjectDetail(TypedDict):
137
  urlOther: Optional[str]
138
 
139
 
140
- class ProjectIds(TypedDict):
141
  """/api/searchのレスポンス用データクラス。
142
  ## example:
143
  ```
 
1
+ from typing import Optional, Literal
2
+ from pydantic import BaseModel
3
 
4
 
5
+ class Project(BaseModel):
6
  """団体から提供された企画情報を格納するデータクラス。
7
  - `projectId`: 企画ID (unique)
8
  - `organization`: 団体名
 
56
  reading: Optional[str]
57
 
58
 
59
+ class ProjectSummary(BaseModel):
60
  """/api/projectsのレスポンス用データクラス。企画一覧に表示されるデータ。
61
  - `projectId`: 企画ID (unique)
62
  - `organization`: 団体名
 
86
  imageName: str
87
 
88
 
89
+ class ProjectDetail(BaseModel):
90
  """/api/details?projectId=xxxのレスポンス用データクラス。企画詳細ページに表示されるデータ。
91
  - `projectId`: 企画ID (unique)
92
  - `organization`: 団体名
 
138
  urlOther: Optional[str]
139
 
140
 
141
+ class ProjectIds(BaseModel):
142
  """/api/searchのレスポンス用データクラス。
143
  ## example:
144
  ```
schemas/tf_token.py CHANGED
@@ -1,12 +1,12 @@
1
- from typing import TypedDict
2
 
3
 
4
- class TfOfField(TypedDict):
5
  len: int
6
  tf: dict[str, int]
7
 
8
 
9
- class Fields(TypedDict):
10
  title: TfOfField
11
  organization: TfOfField
12
  reading: TfOfField
@@ -15,7 +15,7 @@ class Fields(TypedDict):
15
  prCommentLong: TfOfField
16
 
17
 
18
- class Project(TypedDict):
19
  projectId: str
20
  fields: Fields
21
  tf: dict[str, int]
 
1
+ from pydantic import BaseModel
2
 
3
 
4
+ class TfOfField(BaseModel):
5
  len: int
6
  tf: dict[str, int]
7
 
8
 
9
+ class Fields(BaseModel):
10
  title: TfOfField
11
  organization: TfOfField
12
  reading: TfOfField
 
15
  prCommentLong: TfOfField
16
 
17
 
18
+ class Project(BaseModel):
19
  projectId: str
20
  fields: Fields
21
  tf: dict[str, int]