Initial commit: MCP Hub Community Edition v3.0.0
Community edition generated from private repo via sync pipeline. Includes 9 plugins (WordPress, WooCommerce, WP Advanced, Gitea, n8n, Supabase, OpenPanel, Appwrite, Directus) with ~587 tools. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
102
plugins/wordpress/schemas/post.py
Normal file
102
plugins/wordpress/schemas/post.py
Normal file
@@ -0,0 +1,102 @@
|
||||
"""
|
||||
Post Pydantic Schemas
|
||||
|
||||
Validation schemas for WordPress posts, pages, and custom post types.
|
||||
"""
|
||||
|
||||
from pydantic import BaseModel, ConfigDict, Field, field_validator
|
||||
|
||||
class PostBase(BaseModel):
|
||||
"""Base post schema with common fields"""
|
||||
|
||||
title: str | None = Field(None, description="Post title")
|
||||
content: str | None = Field(None, description="Post content (HTML)")
|
||||
excerpt: str | None = Field(None, description="Post excerpt")
|
||||
status: str | None = Field("draft", description="Post status")
|
||||
slug: str | None = Field(None, description="Post slug (URL-friendly)")
|
||||
author: int | None = Field(None, description="Author user ID")
|
||||
featured_media: int | None = Field(None, description="Featured image media ID")
|
||||
comment_status: str | None = Field(None, description="Comment status (open/closed)")
|
||||
ping_status: str | None = Field(None, description="Ping status (open/closed)")
|
||||
format: str | None = Field(None, description="Post format")
|
||||
meta: dict | None = Field(None, description="Post meta fields")
|
||||
sticky: bool | None = Field(None, description="Sticky post flag")
|
||||
categories: list[int] | None = Field(None, description="Category IDs")
|
||||
tags: list[int] | None = Field(None, description="Tag IDs")
|
||||
|
||||
model_config = ConfigDict(extra="allow") # Allow additional fields for custom post types
|
||||
|
||||
@classmethod
|
||||
@field_validator("status")
|
||||
def validate_status(cls, v):
|
||||
if v is not None:
|
||||
allowed = ["publish", "draft", "pending", "private", "future"]
|
||||
if v not in allowed:
|
||||
raise ValueError(f"Status must be one of: {', '.join(allowed)}")
|
||||
return v
|
||||
|
||||
@classmethod
|
||||
@field_validator("comment_status", "ping_status")
|
||||
def validate_comment_ping_status(cls, v):
|
||||
if v is not None:
|
||||
allowed = ["open", "closed"]
|
||||
if v not in allowed:
|
||||
raise ValueError("Status must be 'open' or 'closed'")
|
||||
return v
|
||||
|
||||
class PostCreate(PostBase):
|
||||
"""Schema for creating a new post"""
|
||||
|
||||
title: str = Field(..., min_length=1, description="Post title (required)")
|
||||
content: str = Field(..., description="Post content (required)")
|
||||
|
||||
model_config = ConfigDict(extra="allow")
|
||||
|
||||
class PostUpdate(PostBase):
|
||||
"""Schema for updating an existing post"""
|
||||
|
||||
# All fields optional for updates
|
||||
pass
|
||||
|
||||
class PostResponse(BaseModel):
|
||||
"""Schema for post response data"""
|
||||
|
||||
model_config = ConfigDict(extra="allow")
|
||||
|
||||
id: int
|
||||
title: str
|
||||
content: str
|
||||
excerpt: str
|
||||
status: str
|
||||
slug: str
|
||||
link: str
|
||||
date: str
|
||||
modified: str
|
||||
author: int
|
||||
featured_media: int
|
||||
categories: list[int]
|
||||
tags: list[int]
|
||||
|
||||
class PageCreate(PostCreate):
|
||||
"""Schema for creating a new page"""
|
||||
|
||||
parent: int | None = Field(None, description="Parent page ID")
|
||||
menu_order: int | None = Field(None, description="Menu order")
|
||||
template: str | None = Field(None, description="Page template")
|
||||
|
||||
class PageUpdate(PostUpdate):
|
||||
"""Schema for updating an existing page"""
|
||||
|
||||
parent: int | None = Field(None, description="Parent page ID")
|
||||
menu_order: int | None = Field(None, description="Menu order")
|
||||
template: str | None = Field(None, description="Page template")
|
||||
|
||||
class CustomPostCreate(PostCreate):
|
||||
"""Schema for creating custom post types"""
|
||||
|
||||
post_type: str = Field(..., description="Custom post type")
|
||||
|
||||
class CustomPostUpdate(PostUpdate):
|
||||
"""Schema for updating custom post types"""
|
||||
|
||||
pass
|
||||
Reference in New Issue
Block a user