File tree Expand file tree Collapse file tree 2 files changed +11
-9
lines changed Expand file tree Collapse file tree 2 files changed +11
-9
lines changed Original file line number Diff line number Diff line change 1
1
from fastapi import APIRouter , status
2
- from pydantic import BaseModel
2
+ from pydantic import BaseModel , ConfigDict
3
3
4
4
from domains .books import Book , BookData , BookService
5
5
9
9
10
10
class CreateBookResponse (BaseModel ):
11
11
book : Book
12
-
13
- class Config :
14
- json_schema_extra = {
12
+ model_config = ConfigDict (
13
+ json_schema_extra = {
15
14
"example" : {
16
15
"title" : "The Hitchhiker's Guide to the Galaxy" ,
17
16
"author_name" : "Douglas Adams" ,
18
17
"book_id" : 123 ,
19
18
}
20
19
}
20
+ )
21
21
22
22
23
23
class CreateBookRequest (BaseModel ):
24
24
title : str
25
25
author_name : str
26
26
27
- class Config :
28
- json_schema_extra = {
27
+ model_config = ConfigDict (
28
+ json_schema_extra = {
29
29
"example" : {
30
30
"title" : "The Hitchhiker's Guide to the Galaxy" ,
31
31
"author_name" : "Douglas Adams" ,
32
32
}
33
33
}
34
+ )
34
35
35
36
36
37
"""
Original file line number Diff line number Diff line change 1
1
from fastapi import APIRouter
2
- from pydantic import BaseModel
2
+ from pydantic import BaseModel , ConfigDict
3
3
4
4
router = APIRouter ()
5
5
6
6
7
7
class PingResponse (BaseModel ):
8
8
ping : str
9
9
10
- class Config :
11
- json_schema_extra = {
10
+ model_config = ConfigDict (
11
+ json_schema_extra = {
12
12
"example" : {
13
13
"ping" : "pong!" ,
14
14
}
15
15
}
16
+ )
16
17
17
18
18
19
@router .get ("/ping" , response_model = PingResponse )
You can’t perform that action at this time.
0 commit comments