fix: resolve utoipa schema generation errors by removing unsupported description attributes and creating specific response types

Co-authored-by: aider (openai/andrew/openrouter/anthropic/claude-sonnet-4) <aider@aider.chat>
This commit is contained in:
Andrew Phillips
2025-08-13 13:39:07 -03:00
parent 87e76f6314
commit 92e589699c
4 changed files with 60 additions and 21 deletions

View File

@@ -44,28 +44,61 @@ pub struct AppState {
#[derive(Serialize, Deserialize, ToSchema)]
#[schema(description = "Standard API response wrapper containing success status, data payload, and error information")]
pub struct ApiResponse<T> {
#[schema(description = "Indicates whether the API request was successful")]
pub success: bool,
#[schema(description = "The response data payload, present when success is true")]
pub data: Option<T>,
#[schema(description = "Error message describing what went wrong, present when success is false")]
pub error: Option<String>,
}
// Specific response types for OpenAPI documentation
#[derive(Serialize, Deserialize, ToSchema)]
pub struct ItemInfoListResponse {
pub success: bool,
pub data: Option<Vec<ItemInfo>>,
pub error: Option<String>,
}
#[derive(Serialize, Deserialize, ToSchema)]
pub struct ItemInfoResponse {
pub success: bool,
pub data: Option<ItemInfo>,
pub error: Option<String>,
}
#[derive(Serialize, Deserialize, ToSchema)]
pub struct ItemContentInfoResponse {
pub success: bool,
pub data: Option<ItemContentInfo>,
pub error: Option<String>,
}
#[derive(Serialize, Deserialize, ToSchema)]
pub struct MetadataResponse {
pub success: bool,
pub data: Option<HashMap<String, String>>,
pub error: Option<String>,
}
#[derive(Serialize, Deserialize, ToSchema)]
pub struct StatusInfoResponse {
pub success: bool,
pub data: Option<crate::common::status::StatusInfo>,
pub error: Option<String>,
}
#[derive(Serialize, Deserialize, ToSchema)]
#[schema(description = "Complete information about a stored item including metadata and tags")]
pub struct ItemInfo {
#[schema(description = "Unique identifier for the item", example = 42)]
#[schema(example = 42)]
pub id: i64,
#[schema(description = "ISO 8601 timestamp when the item was created", example = "2023-12-01T15:30:45Z")]
#[schema(example = "2023-12-01T15:30:45Z")]
pub ts: String,
#[schema(description = "Size of the original content in bytes before compression", example = 1024)]
#[schema(example = 1024)]
pub size: Option<i64>,
#[schema(description = "Compression algorithm used to store the item", example = "gzip")]
#[schema(example = "gzip")]
pub compression: String,
#[schema(description = "List of tags associated with this item for categorization", example = json!(["important", "work", "document"]))]
#[schema(example = json!(["important", "work", "document"]))]
pub tags: Vec<String>,
#[schema(description = "Key-value pairs of metadata extracted from the content (file type, encoding, etc.)", example = json!({"file.mime": "text/plain", "file.encoding": "utf-8", "line_count": "42"}))]
#[schema(example = json!({"file.mime": "text/plain", "file.encoding": "utf-8", "line_count": "42"}))]
pub metadata: HashMap<String, String>,
}
@@ -73,11 +106,11 @@ pub struct ItemInfo {
#[schema(description = "Item information including content and metadata, with binary detection")]
pub struct ItemContentInfo {
#[serde(flatten)]
#[schema(description = "Key-value pairs of metadata extracted from the content", example = json!({"file.mime": "text/plain", "file.encoding": "utf-8", "line_count": "42"}))]
#[schema(example = json!({"file.mime": "text/plain", "file.encoding": "utf-8", "line_count": "42"}))]
pub metadata: HashMap<String, String>,
#[schema(description = "The actual content as a string if it's text-based and allow_binary is true for binary content, null otherwise", example = "Hello, world!\nThis is the content of the file.")]
#[schema(example = "Hello, world!\nThis is the content of the file.")]
pub content: Option<String>,
#[schema(description = "Whether the content is detected as binary data (images, executables, etc.)", example = false)]
#[schema(example = false)]
pub binary: bool,
}