openapi.yaml 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415
  1. openapi: 3.0.3
  2. info:
  3. title: TappoCloud App Store API
  4. description: |
  5. Tappo 应用商店公开 API,供 Tappo 客户端获取应用列表、详情和下载。
  6. ## 应用类型
  7. - `system`: 系统应用(官方内置)
  8. - `community`: 社区应用(第三方开发)
  9. - `external`: 远程应用(SaaS 集成)
  10. ## 应用包结构
  11. ```
  12. my-app/
  13. ├── app.yml # 元数据定义
  14. ├── main.py # 后端逻辑
  15. ├── assets/ # 静态资源
  16. │ └── icon.png
  17. └── README.md
  18. ```
  19. version: 1.0.0
  20. contact:
  21. name: Tappo Team
  22. url: https://tappo.dev
  23. license:
  24. name: Proprietary
  25. servers:
  26. - url: https://store.tappo.dev/api/v1
  27. description: Production
  28. - url: http://localhost:8000/api/v1
  29. description: Development
  30. tags:
  31. - name: Categories
  32. description: 应用分类
  33. - name: Apps
  34. description: 应用管理
  35. paths:
  36. /categories:
  37. get:
  38. tags: [Categories]
  39. summary: 获取分类列表
  40. operationId: listCategories
  41. responses:
  42. '200':
  43. description: 成功
  44. content:
  45. application/json:
  46. schema:
  47. type: object
  48. properties:
  49. items:
  50. type: array
  51. items:
  52. $ref: '#/components/schemas/Category'
  53. example:
  54. items:
  55. - slug: security
  56. name: 安全工具
  57. description: 密码管理、认证、加密等安全相关应用
  58. icon: shield
  59. - slug: productivity
  60. name: 效率工具
  61. description: 提升工作效率的自动化工具
  62. icon: zap
  63. /apps:
  64. get:
  65. tags: [Apps]
  66. summary: 获取应用列表
  67. operationId: listApps
  68. parameters:
  69. - name: category
  70. in: query
  71. description: 按分类筛选 (slug)
  72. schema:
  73. type: string
  74. example: security
  75. - name: type
  76. in: query
  77. description: 按应用类型筛选
  78. schema:
  79. type: string
  80. enum: [system, community, external]
  81. - name: search
  82. in: query
  83. description: 搜索关键词 (名称/描述)
  84. schema:
  85. type: string
  86. - name: featured
  87. in: query
  88. description: 仅返回推荐应用
  89. schema:
  90. type: boolean
  91. - name: sort
  92. in: query
  93. description: 排序方式
  94. schema:
  95. type: string
  96. enum: [newest, popular]
  97. default: newest
  98. - name: page
  99. in: query
  100. description: 页码 (从 1 开始)
  101. schema:
  102. type: integer
  103. minimum: 1
  104. default: 1
  105. - name: page_size
  106. in: query
  107. description: 每页数量
  108. schema:
  109. type: integer
  110. minimum: 1
  111. maximum: 100
  112. default: 20
  113. responses:
  114. '200':
  115. description: 成功
  116. content:
  117. application/json:
  118. schema:
  119. $ref: '#/components/schemas/AppListResponse'
  120. /apps/{app_uid}:
  121. get:
  122. tags: [Apps]
  123. summary: 获取应用详情
  124. operationId: getApp
  125. parameters:
  126. - name: app_uid
  127. in: path
  128. required: true
  129. description: 应用唯一标识
  130. schema:
  131. type: string
  132. example: mfa-authenticator
  133. responses:
  134. '200':
  135. description: 成功
  136. content:
  137. application/json:
  138. schema:
  139. $ref: '#/components/schemas/AppDetail'
  140. '404':
  141. description: 应用不存在
  142. content:
  143. application/json:
  144. schema:
  145. $ref: '#/components/schemas/Error'
  146. /apps/{app_uid}/download:
  147. get:
  148. tags: [Apps]
  149. summary: 下载应用包
  150. description: |
  151. 返回最新版本的下载信息。客户端应使用返回的 `url` 下载 ZIP 包,
  152. 下载后验证 `checksum_sha256` 确保完整性。
  153. operationId: downloadApp
  154. parameters:
  155. - name: app_uid
  156. in: path
  157. required: true
  158. description: 应用唯一标识
  159. schema:
  160. type: string
  161. example: mfa-authenticator
  162. responses:
  163. '200':
  164. description: 成功
  165. content:
  166. application/json:
  167. schema:
  168. $ref: '#/components/schemas/DownloadInfo'
  169. '404':
  170. description: 应用不存在或无可用版本
  171. content:
  172. application/json:
  173. schema:
  174. $ref: '#/components/schemas/Error'
  175. components:
  176. schemas:
  177. Category:
  178. type: object
  179. properties:
  180. slug:
  181. type: string
  182. description: 分类标识符
  183. example: security
  184. name:
  185. type: string
  186. description: 分类名称
  187. example: 安全工具
  188. description:
  189. type: string
  190. description: 分类描述
  191. example: 密码管理、认证、加密等安全相关应用
  192. icon:
  193. type: string
  194. description: 图标标识
  195. example: shield
  196. required: [slug, name]
  197. Developer:
  198. type: object
  199. properties:
  200. id:
  201. type: integer
  202. format: int64
  203. name:
  204. type: string
  205. example: Tappo Team
  206. avatar_url:
  207. type: string
  208. format: uri
  209. nullable: true
  210. verified:
  211. type: boolean
  212. description: 是否官方认证
  213. example: true
  214. required: [id, name, verified]
  215. AppSummary:
  216. type: object
  217. description: 应用列表项
  218. properties:
  219. app_uid:
  220. type: string
  221. description: 应用唯一标识
  222. example: mfa-authenticator
  223. name:
  224. type: string
  225. description: 应用名称
  226. example: MFA 安全令牌
  227. type:
  228. type: string
  229. enum: [system, community, external]
  230. example: system
  231. icon_url:
  232. type: string
  233. format: uri
  234. nullable: true
  235. example: https://cdn.tappo.dev/apps/mfa/icon.png
  236. short_description:
  237. type: string
  238. example: 管理 TOTP/HOTP 双因素认证令牌
  239. categories:
  240. type: array
  241. items:
  242. type: string
  243. example: [security]
  244. developer:
  245. $ref: '#/components/schemas/Developer'
  246. current_version:
  247. type: string
  248. description: 当前版本号
  249. example: 1.2.0
  250. download_count:
  251. type: integer
  252. format: int64
  253. example: 1234
  254. is_featured:
  255. type: boolean
  256. example: true
  257. publish_time:
  258. type: string
  259. format: date-time
  260. example: "2025-01-15T10:30:00Z"
  261. required: [app_uid, name, type]
  262. AppDetail:
  263. allOf:
  264. - $ref: '#/components/schemas/AppSummary'
  265. - type: object
  266. properties:
  267. description:
  268. type: string
  269. description: 详细描述 (Markdown)
  270. example: |
  271. ## MFA 安全令牌
  272. 管理您的 TOTP/HOTP 双因素认证令牌。
  273. ### 功能特性
  274. - 支持扫码添加
  275. - 自动计算验证码
  276. - 数据本地加密存储
  277. homepage_url:
  278. type: string
  279. format: uri
  280. nullable: true
  281. manifest:
  282. $ref: '#/components/schemas/Manifest'
  283. version_info:
  284. $ref: '#/components/schemas/VersionInfo'
  285. Manifest:
  286. type: object
  287. description: 应用清单 (来自 app.yml)
  288. properties:
  289. pages:
  290. type: array
  291. items:
  292. type: object
  293. properties:
  294. id:
  295. type: string
  296. title:
  297. type: string
  298. window:
  299. type: object
  300. properties:
  301. width:
  302. type: integer
  303. height:
  304. type: integer
  305. commands:
  306. type: array
  307. items:
  308. type: object
  309. properties:
  310. id:
  311. type: string
  312. name:
  313. type: string
  314. description:
  315. type: string
  316. permissions:
  317. type: array
  318. items:
  319. type: object
  320. properties:
  321. id:
  322. type: string
  323. description:
  324. type: string
  325. VersionInfo:
  326. type: object
  327. properties:
  328. version:
  329. type: string
  330. example: 1.2.0
  331. release_notes:
  332. type: string
  333. nullable: true
  334. example: "修复了若干 Bug,提升稳定性"
  335. min_client_version:
  336. type: string
  337. nullable: true
  338. example: "0.5.0"
  339. published_at:
  340. type: string
  341. format: date-time
  342. example: "2025-01-20T08:00:00Z"
  343. size_bytes:
  344. type: integer
  345. format: int64
  346. example: 102400
  347. DownloadInfo:
  348. type: object
  349. properties:
  350. app_uid:
  351. type: string
  352. example: mfa-authenticator
  353. version:
  354. type: string
  355. example: 1.2.0
  356. url:
  357. type: string
  358. format: uri
  359. description: ZIP 包下载地址 (可能为预签名 URL)
  360. example: https://cdn.tappo.dev/apps/mfa/1.2.0/package.zip
  361. checksum_sha256:
  362. type: string
  363. description: SHA256 校验值
  364. example: a1b2c3d4e5f6...
  365. size_bytes:
  366. type: integer
  367. format: int64
  368. example: 102400
  369. required: [app_uid, version, url]
  370. AppListResponse:
  371. type: object
  372. properties:
  373. items:
  374. type: array
  375. items:
  376. $ref: '#/components/schemas/AppSummary'
  377. page:
  378. type: integer
  379. example: 1
  380. page_size:
  381. type: integer
  382. example: 20
  383. total:
  384. type: integer
  385. description: 总记录数
  386. example: 42
  387. Error:
  388. type: object
  389. properties:
  390. code:
  391. type: string
  392. example: NOT_FOUND
  393. message:
  394. type: string
  395. example: 应用不存在
  396. required: [code, message]