Skip to content

Commit d16f8d6

Browse files
committed
Some more inheritance updates
1 parent f8d39ea commit d16f8d6

File tree

1 file changed

+19
-15
lines changed

1 file changed

+19
-15
lines changed

fastapi_rest_jsonapi/schema.py

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,53 +1,57 @@
1-
"""Helpers to deal with marshmallow schemas. Base JSON API schemas."""
1+
"""Helpers to deal with marshmallow schemas. Base JSON:API schemas."""
22
from typing import (
33
Dict,
4-
Type, List,
4+
Type,
5+
List,
6+
Optional,
7+
Sequence,
58
)
69

710
from fastapi import FastAPI
811
from fastapi.openapi.utils import get_flat_models_from_routes
9-
from typing import (
10-
Optional,
11-
Sequence,
12-
)
1312

1413
from pydantic import (
1514
BaseModel,
1615
Field,
1716
)
1817

1918

20-
class BasePostJSONAPISchema(BaseModel):
21-
"""Base POST JSON API schema."""
19+
class BaseJSONAPIItemSchema(BaseModel):
20+
"""Base JSON:API item schema."""
2221

2322
type: str = Field(description="Тип ресурса")
2423
attributes: dict = Field(description="Данные объекта")
2524

2625

27-
class BaseJSONAPIObjectSchema(BasePostJSONAPISchema):
26+
class BasePostJSONAPISchema(BaseJSONAPIItemSchema):
27+
"""Base POST JSON:API schema."""
28+
29+
30+
class BaseJSONAPIObjectSchema(BaseJSONAPIItemSchema):
2831
"""Base JSON:API object schema."""
32+
2933
id: int = Field(description="ID объекта")
3034

3135

3236
class BasePatchJSONAPISchema(BaseJSONAPIObjectSchema):
33-
"""Base PATCH JSON API schema."""
37+
"""Base PATCH JSON:API schema."""
3438

3539

3640
class JSONAPIResultListMetaSchema(BaseModel):
37-
"""JSON API list meta schema."""
41+
"""JSON:API list meta schema."""
3842

3943
count: Optional[int]
4044
total_pages: Optional[int] = Field(alias="totalPages")
4145

4246

4347
class JSONAPIResultListJSONAPISchema(BaseModel):
44-
"""JSON API result list schema."""
48+
"""JSON:API result list schema."""
4549

4650
version: str = Field(default="1.0", description="json-api версия")
4751

4852

4953
class JSONAPIObjectSchema(BaseJSONAPIObjectSchema):
50-
"""JSON API base object schema."""
54+
"""JSON:API base object schema."""
5155

5256

5357
class BaseJSONAPIResultSchema(BaseModel):
@@ -60,13 +64,13 @@ class BaseJSONAPIResultSchema(BaseModel):
6064

6165

6266
class JSONAPIResultListSchema(BaseJSONAPIResultSchema):
63-
"""JSON API list base result schema."""
67+
"""JSON:API list base result schema."""
6468

6569
data: Sequence[JSONAPIObjectSchema] = Field(description="Список объектов")
6670

6771

6872
class JSONAPIResultDetailSchema(BaseJSONAPIResultSchema):
69-
"""JSON API base detail schema."""
73+
"""JSON:API base detail schema."""
7074

7175
data: JSONAPIObjectSchema = Field(description="Данные объекта")
7276

0 commit comments

Comments
 (0)