{"openapi":"3.1.0","info":{"title":"Research Hub API","description":"System 1 多模态资源中心。外部系统请通过本 API 访问，不要直接读写 SQLite。","version":"0.1.0"},"paths":{"/api/v1/health":{"get":{"summary":"Health","operationId":"health_api_v1_health_get","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}}}}},"/api/v1/items":{"get":{"summary":"List Items","operationId":"list_items_api_v1_items_get","parameters":[{"name":"q","in":"query","required":false,"schema":{"type":"string","default":"","title":"Q"}},{"name":"type","in":"query","required":false,"schema":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Type"}},{"name":"category_id","in":"query","required":false,"schema":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Category Id"}},{"name":"status","in":"query","required":false,"schema":{"type":"string","default":"active","title":"Status"}},{"name":"sort","in":"query","required":false,"schema":{"type":"string","default":"created","title":"Sort"}},{"name":"limit","in":"query","required":false,"schema":{"type":"integer","maximum":100,"minimum":1,"default":30,"title":"Limit"}},{"name":"cursor","in":"query","required":false,"schema":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Cursor"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}},"post":{"summary":"Create Item","operationId":"create_item_api_v1_items_post","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ItemCreate"}}}},"responses":{"201":{"description":"Successful Response","content":{"application/json":{"schema":{}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/api/v1/items/{item_id}":{"get":{"summary":"Get Item","operationId":"get_item_api_v1_items__item_id__get","parameters":[{"name":"item_id","in":"path","required":true,"schema":{"type":"string","title":"Item Id"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}},"patch":{"summary":"Patch Item","operationId":"patch_item_api_v1_items__item_id__patch","parameters":[{"name":"item_id","in":"path","required":true,"schema":{"type":"string","title":"Item Id"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ItemPatch"}}}},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}},"delete":{"summary":"Delete Item","operationId":"delete_item_api_v1_items__item_id__delete","parameters":[{"name":"item_id","in":"path","required":true,"schema":{"type":"string","title":"Item Id"}},{"name":"purge","in":"query","required":false,"schema":{"type":"boolean","default":false,"title":"Purge"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/api/v1/items/{item_id}/assets":{"get":{"summary":"Item Assets","operationId":"item_assets_api_v1_items__item_id__assets_get","parameters":[{"name":"item_id","in":"path","required":true,"schema":{"type":"string","title":"Item Id"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/api/v1/assets/{asset_id}":{"get":{"summary":"Get Asset","operationId":"get_asset_api_v1_assets__asset_id__get","parameters":[{"name":"asset_id","in":"path","required":true,"schema":{"type":"string","title":"Asset Id"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/api/v1/categories":{"get":{"summary":"List Categories","operationId":"list_categories_api_v1_categories_get","parameters":[{"name":"type","in":"query","required":false,"schema":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Type"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}},"post":{"summary":"Create Category","operationId":"create_category_api_v1_categories_post","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CategoryCreate"}}}},"responses":{"201":{"description":"Successful Response","content":{"application/json":{"schema":{}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/api/v1/items/{item_id}/cover":{"put":{"summary":"Set Cover","operationId":"set_cover_api_v1_items__item_id__cover_put","parameters":[{"name":"item_id","in":"path","required":true,"schema":{"type":"string","title":"Item Id"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CoverSet"}}}},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/api/v1/files/browse":{"get":{"summary":"Browse","operationId":"browse_api_v1_files_browse_get","parameters":[{"name":"path","in":"query","required":false,"schema":{"type":"string","default":"","title":"Path"}},{"name":"include_registered","in":"query","required":false,"schema":{"type":"boolean","default":false,"title":"Include Registered"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/api/v1/files/delete":{"post":{"summary":"Delete Files","description":"直接从存储删除未收录文件。已收录（存在 Asset 记录）的文件一律拒绝，先校验后删除。","operationId":"delete_files_api_v1_files_delete_post","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/DeleteFilesReq"}}},"required":true},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/api/v1/library/clear":{"post":{"summary":"Clear Library","description":"清空收录记录：删除数据库中全部 Item 与 Asset；存储中的文件不受影响；分类保留。","operationId":"clear_library_api_v1_library_clear_post","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}}}}},"/api/v1/files/upload":{"post":{"summary":"Upload Files","description":"网页直接上传：文件写入 ASSET_ROOT/uploads/<日期>/，返回相对路径供收录。","operationId":"upload_files_api_v1_files_upload_post","requestBody":{"content":{"multipart/form-data":{"schema":{"$ref":"#/components/schemas/Body_upload_files_api_v1_files_upload_post"}}},"required":true},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/api/v1/files/raw":{"get":{"summary":"Raw File","operationId":"raw_file_api_v1_files_raw_get","parameters":[{"name":"path","in":"query","required":true,"schema":{"type":"string","title":"Path"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/api/v1/files/register":{"post":{"summary":"Register Files","operationId":"register_files_api_v1_files_register_post","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/RegisterReq"}}},"required":true},"responses":{"201":{"description":"Successful Response","content":{"application/json":{"schema":{}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/api/v1/files/register-batch":{"post":{"summary":"Register Batch","description":"批量收录：每个文件生成一个独立 Item。\n\n图片 → image Item，以自身为 Cover 并激活；视频 → video 草稿；其他 → article 草稿\n（md/txt 内容写入 content_text）。分类仅应用到类型匹配的 Item。","operationId":"register_batch_api_v1_files_register_batch_post","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/BatchRegisterReq"}}},"required":true},"responses":{"201":{"description":"Successful Response","content":{"application/json":{"schema":{}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}}},"components":{"schemas":{"BatchRegisterReq":{"properties":{"category_id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Category Id"},"category_name":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Category Name"},"summary":{"type":"string","title":"Summary","default":""},"source_url":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Source Url"},"source_name":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Source Name"},"metadata":{"additionalProperties":true,"type":"object","title":"Metadata","default":{}},"paths":{"items":{"type":"string"},"type":"array","title":"Paths","default":[]}},"type":"object","title":"BatchRegisterReq"},"Body_upload_files_api_v1_files_upload_post":{"properties":{"files":{"items":{"type":"string","contentMediaType":"application/octet-stream"},"type":"array","title":"Files"}},"type":"object","required":["files"],"title":"Body_upload_files_api_v1_files_upload_post"},"CategoryCreate":{"properties":{"item_type":{"type":"string","title":"Item Type"},"name":{"type":"string","title":"Name"},"sort_order":{"type":"integer","title":"Sort Order","default":0}},"type":"object","required":["item_type","name"],"title":"CategoryCreate"},"CoverSet":{"properties":{"asset_id":{"type":"string","title":"Asset Id"}},"type":"object","required":["asset_id"],"title":"CoverSet"},"DeleteFilesReq":{"properties":{"paths":{"items":{"type":"string"},"type":"array","title":"Paths","default":[]}},"type":"object","title":"DeleteFilesReq"},"HTTPValidationError":{"properties":{"detail":{"items":{"$ref":"#/components/schemas/ValidationError"},"type":"array","title":"Detail"}},"type":"object","title":"HTTPValidationError"},"ItemCreate":{"properties":{"title":{"type":"string","title":"Title"},"item_type":{"type":"string","title":"Item Type"},"summary":{"type":"string","title":"Summary","default":""},"content_text":{"type":"string","title":"Content Text","default":""},"category_id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Category Id"},"cover_asset_id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Cover Asset Id"},"source_url":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Source Url"},"source_name":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Source Name"},"metadata":{"additionalProperties":true,"type":"object","title":"Metadata","default":{}},"status":{"type":"string","title":"Status","default":"draft"}},"type":"object","required":["title","item_type"],"title":"ItemCreate"},"ItemPatch":{"properties":{"title":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Title"},"summary":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Summary"},"content_text":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Content Text"},"category_id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Category Id"},"source_url":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Source Url"},"source_name":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Source Name"},"metadata":{"anyOf":[{"additionalProperties":true,"type":"object"},{"type":"null"}],"title":"Metadata"},"status":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Status"}},"type":"object","title":"ItemPatch"},"RegisterReq":{"properties":{"title":{"type":"string","title":"Title"},"item_type":{"type":"string","title":"Item Type"},"category_id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Category Id"},"category_name":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Category Name"},"summary":{"type":"string","title":"Summary","default":""},"content_text":{"type":"string","title":"Content Text","default":""},"source_url":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Source Url"},"source_name":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Source Name"},"metadata":{"additionalProperties":true,"type":"object","title":"Metadata","default":{}},"paths":{"items":{"type":"string"},"type":"array","title":"Paths","default":[]},"cover_path":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Cover Path"}},"type":"object","required":["title","item_type"],"title":"RegisterReq"},"ValidationError":{"properties":{"loc":{"items":{"anyOf":[{"type":"string"},{"type":"integer"}]},"type":"array","title":"Location"},"msg":{"type":"string","title":"Message"},"type":{"type":"string","title":"Error Type"},"input":{"title":"Input"},"ctx":{"type":"object","title":"Context"}},"type":"object","required":["loc","msg","type"],"title":"ValidationError"}}}}