v2-article-preview-id.yaml 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. # 由 openapi/scripts/generate.php 生成,请勿手改;补充写到 overrides/v2-article-preview-id.yaml
  2. put:
  3. summary: 预览文章正文
  4. tags:
  5. - article-preview
  6. operationId: put_api_v2_article_preview_id_
  7. description: |-
  8. PUT /api/v2/article-preview/{id}。用请求体里的 content 覆盖文章正文后走一遍渲染再返回,
  9. 不写数据库,用于编辑器里的即时预览。
  10. 权限与查看文章一致:公开文章匿名可预览,否则需要读权限,无权限返回 401。
  11. 未传 content 时返回 error('no content'),但 HTTP 状态码仍是 200。
  12. 实现:`ArticleController@preview`
  13. parameters:
  14. -
  15. name: id
  16. in: path
  17. required: true
  18. schema:
  19. type: string
  20. description: '文章 uid'
  21. requestBody:
  22. required: true
  23. content:
  24. application/json:
  25. schema:
  26. type: object
  27. properties:
  28. content:
  29. type: string
  30. description: 待预览的正文内容(markdown)
  31. anthology:
  32. type: string
  33. description: '所在文集 uid,用于渲染文集路径'
  34. channel:
  35. type: string
  36. description: '渲染所用 channel uid,多个用下划线分隔'
  37. required:
  38. - content
  39. responses:
  40. 200:
  41. description: '成功。业务失败时 HTTP 仍可能为 200,以 ok 字段为准。'
  42. content:
  43. application/json:
  44. schema:
  45. type: object
  46. properties:
  47. ok:
  48. type: boolean
  49. message:
  50. type: string
  51. data:
  52. type: object
  53. properties:
  54. uid:
  55. type: string
  56. title:
  57. type: string
  58. subtitle:
  59. type: string
  60. summary:
  61. type: string
  62. studio:
  63. type: string
  64. editor:
  65. type: string
  66. status:
  67. type: integer
  68. lang:
  69. type: string
  70. parent_uid:
  71. type: string
  72. created_at:
  73. type: string
  74. updated_at:
  75. type: string
  76. format:
  77. type: string
  78. key:
  79. type: string
  80. level:
  81. type: integer
  82. mode:
  83. type: string
  84. footnote:
  85. type: string
  86. origin:
  87. type: string
  88. paragraph:
  89. type: string
  90. role:
  91. type: string
  92. anthology_count:
  93. type: integer
  94. anthology_first:
  95. type: string
  96. path:
  97. type: string
  98. toc:
  99. type: string
  100. title_text:
  101. type: string
  102. content:
  103. type: string
  104. content_type:
  105. type: string
  106. html:
  107. type: string
  108. _summary:
  109. type: string
  110. 401:
  111. $ref: '../../main.yaml#/components/responses/Unauthorized'
  112. 422:
  113. $ref: '../../main.yaml#/components/responses/ValidationError'