mirror of
https://github.com/maziggy/bambuddy.git
synced 2026-10-03 04:31:28 +02:00
- New APIBrowser component with full OpenAPI schema integration
- Fetches and parses /openapi.json automatically
- Groups endpoints by API tags (printers, archives, settings, etc.)
- Expandable endpoint sections with color-coded method badges
- Path parameter, query parameter, and JSON body editors
- Auto-populates request body with schema examples
- Live API request execution with response display
- Response shows status code, timing, and formatted JSON
- Copy response button with clipboard fallback
- Search to filter endpoints across all categories
- Expand All / Collapse All buttons
- Link to Swagger UI (/docs)
- Two-column layout for API Keys tab
- Left: API key management + webhook documentation
- Right: API Browser with dedicated test key input
- Parameter validation
- Shows warning for missing required parameters
- Validates before sending requests to avoid 422 errors
- UX improvements
- "Use in API Browser" button on newly created keys
- Responsive layout (stacked on mobile, side-by-side on xl+)
60 lines
1.8 KiB
Python
60 lines
1.8 KiB
Python
from datetime import datetime
|
|
|
|
from pydantic import BaseModel, Field, field_validator
|
|
|
|
|
|
class ExternalLinkBase(BaseModel):
|
|
"""Base schema for external links."""
|
|
|
|
name: str = Field(..., min_length=1, max_length=50, description="Display name for the link")
|
|
url: str = Field(..., min_length=1, max_length=500, description="External URL")
|
|
icon: str = Field(default="link", max_length=50, description="Lucide icon name")
|
|
|
|
@field_validator("url")
|
|
@classmethod
|
|
def validate_url(cls, v: str) -> str:
|
|
"""Validate URL format."""
|
|
if not v.startswith(("http://", "https://")):
|
|
raise ValueError("URL must start with http:// or https://")
|
|
return v
|
|
|
|
|
|
class ExternalLinkCreate(ExternalLinkBase):
|
|
"""Schema for creating an external link."""
|
|
|
|
pass
|
|
|
|
|
|
class ExternalLinkUpdate(BaseModel):
|
|
"""Schema for updating an external link (all fields optional)."""
|
|
|
|
name: str | None = Field(default=None, min_length=1, max_length=50)
|
|
url: str | None = Field(default=None, min_length=1, max_length=500)
|
|
icon: str | None = Field(default=None, max_length=50)
|
|
|
|
@field_validator("url")
|
|
@classmethod
|
|
def validate_url(cls, v: str | None) -> str | None:
|
|
"""Validate URL format."""
|
|
if v is not None and not v.startswith(("http://", "https://")):
|
|
raise ValueError("URL must start with http:// or https://")
|
|
return v
|
|
|
|
|
|
class ExternalLinkResponse(ExternalLinkBase):
|
|
"""Response schema for external links."""
|
|
|
|
id: int
|
|
custom_icon: str | None = None
|
|
sort_order: int
|
|
created_at: datetime
|
|
updated_at: datetime
|
|
|
|
model_config = {"from_attributes": True}
|
|
|
|
|
|
class ExternalLinkReorder(BaseModel):
|
|
"""Schema for reordering external links."""
|
|
|
|
ids: list[int] = Field(..., description="List of link IDs in desired order")
|