Skip to content

Commit 6ad2589

Browse files
committed
Some updates and improvements
1 parent e1443a4 commit 6ad2589

File tree

8 files changed

+325
-75
lines changed

8 files changed

+325
-75
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@
1111
export PYTHOPATH="${PYTHONPATH}:./"
1212
python examples/api_for_tortoise_orm/main.py
1313
```
14-
http://0.0.0.0:8080/docs
14+
http://0.0.0.0:8080/docs

examples/api_for_tortoise_orm/models/pydantic/user.py

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -14,36 +14,33 @@
1414
class UserBaseSchema(BaseModel):
1515
"""User base schema."""
1616

17-
class Config(object):
17+
class Config:
1818
"""Pydantic schema config."""
1919

2020
orm_mode = True
2121

22-
class Enum(object):
22+
class Enum:
2323
"""Device enums."""
2424

2525
status = UserStatusEnum
2626

27-
28-
class UserPatchSchema(UserBaseSchema):
29-
"""User PATCH schema."""
3027
first_name: Optional[str] = None
3128
last_name: Optional[str] = None
3229
status: UserStatusEnum = Field(default=UserStatusEnum.active)
3330

3431

32+
class UserPatchSchema(UserBaseSchema):
33+
"""User PATCH schema."""
34+
35+
3536
class UserInSchema(UserBaseSchema):
3637
"""User input schema."""
3738

38-
first_name: Optional[str] = None
39-
last_name: Optional[str] = None
40-
status: UserStatusEnum = Field(default=UserStatusEnum.active)
41-
4239

4340
class UserSchema(UserInSchema):
4441
"""User item schema."""
4542

46-
class Config(object):
43+
class Config:
4744
"""Pydantic model config."""
4845

4946
orm_mode = True
@@ -52,6 +49,3 @@ class Config(object):
5249
id: int
5350
created_at: datetime = Field(description="Время создания данных")
5451
modified_at: datetime = Field(description="Время изменения данных")
55-
first_name: Optional[str] = None
56-
last_name: Optional[str] = None
57-
status: UserStatusEnum = Field(default=UserStatusEnum.active)

examples/api_for_tortoise_orm/models/tortoise/user.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
"""Device model."""
1+
"""User model."""
22

33

44
from tortoise import (
@@ -15,7 +15,7 @@
1515
class User(models.Model):
1616
"""The device model."""
1717

18-
class Enum(object):
18+
class Enum:
1919
status = UserStatusEnum
2020

2121
id: int = fields.IntField(pk=True)
@@ -25,5 +25,5 @@ class Enum(object):
2525
created_at = fields.DatetimeField(null=True, auto_now_add=True)
2626
modified_at = fields.DatetimeField(null=True, auto_now=True)
2727

28-
class Meta(object):
28+
class Meta:
2929
table = "users"

fastapi_rest_jsonapi/data_layers/filter/filters_cacher.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
)
1212

1313

14-
class FiltersCacher(object):
14+
class FiltersCacher:
1515
"""Filter cacher."""
1616

1717
def __init__(

fastapi_rest_jsonapi/data_layers/filter/preparing.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@ def prepare_filter_event(field: Type[ModelField], field_name: str, type_op: str,
3737
"""
3838
if field.type_ == int and type_op not in set(IntSchema.__fields__["operation"].default):
3939
raise InvalidFilters(
40-
'Operation "{type_op}" is not permitted for type "INT"'.format(type_op=type_op), parameter=field_name
40+
'Operation "{type_op}" is not permitted for type "INT"'.format(type_op=type_op),
41+
parameter=field_name,
4142
)
4243
if field.type_ == float and type_op not in set(FloatSchema.__fields__["operation"].default):
4344
raise InvalidFilters(

fastapi_rest_jsonapi/openapi.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,10 @@ def openapi() -> Dict[Any, Any]:
2323
description="",
2424
routes=app.routes,
2525
)
26-
openapi_schema["info"]["x-logo"] = {
27-
"url": "https://static.ssl.mts.ru/mts_rf/static/20201102.1/Styles/Promo/i/header/logo.svg"
28-
}
26+
# картинка по адресу недоступна
27+
# openapi_schema["info"]["x-logo"] = {
28+
# "url": "https://static.ssl.mts.ru/mts_rf/static/20201102.1/Styles/Promo/i/header/logo.svg",
29+
# }
2930
app.openapi_schema = openapi_schema
3031
return app.openapi_schema
3132

fastapi_rest_jsonapi/querystring.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,7 @@ def include(self) -> List[str]:
266266
include_param: str = self.qs.get("include", "")
267267

268268
if self.MAX_INCLUDE_DEPTH is not None:
269+
# TODO: does this really work? needs tests!
269270
for include_path in include_param:
270271
if len(include_path.split(SPLIT_REL)) > self.MAX_INCLUDE_DEPTH:
271272
raise InvalidInclude(

0 commit comments

Comments
 (0)