-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathModels.fs
More file actions
46 lines (39 loc) · 1.64 KB
/
Models.fs
File metadata and controls
46 lines (39 loc) · 1.64 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
/// Pydantic Models for the FastAPI Example
/// Demonstrates how to create Pydantic models using F# classes
module Models
open Fable.Core
open Fable.Python.Pydantic
// ============================================================================
// User Models
// ============================================================================
/// User model - a Pydantic BaseModel
[<Py.DataClass>]
type User(Id: int, Name: string, Email: string) =
inherit BaseModel()
member val Id: int = Id with get, set
member val Name: string = Name with get, set
member val Email: string = Email with get, set
/// Request model for creating a new user
[<Py.DataClass>]
type CreateUserRequest(Name: string, Email: string) =
inherit BaseModel()
member val Name: string = Name with get, set
member val Email: string = Email with get, set
// ============================================================================
// Item Models
// ============================================================================
/// Item model - a Pydantic BaseModel
[<Py.DataClass>]
type Item(Id: int, Name: string, Price: float, InStock: bool) =
inherit BaseModel()
member val Id: int = Id with get, set
member val Name: string = Name with get, set
member val Price: float = Price with get, set
member val InStock: bool = InStock with get, set
/// Request model for creating/updating an item
[<Py.DataClass>]
type CreateItemRequest(Name: string, Price: float, InStock: bool) =
inherit BaseModel()
member val Name: string = Name with get, set
member val Price: float = Price with get, set
member val InStock: bool = InStock with get, set