Skip to content

Commit 6d69213

Browse files
Merge pull request #158 from saritasa-nest/feature/improve-api-docs-for-get-params
Improve docs for get params Django API
2 parents 3e14f15 + bcbaad7 commit 6d69213

5 files changed

Lines changed: 44 additions & 4 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ We follow [Semantic Versions](https://semver.org/).
66

77
- Replace [httpx](https://github.com/encode/httpx) with
88
[httpx2](https://github.com/pydantic/httpx2) in docs and tests
9+
- Improve docs for get params Django API
910

1011
## 0.8.0
1112

pyproject.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,10 @@ local = [
108108
# A library and CLI app for rendering project templates.
109109
# https://copier.readthedocs.io/en/latest/
110110
"copier",
111+
# Werkzeug is a comprehensive WSGI web application library.
112+
# Required to use runserver_plus
113+
# https://werkzeug.palletsprojects.com/en/stable/
114+
"Werkzeug",
111115
]
112116
linters = [
113117
# Mypy is a static type checker for Python.

saritasa_s3_tools/configs.py

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,25 @@ class S3FileTypeConfig(metaclass=S3FileTypeConfigMeta):
3939
expires_in: int = 3600
4040
success_action_status: int = 201
4141
# https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Disposition
42-
content_disposition: (
43-
typing.Literal["attachment"] | typing.Literal["inline"]
44-
) = "attachment"
42+
content_disposition: typing.Literal["attachment", "inline"] = "attachment"
43+
44+
def get_short_description(self) -> str:
45+
"""Get short description for config."""
46+
allowed_types = (
47+
", ".join(self.allowed) if self.allowed else "All types"
48+
)
49+
content_length_range = (
50+
(
51+
f"{self.content_length_range[0]}-"
52+
f"{self.content_length_range[1]} bytes"
53+
)
54+
if self.content_length_range
55+
else "Any length"
56+
)
57+
return (
58+
f"*Allowed types*: {allowed_types}, "
59+
f"*Content length range*: {content_length_range}, "
60+
f"*Expires in*: {self.expires_in} seconds, "
61+
f"*Success action status*: {self.success_action_status}, "
62+
f"*Content disposition*: {self.content_disposition}"
63+
)

saritasa_s3_tools/django/drf_fields.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,9 @@ def _get_choices(self) -> dict[str, str]:
2525
current_choices = tuple(
2626
(
2727
config_name,
28-
config_name,
28+
configs.S3FileTypeConfig.configs[
29+
config_name
30+
].get_short_description(),
2931
)
3032
for config_name in configs.S3FileTypeConfig.configs
3133
)

uv.lock

Lines changed: 14 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)