Álvaro Valenzuela Valdes commited on
Commit
59fcb47
·
1 Parent(s): 2d2e7a1

fix: Resolve Pydantic ResponseValidationError by supporting hybrid dates and empty lists

Browse files
backend/app/main.py CHANGED
@@ -66,7 +66,9 @@ async def startup_event():
66
  estimated_amount=450000000,
67
  region="Metropolitana",
68
  sector="Software",
69
- source="Mercado Público"
 
 
70
  ),
71
  TenderModel(
72
  code="5021-10-LP24",
@@ -78,7 +80,9 @@ async def startup_event():
78
  estimated_amount=180000000,
79
  region="Nacional",
80
  sector="AI & Software",
81
- source="Mercado Público"
 
 
82
  ),
83
  TenderModel(
84
  code="1022-5-LP24",
@@ -90,7 +94,9 @@ async def startup_event():
90
  estimated_amount=320000000,
91
  region="Metropolitana",
92
  sector="Cybersecurity",
93
- source="Mercado Público"
 
 
94
  ),
95
  TenderModel(
96
  code="8821-2-LR24",
@@ -102,7 +108,9 @@ async def startup_event():
102
  estimated_amount=120000000,
103
  region="Valparaíso",
104
  sector="Cloud",
105
- source="Mercado Público"
 
 
106
  )
107
  ]
108
  for t in tenders_to_add:
 
66
  estimated_amount=450000000,
67
  region="Metropolitana",
68
  sector="Software",
69
+ source="Mercado Público",
70
+ items=[],
71
+ attachments=[]
72
  ),
73
  TenderModel(
74
  code="5021-10-LP24",
 
80
  estimated_amount=180000000,
81
  region="Nacional",
82
  sector="AI & Software",
83
+ source="Mercado Público",
84
+ items=[],
85
+ attachments=[]
86
  ),
87
  TenderModel(
88
  code="1022-5-LP24",
 
94
  estimated_amount=320000000,
95
  region="Metropolitana",
96
  sector="Cybersecurity",
97
+ source="Mercado Público",
98
+ items=[],
99
+ attachments=[]
100
  ),
101
  TenderModel(
102
  code="8821-2-LR24",
 
108
  estimated_amount=120000000,
109
  region="Valparaíso",
110
  sector="Cloud",
111
+ source="Mercado Público",
112
+ items=[],
113
+ attachments=[]
114
  )
115
  ]
116
  for t in tenders_to_add:
backend/app/schemas/tender.py CHANGED
@@ -1,5 +1,6 @@
1
- from pydantic import BaseModel
2
- from typing import List, Optional
 
3
 
4
  class TenderItem(BaseModel):
5
  name: str
@@ -11,11 +12,13 @@ class TenderAttachment(BaseModel):
11
  url: str
12
 
13
  class Tender(BaseModel):
 
 
14
  code: str
15
  name: str
16
  buyer: str
17
  status: str
18
- closing_date: str
19
  description: str
20
  estimated_amount: Optional[float] = None
21
  source: str
 
1
+ from pydantic import BaseModel, ConfigDict
2
+ from typing import List, Optional, Union
3
+ from datetime import datetime
4
 
5
  class TenderItem(BaseModel):
6
  name: str
 
12
  url: str
13
 
14
  class Tender(BaseModel):
15
+ model_config = ConfigDict(from_attributes=True)
16
+
17
  code: str
18
  name: str
19
  buyer: str
20
  status: str
21
+ closing_date: Union[str, datetime, None] = None
22
  description: str
23
  estimated_amount: Optional[float] = None
24
  source: str