v2-article-article.yaml 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409
  1. # 由 openapi/scripts/generate.php 生成,请勿手改;补充写到 overrides/v2-article-article.yaml
  2. get:
  3. summary: '查看单篇 article(文章)'
  4. tags:
  5. - article
  6. operationId: get_api_v2_article_article_
  7. description: |-
  8. 前端阅读页最常用的接口。允许匿名访问:status=30(公开)的文章任何人可读;
  9. 非公开文章需要登录,且满足以下之一——是文章 owner、对该文章有只读以上共享权限(power>=10)、
  10. 或对该文章所在的(同一 owner 的)文集有只读以上共享权限,否则返回 403。
  11. 实现:`ArticleController@show`
  12. parameters:
  13. -
  14. name: article
  15. in: path
  16. required: true
  17. schema:
  18. type: string
  19. description: '文章 uid(路由模型绑定到 Article,主键即 uid)'
  20. -
  21. name: anthology
  22. in: query
  23. schema:
  24. type: string
  25. description: '所在文集 uid,用于在返回结果里渲染文集路径(path)'
  26. -
  27. name: channel
  28. in: query
  29. schema:
  30. type: string
  31. description: '渲染标题所用的 channel uid,多个用下划线分隔;不传则回退到文集的默认 channel'
  32. responses:
  33. 200:
  34. description: '成功。业务失败时 HTTP 仍可能为 200,以 ok 字段为准。'
  35. content:
  36. application/json:
  37. schema:
  38. type: object
  39. properties:
  40. ok:
  41. type: boolean
  42. message:
  43. type: string
  44. data:
  45. type: object
  46. properties:
  47. uid:
  48. type: string
  49. title:
  50. type: string
  51. subtitle:
  52. type: string
  53. summary:
  54. type: string
  55. studio:
  56. type: string
  57. editor:
  58. type: string
  59. status:
  60. type: integer
  61. lang:
  62. type: string
  63. parent_uid:
  64. type: string
  65. created_at:
  66. type: string
  67. updated_at:
  68. type: string
  69. format:
  70. type: string
  71. key:
  72. type: string
  73. level:
  74. type: integer
  75. mode:
  76. type: string
  77. footnote:
  78. type: string
  79. origin:
  80. type: string
  81. paragraph:
  82. type: string
  83. role:
  84. type: string
  85. anthology_count:
  86. type: integer
  87. anthology_first:
  88. type: string
  89. path:
  90. type: string
  91. toc:
  92. type: string
  93. title_text:
  94. type: string
  95. content:
  96. type: string
  97. content_type:
  98. type: string
  99. html:
  100. type: string
  101. _summary:
  102. type: string
  103. 401:
  104. $ref: '../../main.yaml#/components/responses/Unauthorized'
  105. 422:
  106. $ref: '../../main.yaml#/components/responses/ValidationError'
  107. put:
  108. summary: '更新 article(文章)'
  109. tags:
  110. - article
  111. operationId: put_api_v2_article_article_
  112. description: |-
  113. 需要登录。权限:必须是文章 owner,或对文章有编辑以上共享权限(power>=20),
  114. 或对文章所在的同 owner 文集有编辑以上权限,否则返回 401。
  115. 字段会整体覆盖:title/subtitle 截断到 128 字,summary 截断到 1024 字,
  116. status 未传时会被重置为 10(非公开),即部分更新也必须带全字段。
  117. 副作用:to_tpl=true 时把正文转成模版——按行切句,正文中的句子被替换成 {{book-para-start-end}} 占位,
  118. 同时把原文逐句写入 sentences 表(必要时为文集新建 CustomBook 与 channel),该过程需要对应 channel 的写权限。
  119. 实现:`ArticleController@update`
  120. parameters:
  121. -
  122. name: article
  123. in: path
  124. required: true
  125. schema:
  126. type: string
  127. description: '文章 uid(路由模型绑定)'
  128. requestBody:
  129. required: true
  130. content:
  131. application/json:
  132. schema:
  133. type: object
  134. properties:
  135. content:
  136. type: string
  137. description: 正文(markdown)
  138. to_tpl:
  139. type: boolean
  140. description: '是否把正文转换为模版并把原文切句入库,必须是布尔 true 才生效'
  141. anthology_id:
  142. type: string
  143. description: 'to_tpl=true 时必填,文集 uid,用于定位/创建书号与 channel'
  144. title:
  145. type: string
  146. description: '标题,最多 128 字'
  147. subtitle:
  148. type: string
  149. description: '副标题,最多 128 字'
  150. summary:
  151. type: string
  152. description: '摘要,最多 1024 字'
  153. lang:
  154. type: string
  155. description: 语言代码
  156. status:
  157. type: integer
  158. description: '公开状态,30 表示公开'
  159. default: 10
  160. required:
  161. - title
  162. - content
  163. - lang
  164. responses:
  165. 200:
  166. description: '成功。业务失败时 HTTP 仍可能为 200,以 ok 字段为准。'
  167. content:
  168. application/json:
  169. schema:
  170. type: object
  171. properties:
  172. ok:
  173. type: boolean
  174. message:
  175. type: string
  176. data:
  177. type: object
  178. properties:
  179. uid:
  180. type: string
  181. title:
  182. type: string
  183. subtitle:
  184. type: string
  185. summary:
  186. type: string
  187. studio:
  188. type: string
  189. editor:
  190. type: string
  191. status:
  192. type: integer
  193. lang:
  194. type: string
  195. parent_uid:
  196. type: string
  197. created_at:
  198. type: string
  199. updated_at:
  200. type: string
  201. format:
  202. type: string
  203. key:
  204. type: string
  205. level:
  206. type: integer
  207. mode:
  208. type: string
  209. footnote:
  210. type: string
  211. origin:
  212. type: string
  213. paragraph:
  214. type: string
  215. role:
  216. type: string
  217. anthology_count:
  218. type: integer
  219. anthology_first:
  220. type: string
  221. path:
  222. type: string
  223. toc:
  224. type: string
  225. title_text:
  226. type: string
  227. content:
  228. type: string
  229. content_type:
  230. type: string
  231. html:
  232. type: string
  233. _summary:
  234. type: string
  235. 401:
  236. $ref: '../../main.yaml#/components/responses/Unauthorized'
  237. 422:
  238. $ref: '../../main.yaml#/components/responses/ValidationError'
  239. patch:
  240. summary: '更新 article(文章)'
  241. tags:
  242. - article
  243. operationId: patch_api_v2_article_article_
  244. description: |-
  245. 需要登录。权限:必须是文章 owner,或对文章有编辑以上共享权限(power>=20),
  246. 或对文章所在的同 owner 文集有编辑以上权限,否则返回 401。
  247. 字段会整体覆盖:title/subtitle 截断到 128 字,summary 截断到 1024 字,
  248. status 未传时会被重置为 10(非公开),即部分更新也必须带全字段。
  249. 副作用:to_tpl=true 时把正文转成模版——按行切句,正文中的句子被替换成 {{book-para-start-end}} 占位,
  250. 同时把原文逐句写入 sentences 表(必要时为文集新建 CustomBook 与 channel),该过程需要对应 channel 的写权限。
  251. 实现:`ArticleController@update`
  252. parameters:
  253. -
  254. name: article
  255. in: path
  256. required: true
  257. schema:
  258. type: string
  259. description: '文章 uid(路由模型绑定)'
  260. requestBody:
  261. required: true
  262. content:
  263. application/json:
  264. schema:
  265. type: object
  266. properties:
  267. content:
  268. type: string
  269. description: 正文(markdown)
  270. to_tpl:
  271. type: boolean
  272. description: '是否把正文转换为模版并把原文切句入库,必须是布尔 true 才生效'
  273. anthology_id:
  274. type: string
  275. description: 'to_tpl=true 时必填,文集 uid,用于定位/创建书号与 channel'
  276. title:
  277. type: string
  278. description: '标题,最多 128 字'
  279. subtitle:
  280. type: string
  281. description: '副标题,最多 128 字'
  282. summary:
  283. type: string
  284. description: '摘要,最多 1024 字'
  285. lang:
  286. type: string
  287. description: 语言代码
  288. status:
  289. type: integer
  290. description: '公开状态,30 表示公开'
  291. default: 10
  292. required:
  293. - title
  294. - content
  295. - lang
  296. responses:
  297. 200:
  298. description: '成功。业务失败时 HTTP 仍可能为 200,以 ok 字段为准。'
  299. content:
  300. application/json:
  301. schema:
  302. type: object
  303. properties:
  304. ok:
  305. type: boolean
  306. message:
  307. type: string
  308. data:
  309. type: object
  310. properties:
  311. uid:
  312. type: string
  313. title:
  314. type: string
  315. subtitle:
  316. type: string
  317. summary:
  318. type: string
  319. studio:
  320. type: string
  321. editor:
  322. type: string
  323. status:
  324. type: integer
  325. lang:
  326. type: string
  327. parent_uid:
  328. type: string
  329. created_at:
  330. type: string
  331. updated_at:
  332. type: string
  333. format:
  334. type: string
  335. key:
  336. type: string
  337. level:
  338. type: integer
  339. mode:
  340. type: string
  341. footnote:
  342. type: string
  343. origin:
  344. type: string
  345. paragraph:
  346. type: string
  347. role:
  348. type: string
  349. anthology_count:
  350. type: integer
  351. anthology_first:
  352. type: string
  353. path:
  354. type: string
  355. toc:
  356. type: string
  357. title_text:
  358. type: string
  359. content:
  360. type: string
  361. content_type:
  362. type: string
  363. html:
  364. type: string
  365. _summary:
  366. type: string
  367. 401:
  368. $ref: '../../main.yaml#/components/responses/Unauthorized'
  369. 422:
  370. $ref: '../../main.yaml#/components/responses/ValidationError'
  371. delete:
  372. summary: '删除 article(文章)'
  373. tags:
  374. - article
  375. operationId: delete_api_v2_article_article_
  376. description: |-
  377. 需要登录,且只有文章 owner 本人可以删除(协作者不行),否则返回鉴权失败。
  378. 副作用:在事务中删除文章记录,并同步把该文章从所有文集目录(article_collections)中摘除。
  379. 实现:`ArticleController@destroy`
  380. parameters:
  381. -
  382. name: article
  383. in: path
  384. required: true
  385. schema:
  386. type: string
  387. description: '文章 uid(路由模型绑定)'
  388. responses:
  389. 200:
  390. description: '成功。业务失败时 HTTP 仍可能为 200,以 ok 字段为准。'
  391. content:
  392. application/json:
  393. schema:
  394. type: object
  395. properties:
  396. ok:
  397. type: boolean
  398. message:
  399. type: string
  400. data:
  401. type: object
  402. 401:
  403. $ref: '../../main.yaml#/components/responses/Unauthorized'
  404. 422:
  405. $ref: '../../main.yaml#/components/responses/ValidationError'