REFACTOR API gateway fix 5
This commit is contained in:
@@ -9,8 +9,9 @@ from typing import Optional, List, Dict, Any
|
||||
from uuid import UUID
|
||||
|
||||
class SalesDataCreate(BaseModel):
|
||||
"""Schema for creating sales data"""
|
||||
tenant_id: UUID
|
||||
"""Schema for creating sales data - FIXED to work with gateway"""
|
||||
# ✅ FIX: Make tenant_id optional since it comes from URL path
|
||||
tenant_id: Optional[UUID] = Field(None, description="Tenant ID (auto-injected from URL path)")
|
||||
date: datetime
|
||||
product_name: str = Field(..., min_length=1, max_length=255)
|
||||
quantity_sold: int = Field(..., gt=0)
|
||||
@@ -25,6 +26,16 @@ class SalesDataCreate(BaseModel):
|
||||
|
||||
class Config:
|
||||
from_attributes = True
|
||||
json_schema_extra = {
|
||||
"example": {
|
||||
"date": "2024-01-15T10:00:00Z",
|
||||
"product_name": "Pan Integral",
|
||||
"quantity_sold": 25,
|
||||
"revenue": 37.50,
|
||||
"source": "manual"
|
||||
# Note: tenant_id is automatically injected from URL path by gateway
|
||||
}
|
||||
}
|
||||
|
||||
class SalesDataResponse(BaseModel):
|
||||
"""Schema for sales data response"""
|
||||
@@ -62,15 +73,23 @@ class SalesDataQuery(BaseModel):
|
||||
from_attributes = True
|
||||
|
||||
class SalesDataImport(BaseModel):
|
||||
"""Schema for importing sales data"""
|
||||
tenant_id: UUID
|
||||
data: str # JSON string or CSV content
|
||||
"""Schema for importing sales data - FIXED to work with gateway"""
|
||||
# ✅ FIX: Make tenant_id optional since it comes from URL path
|
||||
tenant_id: Optional[UUID] = Field(None, description="Tenant ID (auto-injected from URL path)")
|
||||
data: str = Field(..., description="JSON string or CSV content")
|
||||
data_format: str = Field(..., pattern="^(csv|json|excel)$")
|
||||
source: str = Field(default="import", max_length=50)
|
||||
validate_only: bool = Field(default=False)
|
||||
|
||||
class Config:
|
||||
from_attributes = True
|
||||
json_schema_extra = {
|
||||
"example": {
|
||||
"data": "date,product,quantity,revenue\n2024-01-01,bread,10,25.50",
|
||||
"data_format": "csv",
|
||||
# Note: tenant_id is automatically injected from URL path by gateway
|
||||
}
|
||||
}
|
||||
|
||||
class SalesDataBulkCreate(BaseModel):
|
||||
"""Schema for bulk creating sales data"""
|
||||
|
||||
Reference in New Issue
Block a user