apexdevkit 1.17.3__tar.gz → 1.17.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.17.3 → apexdevkit-1.17.5}/PKG-INFO +1 -1
- {apexdevkit-1.17.3 → apexdevkit-1.17.5}/apexdevkit/fastapi/schema.py +17 -7
- {apexdevkit-1.17.3 → apexdevkit-1.17.5}/apexdevkit/formatter.py +28 -7
- {apexdevkit-1.17.3 → apexdevkit-1.17.5}/pyproject.toml +1 -1
- {apexdevkit-1.17.3 → apexdevkit-1.17.5}/LICENSE +0 -0
- {apexdevkit-1.17.3 → apexdevkit-1.17.5}/README.md +0 -0
- {apexdevkit-1.17.3 → apexdevkit-1.17.5}/apexdevkit/__init__.py +0 -0
- {apexdevkit-1.17.3 → apexdevkit-1.17.5}/apexdevkit/annotation/__init__.py +0 -0
- {apexdevkit-1.17.3 → apexdevkit-1.17.5}/apexdevkit/annotation/deprecate.py +0 -0
- {apexdevkit-1.17.3 → apexdevkit-1.17.5}/apexdevkit/environment.py +0 -0
- {apexdevkit-1.17.3 → apexdevkit-1.17.5}/apexdevkit/error.py +0 -0
- {apexdevkit-1.17.3 → apexdevkit-1.17.5}/apexdevkit/fastapi/__init__.py +0 -0
- {apexdevkit-1.17.3 → apexdevkit-1.17.5}/apexdevkit/fastapi/builder.py +0 -0
- {apexdevkit-1.17.3 → apexdevkit-1.17.5}/apexdevkit/fastapi/dependable.py +0 -0
- {apexdevkit-1.17.3 → apexdevkit-1.17.5}/apexdevkit/fastapi/docs.py +0 -0
- {apexdevkit-1.17.3 → apexdevkit-1.17.5}/apexdevkit/fastapi/name.py +0 -0
- {apexdevkit-1.17.3 → apexdevkit-1.17.5}/apexdevkit/fastapi/request.py +0 -0
- {apexdevkit-1.17.3 → apexdevkit-1.17.5}/apexdevkit/fastapi/resource.py +0 -0
- {apexdevkit-1.17.3 → apexdevkit-1.17.5}/apexdevkit/fastapi/response.py +0 -0
- {apexdevkit-1.17.3 → apexdevkit-1.17.5}/apexdevkit/fastapi/router.py +0 -0
- {apexdevkit-1.17.3 → apexdevkit-1.17.5}/apexdevkit/fastapi/service.py +0 -0
- {apexdevkit-1.17.3 → apexdevkit-1.17.5}/apexdevkit/fluent.py +0 -0
- {apexdevkit-1.17.3 → apexdevkit-1.17.5}/apexdevkit/http/__init__.py +0 -0
- {apexdevkit-1.17.3 → apexdevkit-1.17.5}/apexdevkit/http/fake.py +0 -0
- {apexdevkit-1.17.3 → apexdevkit-1.17.5}/apexdevkit/http/fluent.py +0 -0
- {apexdevkit-1.17.3 → apexdevkit-1.17.5}/apexdevkit/http/httpx.py +0 -0
- {apexdevkit-1.17.3 → apexdevkit-1.17.5}/apexdevkit/http/json.py +0 -0
- {apexdevkit-1.17.3 → apexdevkit-1.17.5}/apexdevkit/http/url.py +0 -0
- {apexdevkit-1.17.3 → apexdevkit-1.17.5}/apexdevkit/key_fn.py +0 -0
- {apexdevkit-1.17.3 → apexdevkit-1.17.5}/apexdevkit/py.typed +0 -0
- {apexdevkit-1.17.3 → apexdevkit-1.17.5}/apexdevkit/repository/__init__.py +0 -0
- {apexdevkit-1.17.3 → apexdevkit-1.17.5}/apexdevkit/repository/base.py +0 -0
- {apexdevkit-1.17.3 → apexdevkit-1.17.5}/apexdevkit/repository/connector.py +0 -0
- {apexdevkit-1.17.3 → apexdevkit-1.17.5}/apexdevkit/repository/database.py +0 -0
- {apexdevkit-1.17.3 → apexdevkit-1.17.5}/apexdevkit/repository/decorator.py +0 -0
- {apexdevkit-1.17.3 → apexdevkit-1.17.5}/apexdevkit/repository/in_memory.py +0 -0
- {apexdevkit-1.17.3 → apexdevkit-1.17.5}/apexdevkit/repository/interface.py +0 -0
- {apexdevkit-1.17.3 → apexdevkit-1.17.5}/apexdevkit/repository/mongo.py +0 -0
- {apexdevkit-1.17.3 → apexdevkit-1.17.5}/apexdevkit/repository/mssql.py +0 -0
- {apexdevkit-1.17.3 → apexdevkit-1.17.5}/apexdevkit/repository/sqlite.py +0 -0
- {apexdevkit-1.17.3 → apexdevkit-1.17.5}/apexdevkit/server.py +0 -0
- {apexdevkit-1.17.3 → apexdevkit-1.17.5}/apexdevkit/synchronization.py +0 -0
- {apexdevkit-1.17.3 → apexdevkit-1.17.5}/apexdevkit/testing/__init__.py +0 -0
- {apexdevkit-1.17.3 → apexdevkit-1.17.5}/apexdevkit/testing/database.py +0 -0
- {apexdevkit-1.17.3 → apexdevkit-1.17.5}/apexdevkit/testing/fake.py +0 -0
- {apexdevkit-1.17.3 → apexdevkit-1.17.5}/apexdevkit/testing/rest.py +0 -0
- {apexdevkit-1.17.3 → apexdevkit-1.17.5}/apexdevkit/value.py +0 -0
|
@@ -135,13 +135,7 @@ class Schema:
|
|
|
135
135
|
name: RestfulName
|
|
136
136
|
|
|
137
137
|
def schema_for(self, action: str, fields: dict[str, Any]) -> type[BaseModel]:
|
|
138
|
-
return
|
|
139
|
-
self.name.singular.capitalize() + action,
|
|
140
|
-
**{
|
|
141
|
-
field_name: (field_type, ...)
|
|
142
|
-
for field_name, field_type in fields.items()
|
|
143
|
-
},
|
|
144
|
-
)
|
|
138
|
+
return self._nested_schema_for(self.name.singular.capitalize() + action, fields)
|
|
145
139
|
|
|
146
140
|
def optional_schema_for(
|
|
147
141
|
self, action: str, fields: dict[str, Any]
|
|
@@ -153,3 +147,19 @@ class Schema:
|
|
|
153
147
|
for field_name, field_type in fields.items()
|
|
154
148
|
},
|
|
155
149
|
)
|
|
150
|
+
|
|
151
|
+
def _nested_schema_for(self, name: str, fields: dict[str, Any]) -> type[BaseModel]:
|
|
152
|
+
model_fields = {}
|
|
153
|
+
|
|
154
|
+
for field_name, field_type in fields.items():
|
|
155
|
+
if isinstance(field_type, dict):
|
|
156
|
+
model_fields[field_name] = (
|
|
157
|
+
self._nested_schema_for(
|
|
158
|
+
name.capitalize() + field_name.capitalize(), field_type
|
|
159
|
+
),
|
|
160
|
+
...,
|
|
161
|
+
)
|
|
162
|
+
else:
|
|
163
|
+
model_fields[field_name] = (field_type, ...)
|
|
164
|
+
|
|
165
|
+
return create_model(name, **model_fields)
|
|
@@ -2,9 +2,12 @@ from __future__ import annotations
|
|
|
2
2
|
|
|
3
3
|
import pickle
|
|
4
4
|
from copy import deepcopy
|
|
5
|
-
from dataclasses import asdict, dataclass, field
|
|
6
|
-
from typing import Any, Generic, Protocol, Self, TypeVar
|
|
5
|
+
from dataclasses import asdict, dataclass, field, fields, is_dataclass
|
|
6
|
+
from typing import Any, Generic, Protocol, Self, TypeVar, get_args
|
|
7
7
|
|
|
8
|
+
from typing_extensions import get_type_hints
|
|
9
|
+
|
|
10
|
+
from apexdevkit.fluent import FluentDict
|
|
8
11
|
from apexdevkit.value import Value
|
|
9
12
|
|
|
10
13
|
_SourceT = TypeVar("_SourceT")
|
|
@@ -53,11 +56,29 @@ class DataclassFormatter(Generic[_TargetT]):
|
|
|
53
56
|
return self
|
|
54
57
|
|
|
55
58
|
def load(self, raw: dict[str, Any]) -> _TargetT:
|
|
56
|
-
raw = deepcopy(raw)
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
59
|
+
raw = FluentDict[Any](deepcopy(raw)).select(
|
|
60
|
+
*self.resource.__annotations__.keys()
|
|
61
|
+
)
|
|
62
|
+
|
|
63
|
+
for key in fields(self.resource): # type: ignore
|
|
64
|
+
types = get_type_hints(self.resource)
|
|
65
|
+
key_type = types[key.name]
|
|
66
|
+
if key.name not in raw:
|
|
67
|
+
continue
|
|
68
|
+
elif key.name in self.sub_formatters.keys():
|
|
69
|
+
raw[key.name] = (
|
|
70
|
+
self.sub_formatters[key.name].load(raw.pop(key.name))
|
|
71
|
+
if raw[key.name]
|
|
72
|
+
else raw[key.name]
|
|
73
|
+
)
|
|
74
|
+
elif is_dataclass(key_type):
|
|
75
|
+
raw[key.name] = DataclassFormatter(key_type).load(raw[key.name]) # type: ignore
|
|
76
|
+
else:
|
|
77
|
+
args = get_args(key_type)
|
|
78
|
+
if len(args) == 1 and is_dataclass(args[0]):
|
|
79
|
+
raw[key.name] = ListFormatter(DataclassFormatter(args[0])).load( # type: ignore
|
|
80
|
+
raw[key.name]
|
|
81
|
+
)
|
|
61
82
|
|
|
62
83
|
return self.resource(**raw)
|
|
63
84
|
|
|
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
|