Skip to content

Commit b84c102

Browse files
committed
slight change to payloads/responses
1 parent 5f2e98d commit b84c102

File tree

2 files changed

+61
-5
lines changed

2 files changed

+61
-5
lines changed

mystbin/backend/models/payloads.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,12 @@
2525
class PasteFile(BaseModel):
2626
content: str
2727
filename: str
28+
29+
class Config:
30+
schema_extra = {
31+
"content": "explosions everywhere",
32+
"filename": "kaboom.txt"
33+
}
2834

2935

3036
class PastePut(BaseModel):
@@ -36,15 +42,15 @@ class Config:
3642
schema_extra = {
3743
"example": {
3844
"expires": "2020-11-16T13:46:49.215Z",
39-
"password": "string",
45+
"password": None,
4046
"files": [
4147
{
42-
"content": "string",
43-
"filename": "string"
48+
"content": "import this",
49+
"filename": "foo.py"
4450
},
4551
{
46-
"content": "another_string",
47-
"filename": "another_string",
52+
"content": "doc.md",
53+
"filename": "**do not use this in production**",
4854
},
4955
],
5056
}

mystbin/backend/models/responses.py

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,16 @@ class File(BaseModel):
2828
loc: int
2929
charcount: int
3030

31+
class Config:
32+
schema_extra = {
33+
"example": {
34+
"filename": "foo.py",
35+
"content": "import datetime\\nprint(datetime.datetime.utcnow())",
36+
"loc": 2,
37+
"charcount": 49
38+
}
39+
}
40+
3141

3242
class PastePostResponse(BaseModel):
3343
id: str
@@ -37,6 +47,25 @@ class PastePostResponse(BaseModel):
3747
files: List[File]
3848
notice: Optional[str]
3949

50+
class Config:
51+
schema_extra = {
52+
"example": {
53+
"id": "FlyingHighKites",
54+
"author_id": None,
55+
"created_at": "2020-11-16T13:46:49.215Z",
56+
"expires": None,
57+
"files": [
58+
{
59+
"filename": "foo.py",
60+
"content": "import datetime\\nprint(datetime.datetime.utcnow())",
61+
"loc": 2,
62+
"charcount": 49
63+
}
64+
],
65+
"notice": "Found discord tokens and sent them to https://gist.github.com/Rapptz/c4324f17a80c94776832430007ad40e6 to be invalidated"
66+
}
67+
}
68+
4069

4170
class PastePatchResponse(BaseModel):
4271
id: str
@@ -45,12 +74,33 @@ class PastePatchResponse(BaseModel):
4574

4675
class PasteGetResponse(BaseModel):
4776
id: str
77+
author_id: Optional[int]
4878
created_at: datetime
4979
expires: Optional[datetime] = None
5080
last_edited: Optional[datetime] = None
5181
views: int
5282
files: List[File]
5383

84+
class Config:
85+
schema_extra = {
86+
"example": {
87+
"id": "FlyingHighKites",
88+
"author_id": None,
89+
"created_at": "2020-11-16T13:46:49.215Z",
90+
"expires": None,
91+
"last_edited": "2020-11-20T0:46:0.215Z",
92+
"views": 48,
93+
"files": [
94+
{
95+
"filename": "foo.py",
96+
"content": "import datetime\\nprint(datetime.datetime.utcnow())",
97+
"loc": 2,
98+
"charcount": 49
99+
}
100+
]
101+
}
102+
}
103+
54104

55105
class PasteGetAllResponse(BaseModel):
56106
id: str

0 commit comments

Comments
 (0)