Skip to content

Commit 6613040

Browse files
committed
Add more docs
1 parent 89b73e8 commit 6613040

File tree

2 files changed

+137
-2
lines changed

2 files changed

+137
-2
lines changed

views/api.py

Lines changed: 136 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,104 @@ def __init__(self, app: Application) -> None:
4040
@starlette_plus.limit(**CONFIG["LIMITS"]["paste_get"])
4141
@starlette_plus.limit(**CONFIG["LIMITS"]["paste_get_day"])
4242
async def paste_get(self, request: starlette_plus.Request) -> starlette_plus.Response:
43+
"""Fetch a paste.
44+
45+
---
46+
summary: Fetch a paste.
47+
description:
48+
Fetches a paste with all relevant meta-data and files.\n\n
49+
50+
Fetching pastes does not include the `password` or `safety` fields. You only receive the `safety` field
51+
directly after creating a paste.
52+
53+
parameters:
54+
- in: path
55+
name: id
56+
schema:
57+
type: string
58+
required: true
59+
description: The paste ID.
60+
61+
- in: header
62+
name: Authorization
63+
schema:
64+
type: string
65+
format: basic
66+
required: false
67+
description: The password for the paste; if one is required.
68+
69+
responses:
70+
200:
71+
description: The paste meta-data and files.
72+
content:
73+
application/json:
74+
schema:
75+
type: object
76+
properties:
77+
id:
78+
type: string
79+
example: abc123
80+
created_at:
81+
type: string
82+
example: 2024-01-01T00:00:00.000000+00:00
83+
expires:
84+
type: string
85+
views:
86+
type: integer
87+
example: 3
88+
has_password:
89+
type: boolean
90+
example: false
91+
files:
92+
type: array
93+
items:
94+
type: object
95+
properties:
96+
parent_id:
97+
type: string
98+
content:
99+
type: string
100+
filename:
101+
type: string
102+
loc:
103+
type: integer
104+
charcount:
105+
type: integer
106+
annotation:
107+
type: string
108+
109+
404:
110+
description: The paste does not exist or has been previously deleted.
111+
content:
112+
application/json:
113+
schema:
114+
type: object
115+
properties:
116+
error:
117+
type: string
118+
119+
401:
120+
description: You are not authorized to view this paste or you provided an incorrect password.
121+
content:
122+
application/json:
123+
schema:
124+
type: object
125+
properties:
126+
error:
127+
type: string
128+
example: Unauthorized.
129+
130+
429:
131+
description: You are requesting too fast.
132+
content:
133+
application/json:
134+
schema:
135+
type: object
136+
properties:
137+
error:
138+
type: string
139+
example: You are requesting too fast.
140+
"""
43141
password: str | None = request.headers.get("authorization", None)
44142
identifier: str = request.path_params["id"]
45143

@@ -204,8 +302,45 @@ async def security_info(self, request: starlette_plus.Request) -> starlette_plus
204302

205303
return starlette_plus.JSONResponse(data, status_code=200)
206304

207-
@starlette_plus.route("/security/delete/{token}", methods=["GET", "DELETE", "POST"])
305+
@starlette_plus.route("/security/delete/{token}", methods=["GET"])
208306
async def security_delete(self, request: starlette_plus.Request) -> starlette_plus.Response:
307+
"""Delete a paste.
308+
309+
---
310+
summary: Delete a paste.
311+
description:
312+
Deletes a paste with the associated safety token.\n\n
313+
314+
This action is not reversible.
315+
316+
parameters:
317+
- in: path
318+
name: token
319+
schema:
320+
type: string
321+
required: true
322+
description: The safety token received when creating the paste.
323+
324+
325+
responses:
326+
200:
327+
description: The paste was successfully deleted.
328+
content:
329+
text/plain:
330+
schema:
331+
type: string
332+
333+
401:
334+
description: You are not authorized to delete this paste.
335+
content:
336+
application/json:
337+
schema:
338+
type: object
339+
properties:
340+
error:
341+
type: string
342+
example: Unauthorized.
343+
"""
209344
token: str | None = request.path_params.get("token", None)
210345
if not token:
211346
return starlette_plus.JSONResponse({"error": "Unauthorized."}, status_code=401)

web/docs.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<!doctype html>
22
<html>
33
<head>
4-
<title>Scalar API Reference</title>
4+
<title>Mystbin - Documentation</title>
55
<meta charset="utf-8" />
66
<meta
77
name="viewport"

0 commit comments

Comments
 (0)