2026-02-04 12:35:14 +08:00
|
|
|
"""Request and response schemas for format conversion endpoints."""
|
2025-12-29 17:34:58 +08:00
|
|
|
|
|
|
|
|
from pydantic import BaseModel, Field, field_validator
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class MarkdownToDocxRequest(BaseModel):
|
|
|
|
|
"""Request body for markdown to DOCX conversion endpoint."""
|
|
|
|
|
|
|
|
|
|
markdown: str = Field(..., description="Markdown content to convert")
|
2025-12-31 17:38:32 +08:00
|
|
|
filename: str = Field("texpixel", description="Optional output filename (without extension)")
|
2025-12-29 17:34:58 +08:00
|
|
|
|
|
|
|
|
@field_validator("markdown")
|
|
|
|
|
@classmethod
|
|
|
|
|
def validate_markdown_not_empty(cls, v: str) -> str:
|
|
|
|
|
"""Validate that markdown content is not empty."""
|
|
|
|
|
if not v or not v.strip():
|
|
|
|
|
raise ValueError("Markdown content cannot be empty")
|
|
|
|
|
return v
|
|
|
|
|
|
2026-02-04 12:35:14 +08:00
|
|
|
|
|
|
|
|
class LatexToOmmlRequest(BaseModel):
|
|
|
|
|
"""Request body for LaTeX to OMML conversion endpoint."""
|
|
|
|
|
|
|
|
|
|
latex: str = Field(..., description="Pure LaTeX formula (without $ or $$ delimiters)")
|
|
|
|
|
|
|
|
|
|
@field_validator("latex")
|
|
|
|
|
@classmethod
|
|
|
|
|
def validate_latex_not_empty(cls, v: str) -> str:
|
|
|
|
|
"""Validate that LaTeX formula is not empty."""
|
|
|
|
|
if not v or not v.strip():
|
|
|
|
|
raise ValueError("LaTeX formula cannot be empty")
|
|
|
|
|
return v
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class LatexToOmmlResponse(BaseModel):
|
|
|
|
|
"""Response body for LaTeX to OMML conversion endpoint."""
|
|
|
|
|
|
|
|
|
|
omml: str = Field("", description="OMML (Office Math Markup Language) representation")
|
|
|
|
|
|