fastapi-extra 0.2.1__cp312-cp312-win_amd64.whl → 0.2.3__cp312-cp312-win_amd64.whl
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.
- fastapi_extra/__init__.py +1 -1
- fastapi_extra/cursor.cp312-win_amd64.pyd +0 -0
- fastapi_extra/database/service.py +2 -2
- fastapi_extra/native/routing.pyx +0 -1
- fastapi_extra/response.py +22 -4
- fastapi_extra/routing.cp312-win_amd64.pyd +0 -0
- fastapi_extra/routing.pyi +1 -1
- {fastapi_extra-0.2.1.dist-info → fastapi_extra-0.2.3.dist-info}/METADATA +1 -1
- {fastapi_extra-0.2.1.dist-info → fastapi_extra-0.2.3.dist-info}/RECORD +12 -12
- {fastapi_extra-0.2.1.dist-info → fastapi_extra-0.2.3.dist-info}/WHEEL +0 -0
- {fastapi_extra-0.2.1.dist-info → fastapi_extra-0.2.3.dist-info}/licenses/LICENSE +0 -0
- {fastapi_extra-0.2.1.dist-info → fastapi_extra-0.2.3.dist-info}/top_level.txt +0 -0
fastapi_extra/__init__.py
CHANGED
|
Binary file
|
|
@@ -5,7 +5,7 @@ from contextvars import ContextVar
|
|
|
5
5
|
from typing import Any, Generic, Self, TypeVar
|
|
6
6
|
|
|
7
7
|
from fastapi_extra.database.model import SQLModel
|
|
8
|
-
from fastapi_extra.database.session import DefaultSession
|
|
8
|
+
from fastapi_extra.database.session import AsyncSession, DefaultSession
|
|
9
9
|
from fastapi_extra.dependency import AbstractService
|
|
10
10
|
|
|
11
11
|
Model = TypeVar("Model", bound=SQLModel)
|
|
@@ -32,7 +32,7 @@ class ModelService(AbstractService, Generic[Model], abstract=True):
|
|
|
32
32
|
self.__session_container__.set(session)
|
|
33
33
|
|
|
34
34
|
@property
|
|
35
|
-
def session(self):
|
|
35
|
+
def session(self) -> AsyncSession:
|
|
36
36
|
_session = self.__session_container__.get()
|
|
37
37
|
assert _session is not None, "Session is not initialized"
|
|
38
38
|
return _session
|
fastapi_extra/native/routing.pyx
CHANGED
fastapi_extra/response.py
CHANGED
|
@@ -3,8 +3,9 @@ __date__ = "2024-12-24"
|
|
|
3
3
|
|
|
4
4
|
|
|
5
5
|
from enum import Enum
|
|
6
|
-
from typing import Generic
|
|
6
|
+
from typing import TYPE_CHECKING, Generic
|
|
7
7
|
|
|
8
|
+
from fastapi.responses import JSONResponse
|
|
8
9
|
from pydantic import BaseModel, Field
|
|
9
10
|
|
|
10
11
|
from fastapi_extra.types import T
|
|
@@ -193,9 +194,26 @@ class ResultEnum(Enum):
|
|
|
193
194
|
class APIResult(BaseModel, Generic[T]):
|
|
194
195
|
data: T | None = Field(default=None, title="返回数据")
|
|
195
196
|
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
197
|
+
if TYPE_CHECKING:
|
|
198
|
+
@classmethod
|
|
199
|
+
def ok(cls, data: T | None = None) -> "APIResult[T]":
|
|
200
|
+
return APIResult(data=data)
|
|
201
|
+
else:
|
|
202
|
+
@classmethod
|
|
203
|
+
def ok(cls, data: T | None = None) -> "APIResponse":
|
|
204
|
+
return APIResponse(APIResult(data=data))
|
|
205
|
+
|
|
206
|
+
|
|
207
|
+
class APIResponse(JSONResponse):
|
|
208
|
+
|
|
209
|
+
def render(self, content: APIResult) -> bytes:
|
|
210
|
+
return content.__pydantic_serializer__.to_json(
|
|
211
|
+
indent=None,
|
|
212
|
+
by_alias=True,
|
|
213
|
+
exclude_defaults=False,
|
|
214
|
+
exclude_none=False,
|
|
215
|
+
exclude_unset=False
|
|
216
|
+
)
|
|
199
217
|
|
|
200
218
|
|
|
201
219
|
class APIError(Exception):
|
|
Binary file
|
fastapi_extra/routing.pyi
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
fastapi_extra/__init__.py,sha256=
|
|
2
|
-
fastapi_extra/cursor.cp312-win_amd64.pyd,sha256=
|
|
1
|
+
fastapi_extra/__init__.py,sha256=R03bRZYl4AVdbnAFZ3g-AlNlR6fvByDmK7lqJuApDgI,286
|
|
2
|
+
fastapi_extra/cursor.cp312-win_amd64.pyd,sha256=cmeCdfqVMua1kmwFAMUjlWPeC28fQbmJneNcjaUz2bI,53760
|
|
3
3
|
fastapi_extra/cursor.pyi,sha256=t1_ub-dRhu3OcXB_dIw5MdBG9r1n7853Vtgzc6bk6dw,115
|
|
4
4
|
fastapi_extra/dependency.py,sha256=LtYnOTMyhOQUFSbNEViw7lxJvAFpPWbyuY4e2goSG-8,2130
|
|
5
5
|
fastapi_extra/form.py,sha256=Fs9uEDOQThjFroDVTrjWnIGJ107BgXCppIVTymwQLzg,1247
|
|
6
6
|
fastapi_extra/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
7
|
-
fastapi_extra/response.py,sha256=
|
|
8
|
-
fastapi_extra/routing.cp312-win_amd64.pyd,sha256=
|
|
9
|
-
fastapi_extra/routing.pyi,sha256=
|
|
7
|
+
fastapi_extra/response.py,sha256=9rSoFDjLGBQTXrKrLuiX0rlaGSxR7YAFVlGKDc4Q9S8,10173
|
|
8
|
+
fastapi_extra/routing.cp312-win_amd64.pyd,sha256=L92GqIq7WQdzcSJfJt9qsdGt4mrHQ1hMj1adPj_vwRY,91648
|
|
9
|
+
fastapi_extra/routing.pyi,sha256=pW9O3noU4F-7l7LLViTVBLgzY468JS0jO96vdfL7CPA,243
|
|
10
10
|
fastapi_extra/settings.py,sha256=cCcwaper5GiNNoT4gNKqf-iloSOTNnMsiUR0knJx4Mw,1461
|
|
11
11
|
fastapi_extra/types.py,sha256=3z6gUnao6WZL76asZYmex20xfY9mvYA-RbnsxUcui30,819
|
|
12
12
|
fastapi_extra/utils.py,sha256=tsPX3kpF_P5D9Bd3gnlG6rkVsLkv5gbxjml-s6ZL_6I,346
|
|
@@ -14,12 +14,12 @@ fastapi_extra/cache/__init__.py,sha256=kq4b_AYKCSJ0fEp4rqpeaoNJilko4XbtfC81xzUaY
|
|
|
14
14
|
fastapi_extra/cache/redis.py,sha256=-hr2DRkmruzH4cIArdjsytqRiiWWtDJt9GIDy38wmtQ,1600
|
|
15
15
|
fastapi_extra/database/__init__.py,sha256=pCYUoEylTponWqpR0AXJHcRo_cs4fnEXVVV9B5J9rt0,384
|
|
16
16
|
fastapi_extra/database/model.py,sha256=2lDi9PQ5F0PSM7BGZozZf1wSefpXnTWqAVzEyGPaXRI,2453
|
|
17
|
-
fastapi_extra/database/service.py,sha256
|
|
17
|
+
fastapi_extra/database/service.py,sha256=V5ojRpiWs9_B3XVQz-PtyvBePfmByTn8WG2gXwuhpO0,1828
|
|
18
18
|
fastapi_extra/database/session.py,sha256=PALArHhXNS2gCgeMkiKjyatvINV_VW1LjgEIwXDKyfQ,1903
|
|
19
19
|
fastapi_extra/native/cursor.pyx,sha256=GchJIPY6e5scuyl1BbA-Et0CdRcHOI3xgsTvDem0B70,1141
|
|
20
|
-
fastapi_extra/native/routing.pyx,sha256=
|
|
21
|
-
fastapi_extra-0.2.
|
|
22
|
-
fastapi_extra-0.2.
|
|
23
|
-
fastapi_extra-0.2.
|
|
24
|
-
fastapi_extra-0.2.
|
|
25
|
-
fastapi_extra-0.2.
|
|
20
|
+
fastapi_extra/native/routing.pyx,sha256=NisJ9YaxzceDVWJnF3EeVXWT8rv_6WRDuIfLEK0eWbc,6233
|
|
21
|
+
fastapi_extra-0.2.3.dist-info/licenses/LICENSE,sha256=0vTjHDa3VDsxTT-R-sH6SpYcA2F1hKtbX9ZFZQm-EcU,1516
|
|
22
|
+
fastapi_extra-0.2.3.dist-info/METADATA,sha256=ncCoVqk0MpEjPC2GE-wHHKhfVvocUbKvjlweKpSbvuY,1371
|
|
23
|
+
fastapi_extra-0.2.3.dist-info/WHEEL,sha256=8UP9x9puWI0P1V_d7K2oMTBqfeLNm21CTzZ_Ptr0NXU,101
|
|
24
|
+
fastapi_extra-0.2.3.dist-info/top_level.txt,sha256=B7D80bEftE2E-eSd1be2r9BWkLLMZN21dRTWpb4y4Ig,14
|
|
25
|
+
fastapi_extra-0.2.3.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|