refactor(api): use pydantic v2 model_config
This commit is contained in:
1 parent
adc708ae29
commit
53927f7e11
2 files changed
+4
-6
No files matched your search
@@ -1,5 +1,5 @@
|
|||||||
from fastapi import APIRouter, Depends, HTTPException
|
from fastapi import APIRouter, Depends, HTTPException
|
||||||
from pydantic import BaseModel
|
from pydantic import BaseModel, ConfigDict
|
||||||
from sqlalchemy import select
|
from sqlalchemy import select
|
||||||
from sqlalchemy.orm import Session
|
from sqlalchemy.orm import Session
|
||||||
|
|
||||||
@@ -21,8 +21,7 @@ class LibraryIn(BaseModel):
|
|||||||
class LibraryOut(LibraryIn):
|
class LibraryOut(LibraryIn):
|
||||||
id: int
|
id: int
|
||||||
|
|
||||||
class Config:
|
model_config = ConfigDict(from_attributes=True)
|
||||||
from_attributes = True
|
|
||||||
|
|
||||||
|
|
||||||
def _validate(data: LibraryIn):
|
def _validate(data: LibraryIn):
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
from fastapi import APIRouter, Depends, HTTPException
|
from fastapi import APIRouter, Depends, HTTPException
|
||||||
from pydantic import BaseModel
|
from pydantic import BaseModel, ConfigDict
|
||||||
from sqlalchemy import select
|
from sqlalchemy import select
|
||||||
from sqlalchemy.orm import Session
|
from sqlalchemy.orm import Session
|
||||||
|
|
||||||
@@ -34,8 +34,7 @@ class RequestOut(RequestIn):
|
|||||||
imported_path: str
|
imported_path: str
|
||||||
library_name: str = ""
|
library_name: str = ""
|
||||||
|
|
||||||
class Config:
|
model_config = ConfigDict(from_attributes=True)
|
||||||
from_attributes = True
|
|
||||||
|
|
||||||
|
|
||||||
def _out(r: BookRequest) -> RequestOut:
|
def _out(r: BookRequest) -> RequestOut:
|
||||||
|
|||||||
Reference in new issue
Block a user