Skip to content

Commit 50aec15

Browse files
committed
chore: simplify fastapi model
1 parent 4196495 commit 50aec15

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

examples/fastapi/Models.fs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,15 @@ open Fable.Python.Pydantic
1010
// ============================================================================
1111

1212
/// User model - a Pydantic BaseModel
13-
[<Py.ClassAttributes(style = Py.ClassAttributeStyle.Attributes, init = false)>]
13+
[<Py.DataClass>]
1414
type User(Id: int, Name: string, Email: string) =
1515
inherit BaseModel()
1616
member val Id: int = Id with get, set
1717
member val Name: string = Name with get, set
1818
member val Email: string = Email with get, set
1919

2020
/// Request model for creating a new user
21-
[<Py.ClassAttributes(style = Py.ClassAttributeStyle.Attributes, init = false)>]
21+
[<Py.DataClass>]
2222
type CreateUserRequest(Name: string, Email: string) =
2323
inherit BaseModel()
2424
member val Name: string = Name with get, set
@@ -29,7 +29,7 @@ type CreateUserRequest(Name: string, Email: string) =
2929
// ============================================================================
3030

3131
/// Item model - a Pydantic BaseModel
32-
[<Py.ClassAttributes(style = Py.ClassAttributeStyle.Attributes, init = false)>]
32+
[<Py.DataClass>]
3333
type Item(Id: int, Name: string, Price: float, InStock: bool) =
3434
inherit BaseModel()
3535
member val Id: int = Id with get, set
@@ -38,7 +38,7 @@ type Item(Id: int, Name: string, Price: float, InStock: bool) =
3838
member val InStock: bool = InStock with get, set
3939

4040
/// Request model for creating/updating an item
41-
[<Py.ClassAttributes(style = Py.ClassAttributeStyle.Attributes, init = false)>]
41+
[<Py.DataClass>]
4242
type CreateItemRequest(Name: string, Price: float, InStock: bool) =
4343
inherit BaseModel()
4444
member val Name: string = Name with get, set

0 commit comments

Comments
 (0)