apexdevkit 1.6.3__tar.gz → 1.6.5__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.
- {apexdevkit-1.6.3 → apexdevkit-1.6.5}/PKG-INFO +1 -1
- {apexdevkit-1.6.3 → apexdevkit-1.6.5}/apexdevkit/error.py +6 -0
- {apexdevkit-1.6.3 → apexdevkit-1.6.5}/apexdevkit/fastapi/builder.py +6 -0
- {apexdevkit-1.6.3 → apexdevkit-1.6.5}/apexdevkit/fastapi/dependable.py +9 -2
- {apexdevkit-1.6.3 → apexdevkit-1.6.5}/apexdevkit/fastapi/router.py +2 -1
- {apexdevkit-1.6.3 → apexdevkit-1.6.5}/pyproject.toml +1 -1
- {apexdevkit-1.6.3 → apexdevkit-1.6.5}/LICENSE +0 -0
- {apexdevkit-1.6.3 → apexdevkit-1.6.5}/README.md +0 -0
- {apexdevkit-1.6.3 → apexdevkit-1.6.5}/apexdevkit/__init__.py +0 -0
- {apexdevkit-1.6.3 → apexdevkit-1.6.5}/apexdevkit/annotation/__init__.py +0 -0
- {apexdevkit-1.6.3 → apexdevkit-1.6.5}/apexdevkit/annotation/deprecate.py +0 -0
- {apexdevkit-1.6.3 → apexdevkit-1.6.5}/apexdevkit/fastapi/__init__.py +0 -0
- {apexdevkit-1.6.3 → apexdevkit-1.6.5}/apexdevkit/fastapi/docs.py +0 -0
- {apexdevkit-1.6.3 → apexdevkit-1.6.5}/apexdevkit/fastapi/resource.py +0 -0
- {apexdevkit-1.6.3 → apexdevkit-1.6.5}/apexdevkit/fastapi/response.py +0 -0
- {apexdevkit-1.6.3 → apexdevkit-1.6.5}/apexdevkit/fastapi/schema.py +0 -0
- {apexdevkit-1.6.3 → apexdevkit-1.6.5}/apexdevkit/fastapi/service.py +0 -0
- {apexdevkit-1.6.3 → apexdevkit-1.6.5}/apexdevkit/formatter.py +0 -0
- {apexdevkit-1.6.3 → apexdevkit-1.6.5}/apexdevkit/http/__init__.py +0 -0
- {apexdevkit-1.6.3 → apexdevkit-1.6.5}/apexdevkit/http/fake.py +0 -0
- {apexdevkit-1.6.3 → apexdevkit-1.6.5}/apexdevkit/http/fluent.py +0 -0
- {apexdevkit-1.6.3 → apexdevkit-1.6.5}/apexdevkit/http/httpx.py +0 -0
- {apexdevkit-1.6.3 → apexdevkit-1.6.5}/apexdevkit/http/json.py +0 -0
- {apexdevkit-1.6.3 → apexdevkit-1.6.5}/apexdevkit/http/url.py +0 -0
- {apexdevkit-1.6.3 → apexdevkit-1.6.5}/apexdevkit/py.typed +0 -0
- {apexdevkit-1.6.3 → apexdevkit-1.6.5}/apexdevkit/repository/__init__.py +0 -0
- {apexdevkit-1.6.3 → apexdevkit-1.6.5}/apexdevkit/repository/base.py +0 -0
- {apexdevkit-1.6.3 → apexdevkit-1.6.5}/apexdevkit/repository/connector.py +0 -0
- {apexdevkit-1.6.3 → apexdevkit-1.6.5}/apexdevkit/repository/database.py +0 -0
- {apexdevkit-1.6.3 → apexdevkit-1.6.5}/apexdevkit/repository/in_memory.py +0 -0
- {apexdevkit-1.6.3 → apexdevkit-1.6.5}/apexdevkit/repository/interface.py +0 -0
- {apexdevkit-1.6.3 → apexdevkit-1.6.5}/apexdevkit/testing/__init__.py +0 -0
- {apexdevkit-1.6.3 → apexdevkit-1.6.5}/apexdevkit/testing/database.py +0 -0
- {apexdevkit-1.6.3 → apexdevkit-1.6.5}/apexdevkit/testing/fake.py +0 -0
- {apexdevkit-1.6.3 → apexdevkit-1.6.5}/apexdevkit/testing/rest.py +0 -0
|
@@ -3,7 +3,9 @@ from dataclasses import dataclass, field
|
|
|
3
3
|
from typing import Any, Self
|
|
4
4
|
|
|
5
5
|
from fastapi import APIRouter, FastAPI
|
|
6
|
+
from starlette.responses import JSONResponse
|
|
6
7
|
|
|
8
|
+
from apexdevkit.error import ApiError
|
|
7
9
|
from apexdevkit.fastapi.service import RestfulService
|
|
8
10
|
|
|
9
11
|
|
|
@@ -12,6 +14,10 @@ class FastApiBuilder:
|
|
|
12
14
|
app: FastAPI = field(default_factory=FastAPI)
|
|
13
15
|
|
|
14
16
|
def build(self) -> FastAPI:
|
|
17
|
+
self.app.add_exception_handler(
|
|
18
|
+
ApiError,
|
|
19
|
+
lambda request, exc: JSONResponse(content=exc.data, status_code=exc.code),
|
|
20
|
+
)
|
|
15
21
|
return self.app
|
|
16
22
|
|
|
17
23
|
def with_title(self, value: str) -> Self:
|
|
@@ -4,7 +4,9 @@ from typing import Annotated, Any, Callable, Protocol, Self
|
|
|
4
4
|
from fastapi import Depends, Path
|
|
5
5
|
from fastapi.requests import Request
|
|
6
6
|
|
|
7
|
+
from apexdevkit.error import ApiError, DoesNotExistError
|
|
7
8
|
from apexdevkit.fastapi import RestfulServiceBuilder
|
|
9
|
+
from apexdevkit.fastapi.response import RestfulResponse
|
|
8
10
|
from apexdevkit.fastapi.service import RestfulService
|
|
9
11
|
from apexdevkit.testing import RestfulName
|
|
10
12
|
|
|
@@ -41,10 +43,15 @@ class ParentDependency:
|
|
|
41
43
|
|
|
42
44
|
def as_dependable(self) -> type[RestfulServiceBuilder]:
|
|
43
45
|
Builder = self.dependency.as_dependable()
|
|
44
|
-
ParentId = Annotated[
|
|
46
|
+
ParentId = Annotated[
|
|
47
|
+
str, Path(alias=self.parent.singular.replace("-", "_") + "_id")
|
|
48
|
+
]
|
|
45
49
|
|
|
46
50
|
def _(builder: Builder, parent_id: ParentId) -> RestfulServiceBuilder:
|
|
47
|
-
|
|
51
|
+
try:
|
|
52
|
+
return builder.with_parent(parent_id)
|
|
53
|
+
except DoesNotExistError as e:
|
|
54
|
+
raise ApiError(404, RestfulResponse(self.parent).not_found(e))
|
|
48
55
|
|
|
49
56
|
return Annotated[RestfulServiceBuilder, Depends(_)]
|
|
50
57
|
|
|
@@ -46,7 +46,7 @@ class RestfulRouter:
|
|
|
46
46
|
|
|
47
47
|
@property
|
|
48
48
|
def id_alias(self) -> str:
|
|
49
|
-
return self.name.singular + "_id"
|
|
49
|
+
return self.name.singular.replace("-", "_") + "_id"
|
|
50
50
|
|
|
51
51
|
@property
|
|
52
52
|
def item_path(self) -> str:
|
|
@@ -264,6 +264,7 @@ class RestfulRouter:
|
|
|
264
264
|
|
|
265
265
|
def with_sub_resource(self, **names: APIRouter) -> Self:
|
|
266
266
|
for name, router in names.items():
|
|
267
|
+
print(self.item_path)
|
|
267
268
|
self.router.include_router(router, prefix=f"{self.item_path}/{name}")
|
|
268
269
|
|
|
269
270
|
return self
|
|
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
|