1- """Helpers to deal with marshmallow schemas. Base JSON API schemas."""
1+ """Helpers to deal with marshmallow schemas. Base JSON: API schemas."""
22from typing import (
33 Dict ,
4- Type , List ,
4+ Type ,
5+ List ,
6+ Optional ,
7+ Sequence ,
58)
69
710from fastapi import FastAPI
811from fastapi .openapi .utils import get_flat_models_from_routes
9- from typing import (
10- Optional ,
11- Sequence ,
12- )
1312
1413from 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
3236class BasePatchJSONAPISchema (BaseJSONAPIObjectSchema ):
33- """Base PATCH JSON API schema."""
37+ """Base PATCH JSON: API schema."""
3438
3539
3640class 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
4347class 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
4953class JSONAPIObjectSchema (BaseJSONAPIObjectSchema ):
50- """JSON API base object schema."""
54+ """JSON: API base object schema."""
5155
5256
5357class BaseJSONAPIResultSchema (BaseModel ):
@@ -60,13 +64,13 @@ class BaseJSONAPIResultSchema(BaseModel):
6064
6165
6266class 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
6872class JSONAPIResultDetailSchema (BaseJSONAPIResultSchema ):
69- """JSON API base detail schema."""
73+ """JSON: API base detail schema."""
7074
7175 data : JSONAPIObjectSchema = Field (description = "Данные объекта" )
7276
0 commit comments