Fix custom command creator POST validation (v2.3.1)
Changed CustomCommandCreatorModel.id from required `int` to `Optional[int] = None` to allow POST requests to create new creators without specifying an ID (database auto-generates it). Bug: Users couldn't create custom commands with /new-cc - API returned 422 error "Field required" for missing id field. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
parent
d53b7259db
commit
99f501e748
@ -72,6 +72,7 @@ app/
|
||||
- **Models**: Pydantic models for request/response validation
|
||||
- **Database Access**: Direct Peewee ORM queries with automatic connection pooling
|
||||
- **Response Format**: Consistent JSON with proper HTTP status codes
|
||||
- **POST Requests**: Pydantic models for POST (create) endpoints should use `Optional[int] = None` for `id` fields since the database auto-generates IDs
|
||||
|
||||
### Environment Variables
|
||||
**Required**:
|
||||
|
||||
@ -20,7 +20,7 @@ router = APIRouter(
|
||||
|
||||
# Pydantic Models for API
|
||||
class CustomCommandCreatorModel(BaseModel):
|
||||
id: int
|
||||
id: Optional[int] = None # Optional for POST (auto-generated), required on response
|
||||
discord_id: int
|
||||
username: str
|
||||
display_name: Optional[str] = None
|
||||
|
||||
Loading…
Reference in New Issue
Block a user