gmt-python-sdk 0.12.0__tar.gz → 0.14.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- gmt_python_sdk-0.14.0/.release-please-manifest.json +3 -0
- {gmt_python_sdk-0.12.0 → gmt_python_sdk-0.14.0}/CHANGELOG.md +21 -0
- {gmt_python_sdk-0.12.0 → gmt_python_sdk-0.14.0}/PKG-INFO +1 -1
- {gmt_python_sdk-0.12.0 → gmt_python_sdk-0.14.0}/pyproject.toml +1 -1
- {gmt_python_sdk-0.12.0 → gmt_python_sdk-0.14.0}/src/gmt/_base_client.py +5 -2
- {gmt_python_sdk-0.12.0 → gmt_python_sdk-0.14.0}/src/gmt/_compat.py +3 -3
- gmt_python_sdk-0.14.0/src/gmt/_utils/_json.py +35 -0
- {gmt_python_sdk-0.12.0 → gmt_python_sdk-0.14.0}/src/gmt/_version.py +1 -1
- {gmt_python_sdk-0.12.0 → gmt_python_sdk-0.14.0}/src/gmt/resources/accounts.py +2 -2
- {gmt_python_sdk-0.12.0 → gmt_python_sdk-0.14.0}/src/gmt/types/account_list_countries_params.py +1 -1
- {gmt_python_sdk-0.12.0 → gmt_python_sdk-0.14.0}/src/gmt/types/profile_retrieve_response.py +8 -2
- gmt_python_sdk-0.14.0/tests/test_utils/test_json.py +126 -0
- gmt_python_sdk-0.12.0/.release-please-manifest.json +0 -3
- {gmt_python_sdk-0.12.0 → gmt_python_sdk-0.14.0}/.gitignore +0 -0
- {gmt_python_sdk-0.12.0 → gmt_python_sdk-0.14.0}/CONTRIBUTING.md +0 -0
- {gmt_python_sdk-0.12.0 → gmt_python_sdk-0.14.0}/LICENSE +0 -0
- {gmt_python_sdk-0.12.0 → gmt_python_sdk-0.14.0}/README.md +0 -0
- {gmt_python_sdk-0.12.0 → gmt_python_sdk-0.14.0}/SECURITY.md +0 -0
- {gmt_python_sdk-0.12.0 → gmt_python_sdk-0.14.0}/api.md +0 -0
- {gmt_python_sdk-0.12.0 → gmt_python_sdk-0.14.0}/bin/check-release-environment +0 -0
- {gmt_python_sdk-0.12.0 → gmt_python_sdk-0.14.0}/bin/publish-pypi +0 -0
- {gmt_python_sdk-0.12.0 → gmt_python_sdk-0.14.0}/examples/.keep +0 -0
- {gmt_python_sdk-0.12.0 → gmt_python_sdk-0.14.0}/release-please-config.json +0 -0
- {gmt_python_sdk-0.12.0 → gmt_python_sdk-0.14.0}/requirements-dev.lock +0 -0
- {gmt_python_sdk-0.12.0 → gmt_python_sdk-0.14.0}/src/gmt/__init__.py +0 -0
- {gmt_python_sdk-0.12.0 → gmt_python_sdk-0.14.0}/src/gmt/_client.py +0 -0
- {gmt_python_sdk-0.12.0 → gmt_python_sdk-0.14.0}/src/gmt/_constants.py +0 -0
- {gmt_python_sdk-0.12.0 → gmt_python_sdk-0.14.0}/src/gmt/_exceptions.py +0 -0
- {gmt_python_sdk-0.12.0 → gmt_python_sdk-0.14.0}/src/gmt/_files.py +0 -0
- {gmt_python_sdk-0.12.0 → gmt_python_sdk-0.14.0}/src/gmt/_models.py +0 -0
- {gmt_python_sdk-0.12.0 → gmt_python_sdk-0.14.0}/src/gmt/_qs.py +0 -0
- {gmt_python_sdk-0.12.0 → gmt_python_sdk-0.14.0}/src/gmt/_resource.py +0 -0
- {gmt_python_sdk-0.12.0 → gmt_python_sdk-0.14.0}/src/gmt/_response.py +0 -0
- {gmt_python_sdk-0.12.0 → gmt_python_sdk-0.14.0}/src/gmt/_streaming.py +0 -0
- {gmt_python_sdk-0.12.0 → gmt_python_sdk-0.14.0}/src/gmt/_types.py +0 -0
- {gmt_python_sdk-0.12.0 → gmt_python_sdk-0.14.0}/src/gmt/_utils/__init__.py +0 -0
- {gmt_python_sdk-0.12.0 → gmt_python_sdk-0.14.0}/src/gmt/_utils/_compat.py +0 -0
- {gmt_python_sdk-0.12.0 → gmt_python_sdk-0.14.0}/src/gmt/_utils/_datetime_parse.py +0 -0
- {gmt_python_sdk-0.12.0 → gmt_python_sdk-0.14.0}/src/gmt/_utils/_logs.py +0 -0
- {gmt_python_sdk-0.12.0 → gmt_python_sdk-0.14.0}/src/gmt/_utils/_proxy.py +0 -0
- {gmt_python_sdk-0.12.0 → gmt_python_sdk-0.14.0}/src/gmt/_utils/_reflection.py +0 -0
- {gmt_python_sdk-0.12.0 → gmt_python_sdk-0.14.0}/src/gmt/_utils/_resources_proxy.py +0 -0
- {gmt_python_sdk-0.12.0 → gmt_python_sdk-0.14.0}/src/gmt/_utils/_streams.py +0 -0
- {gmt_python_sdk-0.12.0 → gmt_python_sdk-0.14.0}/src/gmt/_utils/_sync.py +0 -0
- {gmt_python_sdk-0.12.0 → gmt_python_sdk-0.14.0}/src/gmt/_utils/_transform.py +0 -0
- {gmt_python_sdk-0.12.0 → gmt_python_sdk-0.14.0}/src/gmt/_utils/_typing.py +0 -0
- {gmt_python_sdk-0.12.0 → gmt_python_sdk-0.14.0}/src/gmt/_utils/_utils.py +0 -0
- {gmt_python_sdk-0.12.0 → gmt_python_sdk-0.14.0}/src/gmt/lib/.keep +0 -0
- {gmt_python_sdk-0.12.0 → gmt_python_sdk-0.14.0}/src/gmt/pagination.py +0 -0
- {gmt_python_sdk-0.12.0 → gmt_python_sdk-0.14.0}/src/gmt/py.typed +0 -0
- {gmt_python_sdk-0.12.0 → gmt_python_sdk-0.14.0}/src/gmt/resources/__init__.py +0 -0
- {gmt_python_sdk-0.12.0 → gmt_python_sdk-0.14.0}/src/gmt/resources/profile.py +0 -0
- {gmt_python_sdk-0.12.0 → gmt_python_sdk-0.14.0}/src/gmt/resources/purchases.py +0 -0
- {gmt_python_sdk-0.12.0 → gmt_python_sdk-0.14.0}/src/gmt/resources/service.py +0 -0
- {gmt_python_sdk-0.12.0 → gmt_python_sdk-0.14.0}/src/gmt/resources/webhooks.py +0 -0
- {gmt_python_sdk-0.12.0 → gmt_python_sdk-0.14.0}/src/gmt/types/__init__.py +0 -0
- {gmt_python_sdk-0.12.0 → gmt_python_sdk-0.14.0}/src/gmt/types/account_list_countries_response.py +0 -0
- {gmt_python_sdk-0.12.0 → gmt_python_sdk-0.14.0}/src/gmt/types/account_list_params.py +0 -0
- {gmt_python_sdk-0.12.0 → gmt_python_sdk-0.14.0}/src/gmt/types/account_list_response.py +0 -0
- {gmt_python_sdk-0.12.0 → gmt_python_sdk-0.14.0}/src/gmt/types/account_retrieve_response.py +0 -0
- {gmt_python_sdk-0.12.0 → gmt_python_sdk-0.14.0}/src/gmt/types/purchase_create_params.py +0 -0
- {gmt_python_sdk-0.12.0 → gmt_python_sdk-0.14.0}/src/gmt/types/purchase_create_response.py +0 -0
- {gmt_python_sdk-0.12.0 → gmt_python_sdk-0.14.0}/src/gmt/types/purchase_list_params.py +0 -0
- {gmt_python_sdk-0.12.0 → gmt_python_sdk-0.14.0}/src/gmt/types/purchase_list_response.py +0 -0
- {gmt_python_sdk-0.12.0 → gmt_python_sdk-0.14.0}/src/gmt/types/purchase_refund_response.py +0 -0
- {gmt_python_sdk-0.12.0 → gmt_python_sdk-0.14.0}/src/gmt/types/purchase_request_verification_code_params.py +0 -0
- {gmt_python_sdk-0.12.0 → gmt_python_sdk-0.14.0}/src/gmt/types/purchase_request_verification_code_response.py +0 -0
- {gmt_python_sdk-0.12.0 → gmt_python_sdk-0.14.0}/src/gmt/types/purchase_retrieve_response.py +0 -0
- {gmt_python_sdk-0.12.0 → gmt_python_sdk-0.14.0}/src/gmt/types/service_get_server_time_response.py +0 -0
- {gmt_python_sdk-0.12.0 → gmt_python_sdk-0.14.0}/src/gmt/types/service_health_check_response.py +0 -0
- {gmt_python_sdk-0.12.0 → gmt_python_sdk-0.14.0}/src/gmt/types/webhook_test_params.py +0 -0
- {gmt_python_sdk-0.12.0 → gmt_python_sdk-0.14.0}/src/gmt/types/webhook_test_response.py +0 -0
- {gmt_python_sdk-0.12.0 → gmt_python_sdk-0.14.0}/tests/__init__.py +0 -0
- {gmt_python_sdk-0.12.0 → gmt_python_sdk-0.14.0}/tests/api_resources/__init__.py +0 -0
- {gmt_python_sdk-0.12.0 → gmt_python_sdk-0.14.0}/tests/api_resources/test_accounts.py +0 -0
- {gmt_python_sdk-0.12.0 → gmt_python_sdk-0.14.0}/tests/api_resources/test_profile.py +0 -0
- {gmt_python_sdk-0.12.0 → gmt_python_sdk-0.14.0}/tests/api_resources/test_purchases.py +0 -0
- {gmt_python_sdk-0.12.0 → gmt_python_sdk-0.14.0}/tests/api_resources/test_service.py +0 -0
- {gmt_python_sdk-0.12.0 → gmt_python_sdk-0.14.0}/tests/api_resources/test_webhooks.py +0 -0
- {gmt_python_sdk-0.12.0 → gmt_python_sdk-0.14.0}/tests/conftest.py +0 -0
- {gmt_python_sdk-0.12.0 → gmt_python_sdk-0.14.0}/tests/sample_file.txt +0 -0
- {gmt_python_sdk-0.12.0 → gmt_python_sdk-0.14.0}/tests/test_client.py +0 -0
- {gmt_python_sdk-0.12.0 → gmt_python_sdk-0.14.0}/tests/test_deepcopy.py +0 -0
- {gmt_python_sdk-0.12.0 → gmt_python_sdk-0.14.0}/tests/test_extract_files.py +0 -0
- {gmt_python_sdk-0.12.0 → gmt_python_sdk-0.14.0}/tests/test_files.py +0 -0
- {gmt_python_sdk-0.12.0 → gmt_python_sdk-0.14.0}/tests/test_models.py +0 -0
- {gmt_python_sdk-0.12.0 → gmt_python_sdk-0.14.0}/tests/test_qs.py +0 -0
- {gmt_python_sdk-0.12.0 → gmt_python_sdk-0.14.0}/tests/test_required_args.py +0 -0
- {gmt_python_sdk-0.12.0 → gmt_python_sdk-0.14.0}/tests/test_response.py +0 -0
- {gmt_python_sdk-0.12.0 → gmt_python_sdk-0.14.0}/tests/test_streaming.py +0 -0
- {gmt_python_sdk-0.12.0 → gmt_python_sdk-0.14.0}/tests/test_transform.py +0 -0
- {gmt_python_sdk-0.12.0 → gmt_python_sdk-0.14.0}/tests/test_utils/test_datetime_parse.py +0 -0
- {gmt_python_sdk-0.12.0 → gmt_python_sdk-0.14.0}/tests/test_utils/test_proxy.py +0 -0
- {gmt_python_sdk-0.12.0 → gmt_python_sdk-0.14.0}/tests/test_utils/test_typing.py +0 -0
- {gmt_python_sdk-0.12.0 → gmt_python_sdk-0.14.0}/tests/utils.py +0 -0
- {gmt_python_sdk-0.12.0 → gmt_python_sdk-0.14.0}/uv.lock +0 -0
|
@@ -1,5 +1,26 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.14.0 (2026-01-30)
|
|
4
|
+
|
|
5
|
+
Full Changelog: [v0.13.0...v0.14.0](https://github.com/cameo6/gmt-python-sdk/compare/v0.13.0...v0.14.0)
|
|
6
|
+
|
|
7
|
+
### Features
|
|
8
|
+
|
|
9
|
+
* **client:** add custom JSON encoder for extended type support ([09619c4](https://github.com/cameo6/gmt-python-sdk/commit/09619c46443faf76be753075518b53560d6dd958))
|
|
10
|
+
|
|
11
|
+
## 0.13.0 (2026-01-27)
|
|
12
|
+
|
|
13
|
+
Full Changelog: [v0.12.0...v0.13.0](https://github.com/cameo6/gmt-python-sdk/compare/v0.12.0...v0.13.0)
|
|
14
|
+
|
|
15
|
+
### Features
|
|
16
|
+
|
|
17
|
+
* **api:** api update ([f475b49](https://github.com/cameo6/gmt-python-sdk/commit/f475b49d3d4b8c3473b7be6ea2d7e45990c6a718))
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
### Chores
|
|
21
|
+
|
|
22
|
+
* **ci:** upgrade `actions/github-script` ([b84addd](https://github.com/cameo6/gmt-python-sdk/commit/b84addd41b71ccef80ac6f3f0d7f2f3e0b027981))
|
|
23
|
+
|
|
3
24
|
## 0.12.0 (2026-01-23)
|
|
4
25
|
|
|
5
26
|
Full Changelog: [v0.11.0...v0.12.0](https://github.com/cameo6/gmt-python-sdk/compare/v0.11.0...v0.12.0)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.3
|
|
2
2
|
Name: gmt-python-sdk
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.14.0
|
|
4
4
|
Summary: The official Python library for the gmt API
|
|
5
5
|
Project-URL: Homepage, https://github.com/cameo6/gmt-python-sdk
|
|
6
6
|
Project-URL: Repository, https://github.com/cameo6/gmt-python-sdk
|
|
@@ -86,6 +86,7 @@ from ._exceptions import (
|
|
|
86
86
|
APIConnectionError,
|
|
87
87
|
APIResponseValidationError,
|
|
88
88
|
)
|
|
89
|
+
from ._utils._json import openapi_dumps
|
|
89
90
|
|
|
90
91
|
log: logging.Logger = logging.getLogger(__name__)
|
|
91
92
|
|
|
@@ -554,8 +555,10 @@ class BaseClient(Generic[_HttpxClientT, _DefaultStreamT]):
|
|
|
554
555
|
kwargs["content"] = options.content
|
|
555
556
|
elif isinstance(json_data, bytes):
|
|
556
557
|
kwargs["content"] = json_data
|
|
557
|
-
|
|
558
|
-
|
|
558
|
+
elif not files:
|
|
559
|
+
# Don't set content when JSON is sent as multipart/form-data,
|
|
560
|
+
# since httpx's content param overrides other body arguments
|
|
561
|
+
kwargs["content"] = openapi_dumps(json_data) if is_given(json_data) and json_data is not None else None
|
|
559
562
|
kwargs["files"] = files
|
|
560
563
|
else:
|
|
561
564
|
headers.pop("Content-Type", None)
|
|
@@ -139,6 +139,7 @@ def model_dump(
|
|
|
139
139
|
exclude_defaults: bool = False,
|
|
140
140
|
warnings: bool = True,
|
|
141
141
|
mode: Literal["json", "python"] = "python",
|
|
142
|
+
by_alias: bool | None = None,
|
|
142
143
|
) -> dict[str, Any]:
|
|
143
144
|
if (not PYDANTIC_V1) or hasattr(model, "model_dump"):
|
|
144
145
|
return model.model_dump(
|
|
@@ -148,13 +149,12 @@ def model_dump(
|
|
|
148
149
|
exclude_defaults=exclude_defaults,
|
|
149
150
|
# warnings are not supported in Pydantic v1
|
|
150
151
|
warnings=True if PYDANTIC_V1 else warnings,
|
|
152
|
+
by_alias=by_alias,
|
|
151
153
|
)
|
|
152
154
|
return cast(
|
|
153
155
|
"dict[str, Any]",
|
|
154
156
|
model.dict( # pyright: ignore[reportDeprecated, reportUnnecessaryCast]
|
|
155
|
-
exclude=exclude,
|
|
156
|
-
exclude_unset=exclude_unset,
|
|
157
|
-
exclude_defaults=exclude_defaults,
|
|
157
|
+
exclude=exclude, exclude_unset=exclude_unset, exclude_defaults=exclude_defaults, by_alias=bool(by_alias)
|
|
158
158
|
),
|
|
159
159
|
)
|
|
160
160
|
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import json
|
|
2
|
+
from typing import Any
|
|
3
|
+
from datetime import datetime
|
|
4
|
+
from typing_extensions import override
|
|
5
|
+
|
|
6
|
+
import pydantic
|
|
7
|
+
|
|
8
|
+
from .._compat import model_dump
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
def openapi_dumps(obj: Any) -> bytes:
|
|
12
|
+
"""
|
|
13
|
+
Serialize an object to UTF-8 encoded JSON bytes.
|
|
14
|
+
|
|
15
|
+
Extends the standard json.dumps with support for additional types
|
|
16
|
+
commonly used in the SDK, such as `datetime`, `pydantic.BaseModel`, etc.
|
|
17
|
+
"""
|
|
18
|
+
return json.dumps(
|
|
19
|
+
obj,
|
|
20
|
+
cls=_CustomEncoder,
|
|
21
|
+
# Uses the same defaults as httpx's JSON serialization
|
|
22
|
+
ensure_ascii=False,
|
|
23
|
+
separators=(",", ":"),
|
|
24
|
+
allow_nan=False,
|
|
25
|
+
).encode()
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
class _CustomEncoder(json.JSONEncoder):
|
|
29
|
+
@override
|
|
30
|
+
def default(self, o: Any) -> Any:
|
|
31
|
+
if isinstance(o, datetime):
|
|
32
|
+
return o.isoformat()
|
|
33
|
+
if isinstance(o, pydantic.BaseModel):
|
|
34
|
+
return model_dump(o, exclude_unset=True, mode="json", by_alias=True)
|
|
35
|
+
return super().default(o)
|
|
@@ -143,7 +143,7 @@ class AccountsResource(SyncAPIResource):
|
|
|
143
143
|
*,
|
|
144
144
|
page: int,
|
|
145
145
|
page_size: int,
|
|
146
|
-
sort: Literal["price_asc", "price_desc", "name_asc", "name_desc"],
|
|
146
|
+
sort: Literal["price_asc", "price_desc", "name_asc", "name_desc", "popularity_asc", "popularity_desc"],
|
|
147
147
|
country_codes: str | Omit = omit,
|
|
148
148
|
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
149
149
|
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
@@ -313,7 +313,7 @@ class AsyncAccountsResource(AsyncAPIResource):
|
|
|
313
313
|
*,
|
|
314
314
|
page: int,
|
|
315
315
|
page_size: int,
|
|
316
|
-
sort: Literal["price_asc", "price_desc", "name_asc", "name_desc"],
|
|
316
|
+
sort: Literal["price_asc", "price_desc", "name_asc", "name_desc", "popularity_asc", "popularity_desc"],
|
|
317
317
|
country_codes: str | Omit = omit,
|
|
318
318
|
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
319
319
|
# The extra values given here take precedence over values defined on the client or passed to this method.
|
{gmt_python_sdk-0.12.0 → gmt_python_sdk-0.14.0}/src/gmt/types/account_list_countries_params.py
RENAMED
|
@@ -14,7 +14,7 @@ class AccountListCountriesParams(TypedDict, total=False):
|
|
|
14
14
|
page_size: Required[int]
|
|
15
15
|
"""Number of items per page."""
|
|
16
16
|
|
|
17
|
-
sort: Required[Literal["price_asc", "price_desc", "name_asc", "name_desc"]]
|
|
17
|
+
sort: Required[Literal["price_asc", "price_desc", "name_asc", "name_desc", "popularity_asc", "popularity_desc"]]
|
|
18
18
|
"""Sort order for accounts."""
|
|
19
19
|
|
|
20
20
|
country_codes: str
|
|
@@ -77,6 +77,9 @@ class Statistics(BaseModel):
|
|
|
77
77
|
class ProfileRetrieveResponse(BaseModel):
|
|
78
78
|
"""Successful response."""
|
|
79
79
|
|
|
80
|
+
id: str
|
|
81
|
+
"""User Database ID"""
|
|
82
|
+
|
|
80
83
|
balance: Balance
|
|
81
84
|
|
|
82
85
|
created_at: str
|
|
@@ -84,12 +87,15 @@ class ProfileRetrieveResponse(BaseModel):
|
|
|
84
87
|
|
|
85
88
|
discount: Discount
|
|
86
89
|
|
|
90
|
+
login: Optional[str] = None
|
|
91
|
+
"""Web username"""
|
|
92
|
+
|
|
87
93
|
referral: Referral
|
|
88
94
|
|
|
89
95
|
statistics: Statistics
|
|
90
96
|
|
|
91
|
-
telegram_id: str
|
|
92
|
-
"""User's Telegram ID"""
|
|
97
|
+
telegram_id: Optional[str] = None
|
|
98
|
+
"""User's Telegram ID (null for web-only users)"""
|
|
93
99
|
|
|
94
100
|
telegram_username: Optional[str] = None
|
|
95
101
|
"""User's Telegram username"""
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import datetime
|
|
4
|
+
from typing import Union
|
|
5
|
+
|
|
6
|
+
import pydantic
|
|
7
|
+
|
|
8
|
+
from gmt import _compat
|
|
9
|
+
from gmt._utils._json import openapi_dumps
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
class TestOpenapiDumps:
|
|
13
|
+
def test_basic(self) -> None:
|
|
14
|
+
data = {"key": "value", "number": 42}
|
|
15
|
+
json_bytes = openapi_dumps(data)
|
|
16
|
+
assert json_bytes == b'{"key":"value","number":42}'
|
|
17
|
+
|
|
18
|
+
def test_datetime_serialization(self) -> None:
|
|
19
|
+
dt = datetime.datetime(2023, 1, 1, 12, 0, 0)
|
|
20
|
+
data = {"datetime": dt}
|
|
21
|
+
json_bytes = openapi_dumps(data)
|
|
22
|
+
assert json_bytes == b'{"datetime":"2023-01-01T12:00:00"}'
|
|
23
|
+
|
|
24
|
+
def test_pydantic_model_serialization(self) -> None:
|
|
25
|
+
class User(pydantic.BaseModel):
|
|
26
|
+
first_name: str
|
|
27
|
+
last_name: str
|
|
28
|
+
age: int
|
|
29
|
+
|
|
30
|
+
model_instance = User(first_name="John", last_name="Kramer", age=83)
|
|
31
|
+
data = {"model": model_instance}
|
|
32
|
+
json_bytes = openapi_dumps(data)
|
|
33
|
+
assert json_bytes == b'{"model":{"first_name":"John","last_name":"Kramer","age":83}}'
|
|
34
|
+
|
|
35
|
+
def test_pydantic_model_with_default_values(self) -> None:
|
|
36
|
+
class User(pydantic.BaseModel):
|
|
37
|
+
name: str
|
|
38
|
+
role: str = "user"
|
|
39
|
+
active: bool = True
|
|
40
|
+
score: int = 0
|
|
41
|
+
|
|
42
|
+
model_instance = User(name="Alice")
|
|
43
|
+
data = {"model": model_instance}
|
|
44
|
+
json_bytes = openapi_dumps(data)
|
|
45
|
+
assert json_bytes == b'{"model":{"name":"Alice"}}'
|
|
46
|
+
|
|
47
|
+
def test_pydantic_model_with_default_values_overridden(self) -> None:
|
|
48
|
+
class User(pydantic.BaseModel):
|
|
49
|
+
name: str
|
|
50
|
+
role: str = "user"
|
|
51
|
+
active: bool = True
|
|
52
|
+
|
|
53
|
+
model_instance = User(name="Bob", role="admin", active=False)
|
|
54
|
+
data = {"model": model_instance}
|
|
55
|
+
json_bytes = openapi_dumps(data)
|
|
56
|
+
assert json_bytes == b'{"model":{"name":"Bob","role":"admin","active":false}}'
|
|
57
|
+
|
|
58
|
+
def test_pydantic_model_with_alias(self) -> None:
|
|
59
|
+
class User(pydantic.BaseModel):
|
|
60
|
+
first_name: str = pydantic.Field(alias="firstName")
|
|
61
|
+
last_name: str = pydantic.Field(alias="lastName")
|
|
62
|
+
|
|
63
|
+
model_instance = User(firstName="John", lastName="Doe")
|
|
64
|
+
data = {"model": model_instance}
|
|
65
|
+
json_bytes = openapi_dumps(data)
|
|
66
|
+
assert json_bytes == b'{"model":{"firstName":"John","lastName":"Doe"}}'
|
|
67
|
+
|
|
68
|
+
def test_pydantic_model_with_alias_and_default(self) -> None:
|
|
69
|
+
class User(pydantic.BaseModel):
|
|
70
|
+
user_name: str = pydantic.Field(alias="userName")
|
|
71
|
+
user_role: str = pydantic.Field(default="member", alias="userRole")
|
|
72
|
+
is_active: bool = pydantic.Field(default=True, alias="isActive")
|
|
73
|
+
|
|
74
|
+
model_instance = User(userName="charlie")
|
|
75
|
+
data = {"model": model_instance}
|
|
76
|
+
json_bytes = openapi_dumps(data)
|
|
77
|
+
assert json_bytes == b'{"model":{"userName":"charlie"}}'
|
|
78
|
+
|
|
79
|
+
model_with_overrides = User(userName="diana", userRole="admin", isActive=False)
|
|
80
|
+
data = {"model": model_with_overrides}
|
|
81
|
+
json_bytes = openapi_dumps(data)
|
|
82
|
+
assert json_bytes == b'{"model":{"userName":"diana","userRole":"admin","isActive":false}}'
|
|
83
|
+
|
|
84
|
+
def test_pydantic_model_with_nested_models_and_defaults(self) -> None:
|
|
85
|
+
class Address(pydantic.BaseModel):
|
|
86
|
+
street: str
|
|
87
|
+
city: str = "Unknown"
|
|
88
|
+
|
|
89
|
+
class User(pydantic.BaseModel):
|
|
90
|
+
name: str
|
|
91
|
+
address: Address
|
|
92
|
+
verified: bool = False
|
|
93
|
+
|
|
94
|
+
if _compat.PYDANTIC_V1:
|
|
95
|
+
# to handle forward references in Pydantic v1
|
|
96
|
+
User.update_forward_refs(**locals()) # type: ignore[reportDeprecated]
|
|
97
|
+
|
|
98
|
+
address = Address(street="123 Main St")
|
|
99
|
+
user = User(name="Diana", address=address)
|
|
100
|
+
data = {"user": user}
|
|
101
|
+
json_bytes = openapi_dumps(data)
|
|
102
|
+
assert json_bytes == b'{"user":{"name":"Diana","address":{"street":"123 Main St"}}}'
|
|
103
|
+
|
|
104
|
+
address_with_city = Address(street="456 Oak Ave", city="Boston")
|
|
105
|
+
user_verified = User(name="Eve", address=address_with_city, verified=True)
|
|
106
|
+
data = {"user": user_verified}
|
|
107
|
+
json_bytes = openapi_dumps(data)
|
|
108
|
+
assert (
|
|
109
|
+
json_bytes == b'{"user":{"name":"Eve","address":{"street":"456 Oak Ave","city":"Boston"},"verified":true}}'
|
|
110
|
+
)
|
|
111
|
+
|
|
112
|
+
def test_pydantic_model_with_optional_fields(self) -> None:
|
|
113
|
+
class User(pydantic.BaseModel):
|
|
114
|
+
name: str
|
|
115
|
+
email: Union[str, None]
|
|
116
|
+
phone: Union[str, None]
|
|
117
|
+
|
|
118
|
+
model_with_none = User(name="Eve", email=None, phone=None)
|
|
119
|
+
data = {"model": model_with_none}
|
|
120
|
+
json_bytes = openapi_dumps(data)
|
|
121
|
+
assert json_bytes == b'{"model":{"name":"Eve","email":null,"phone":null}}'
|
|
122
|
+
|
|
123
|
+
model_with_values = User(name="Frank", email="frank@example.com", phone=None)
|
|
124
|
+
data = {"model": model_with_values}
|
|
125
|
+
json_bytes = openapi_dumps(data)
|
|
126
|
+
assert json_bytes == b'{"model":{"name":"Frank","email":"frank@example.com","phone":null}}'
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{gmt_python_sdk-0.12.0 → gmt_python_sdk-0.14.0}/src/gmt/types/account_list_countries_response.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{gmt_python_sdk-0.12.0 → gmt_python_sdk-0.14.0}/src/gmt/types/service_get_server_time_response.py
RENAMED
|
File without changes
|
{gmt_python_sdk-0.12.0 → gmt_python_sdk-0.14.0}/src/gmt/types/service_health_check_response.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|